API refactor and cleanup