Update documentation and comments

Get it ready for a pull request.