Added more comments and fixed a line of code.

Added more comments and fixed a line of code.