Refactor tcpserver and websocket. Fixes #10