Fixes to the client to stop a memory leak for reconnecting clients