Minor refactor and API documentation.