Clean up main and move the code to __main__.py