Refactor websockets so they are nicer.