Change the structure and add websocket support