Update API and documentation, and add tests.