Optimize API and implementation