some magic and fixes in main.py