Fixing up some unclean code and adding documentation.
More documentation.
More documentation.