Rewrote the library in a modular way.