Finishing the library refactoring