Cleanup API and add documentation