Cleaned up the code, adding a few comments, and defining variables and constants to clean up the program structure.