API refactoring

Closes #38