Incorporate review feedback, add tests and docs.