Finished the bulk of the code for server communication