Fixed a bug where the client would crash on exit; fixed a bug where the client would not reconnect after being disconnected