Added comments and "clean up" code