Cleaning up __main__

Use if __name__ as entry point and move config/command logic into here.