Refactored server.cs.