Refactor websocket

Jira said it was working (only what he tested). I do expect some regressions but they'll be easy to patch.