slight cleanup of main loop, websockets