More tests and some code cleanup w/ documentation.