refactor lib hierarchy