Documentation, cleanup, and improved tests.