Added a saveLibrary function