Adding more comments and removing some unused variables.