refactor and expose some API methods