Library refactor