Networking server refactoring

Added mail logging for the server, formatted and cleaned up, and fixed bugs including not removing connections upon close