Cleanup, documentation, and final tests to validate correctness