Major cleanup, and build system is now OK with CMakeLists