refactor, add applib