Better socket, with multiple event handlers and better reconnect logic