Added a tonne of comments and a few minor changes.