Improved code, markup and fixed websocket timeout