Added a main() function. Moved logic from the __main__ section into the
main method.