refactors api into lib module
updates for clarity