lib structure refactored