Websocket refactoring