Move websocket init code to the right method