Improved API and added documentation