Refactor Websocket Message Processing