Completed main program functions for Part B.