Fixed many WebSocket logic errors.