fix math and rename websocket functions