Added tests, documentation, and started refactoring up.