Added comments and reviewed the code.