CMake: some cleanup and improvements