Simplifying main.py:
Trying to move everything out of one monolithic function and into several smaller sub-functions.