added logging to both the client and the server, cleaned up exception handling