API: documentation and cleanup.