Phase I. Restructured code to use __main__