Updated documentation, cosmetic changes, added unit tests.