cleaned up, refreshed reconnecting websocket code