Client now closes session properly (including by sending a FIN)
Don't close the socket until a response to the FIN is recieved.
Add comments, clean up some code, remove unused functions
Merged