Added a slew of comments to make things easier to understand.