Fix #5, Websocket constructor exception and small refactoring