diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5e844a229efde1da03a656b8647a76f60d8e71a8..60e5e44404ccf25bce836d5535fed6819abeab39 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -23,10 +23,9 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) # for find_package
 set(CMAKE_POSITION_INDEPENDENT_CODE ON) # Allows making a shared object
 set(CMAKE_CXX_EXTENSIONS OFF) # Generate -std=c++17 instead of -std=gnu++17
 set(CMAKE_CXX_STANDARD 17)
-set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG")
-set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
-set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -DALLEN_DEBUG")
-set(CMAKE_EXE_LINKER_FLAGS "-lpthread")
+set(CMAKE_CXX_FLAGS_RELWITHDEBINFO CACHE STRING "-O3 -g -DNDEBUG")
+set(CMAKE_CXX_FLAGS_RELEASE CACHE STRING "-O3 -DNDEBUG")
+set(CMAKE_CXX_FLAGS_DEBUG CACHE STRING "-O0 -g -DALLEN_DEBUG")
 
 # -----------------------
 # Multiple-choice options
@@ -36,10 +35,12 @@ set(CMAKE_EXE_LINKER_FLAGS "-lpthread")
 set(TARGET_DEVICE CPU CACHE STRING "Target architecture of the device")
 set_property(CACHE TARGET_DEVICE PROPERTY STRINGS CPU CUDA HIP CUDACLANG)
 
-# Build type
-set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Build type")
-set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS RelWithDebInfo Release Debug)
-message(STATUS "CMAKE_BUILD_TYPE: " ${CMAKE_BUILD_TYPE})
+# Build type (builds based on Gaudi are setting CMAKE_BUILD_TYPE in gaudi_project)
+if(STANDALONE)
+  set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Build type")
+  set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS RelWithDebInfo Release Debug)
+  message(STATUS "CMAKE_BUILD_TYPE: " ${CMAKE_BUILD_TYPE})
+endif()
 
 # CUDA compute capability
 set(CUDA_ARCH COMPATIBILITY CACHE STRING "CUDA target architecture")
@@ -637,6 +638,8 @@ else()
   allen_add_device_library(AllenLib SHARED ${allen_lib_sources})
 endif()
 
+find_package(Threads REQUIRED)
+
 target_link_libraries(AllenLib PUBLIC
   Stream
   Common
@@ -647,7 +650,8 @@ target_link_libraries(AllenLib PUBLIC
   SelChecking
   AllenMonitoring
   NonEventData
-  AllenZMQ)
+  AllenZMQ
+  Threads::Threads)
 
 if (USE_MPI AND MPI_FOUND)
   get_filename_component(MPI_LIBRARY_DIR ${MPI_mpi_LIBRARY} DIRECTORY)
diff --git a/checker/pv/src/PVCheckerHistos.cpp b/checker/pv/src/PVCheckerHistos.cpp
index f0dbddbd5d8abb6f97b9491d1315ff9cb8fcdde5..e52f23682c07a07ce5fb2f802e33de548f9e0f3b 100644
--- a/checker/pv/src/PVCheckerHistos.cpp
+++ b/checker/pv/src/PVCheckerHistos.cpp
@@ -1,8 +1,10 @@
 #include "PVCheckerHistos.h"
 
+#ifdef WITH_ROOT
 namespace {
   float binomial_error(float k, float N) { return sqrtf(k * (1 - k / N)) / N; }
 } // namespace
+#endif
 
 PVCheckerHistos::PVCheckerHistos(CheckerInvoker const* invoker, std::string const& root_file)
 {
diff --git a/main/src/Allen.cpp b/main/src/Allen.cpp
index f8d8a76822af10ae007c7b26f3081c039a461259..452d9b4f7d60840aa0c4a1631be8ce4d6ecc44d8 100644
--- a/main/src/Allen.cpp
+++ b/main/src/Allen.cpp
@@ -427,8 +427,6 @@ extern "C" int allen(
   // Register all consumers
   register_consumers(updater, constants);
 
-  printf("2");
-
   // Run all registered produces and consumers
   updater->update(0);
 
@@ -447,8 +445,6 @@ extern "C" int allen(
 
   stream_wrapper.initialize_streams_host_buffers_manager(buffer_manager.get());
 
-  printf("3");
-
   if (print_status) {
     buffer_manager->printStatus();
   }
diff --git a/mdf/CMakeLists.txt b/mdf/CMakeLists.txt
index 070e9188c2985f68063c04301664f2dca78cccc0..196c11f2e4062ff47a39cb49985543ee565b70b4 100644
--- a/mdf/CMakeLists.txt
+++ b/mdf/CMakeLists.txt
@@ -75,11 +75,13 @@ function(test_program)
   cmake_parse_arguments(PARSED_ARGS "" "NAME" "" ${ARGN})
   add_executable(${PARSED_ARGS_NAME} test/${PARSED_ARGS_NAME}.cpp)
 
+  find_package(Threads REQUIRED)
+
   target_include_directories(${PARSED_ARGS_NAME} PUBLIC
     ${CMAKE_SOURCE_DIR}/mdf/include
     ${CMAKE_SOURCE_DIR}/main/include)
 
-  target_link_libraries(${PARSED_ARGS_NAME} PRIVATE MdfTestCommon)
+  target_link_libraries(${PARSED_ARGS_NAME} PRIVATE MdfTestCommon Threads::Threads)
 
   if (USE_MPI AND MPI_FOUND)
     target_compile_definitions(${PARSED_ARGS_NAME} PRIVATE HAVE_MPI)