Changed websocket server and handler functions to ones that return closures