more lib refactoring