refactor to use cmake and   move around code to  group up functions and put them into their own  classes/files.
makes things a bit more readable and workable for further work in refactoring things.