Added a bunch of comments for Richard.
Made various changes for readability and inserted a whole lot of
comments for Richard.