major refactoring in the library