Finished moving functions from websocket.c to functions.h