add sockjs support, refactor some stuff
more sensible handling for websockets