Internal documentation in the form of comments.

I had to relearn some of the code, so decided to document it.