Fix for socket reconnect problems