Refactored server/main.py