Clean up API and document it