CMake update and minor bugfixes