Refactor libs