begin the functional restructuring of the lib to proper c++