Refactored server.py, added logging