moved Init and Quit functions for libraries into Library classes to ensure memory is managed better