Cleanup and documentation for API lib