Fix reference counting for key exchange handling.