Fix makefiles and CMake