Clean up variables in main program, added comments