Clean up main function for the server