Major refactoring to modernize library