Fix memory leak: infinite history
SSE code clean
Fix memory leak: client closed connection