Completely refactored the program into various classes.