Segfault fixes on socketDisconnected