Cleaned up some code and fixed the messages sent to the server and how they are handled.