Refactored server controllers code.