diff --git a/src/threading/serial.hpp b/src/threading/serial.hpp
index eef783949049c77f3c06bfa059b02c06d96b3670..fb66e6e2ff78ec7eb638091ded2ac874583227e6 100644
--- a/src/threading/serial.hpp
+++ b/src/threading/serial.hpp
@@ -1,7 +1,7 @@
 #pragma once
 
 #if !defined(WITH_SERIAL)
-    #error this header can only be loaded if WITH_SERIAL is set
+    #error "this header can only be loaded if WITH_SERIAL is set"
 #endif
 
 #include <array>
@@ -76,6 +76,8 @@ struct timer {
     }
 };
 
+constexpr bool multithreaded() { return false; }
+
 
 } // threading
 } // mc
diff --git a/src/threading/tbb.hpp b/src/threading/tbb.hpp
index ed82e26ec87617f7453f4548efe3eec3f858507f..eae6b112bdb75b697709379b41f00cfbc249a3b1 100644
--- a/src/threading/tbb.hpp
+++ b/src/threading/tbb.hpp
@@ -44,6 +44,8 @@ struct timer {
     }
 };
 
+constexpr bool multithreaded() { return true; }
+
 } // threading
 } // mc
 } // nest
diff --git a/src/util/debug.cpp b/src/util/debug.cpp
index 6dee975a75aa3b573f4aa5affefad8ce7cf20e66..51c646bbcb38b1722e40766f4886a957094bd1bb 100644
--- a/src/util/debug.cpp
+++ b/src/util/debug.cpp
@@ -12,9 +12,7 @@ namespace nest {
 namespace mc {
 namespace util {
 
-#ifdef WITH_TBB
 std::mutex global_debug_cerr_mutex;
-#endif
 
 bool failed_assertion(const char* assertion, const char* file,
                       int line, const char* func)
diff --git a/src/util/debug.hpp b/src/util/debug.hpp
index 612b433148114a4a4696f9d0492169a26d52d988..f12f9ec40db6e0e07320ffd9216770041511b3eb 100644
--- a/src/util/debug.hpp
+++ b/src/util/debug.hpp
@@ -1,9 +1,12 @@
 #pragma once
 
 #include <iostream>
+#include <memory>
 #include <sstream>
 #include <mutex>
 
+#include "threading/threading.hpp"
+
 namespace nest {
 namespace mc {
 namespace util {
@@ -24,27 +27,31 @@ void debug_emit(std::ostream& out, const Head& head, const Tail&... tail) {
     debug_emit(out, tail...);
 }
 
-#ifdef WITH_TBB
 extern std::mutex global_debug_cerr_mutex;
-#endif
 
 template <typename... Args>
 void debug_emit_trace(const char* file, int line, const char* varlist, const Args&... args) {
-#ifdef WITH_TBB
-    std::stringstream out;
-#else
-    auto &out = std::cerr;
-#endif
+    constexpr bool multithreaded = nest::mc::threading::multithreaded();
 
-    debug_emit_trace_leader(out, file, line, varlist);
-    debug_emit(out, args...);
+    std::unique_ptr<std::ostream> buffer;
+    std::ostream* out = &std::cerr;
 
-#ifdef WITH_TBB
-    std::lock_guard<std::mutex> guard(global_debug_cerr_mutex);
-    std::cerr << out.rdbuf();
-#else
-    out.flush();
-#endif
+    if (multithreaded) {
+        buffer.reset(new std::stringstream());
+        out = buffer.get();
+    }
+
+    debug_emit_trace_leader(*out, file, line, varlist);
+    debug_emit(*out, args...);
+
+    if (multithreaded) {
+        std::lock_guard<std::mutex> guard(global_debug_cerr_mutex);
+        std::cerr << out->rdbuf();
+        std::cerr.flush();
+    }
+    else {
+        out->flush();
+    }
 }
 
 } // namespace util
@@ -57,7 +64,6 @@ void debug_emit_trace(const char* file, int line, const char* varlist, const Arg
     #define TRACE(...)
 #endif
 
-
 #ifdef WITH_ASSERTIONS
     #ifdef __GNUC__
         #define DEBUG_FUNCTION_NAME __PRETTY_FUNCTION__