Refactor websocket
Reduced memory leakage
Fixed memory leak