some restructuring, removing the internal library and making various classes and methods private.