Added comments and headers to the code.