Minor code tidy-up; added documentation for API