Tidy-up and initial API documentation.