Add API functions (patch by Eugene Arshinov, thanks):