Update main.py

general improvements