major rewrite to socket.io