Refactor move into library module