Added a lot of comments and formatting. Should be no code changes.