diff --git a/CMakeLists.txt b/CMakeLists.txt
index ae33cd44da5d2b80c8364eefe5f6b6b4709a4881..3220831ceaf5b369966cdd6b485a612dccaeba60 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -57,6 +57,16 @@ project(TurTLE
 set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/morse ${CMAKE_MODULE_PATH})
 set(TURTLE_LIBS "")
 
+option(NDEBUG "Define NDEBUG macro" ON)
+if(NDEBUG)
+    add_definitions(-DNDEBUG)
+endif()
+
+option(TIMING_OUTPUT "Toggle timing output. WARNING: memory usage is proportional to `niter_todo`" OFF)
+if(TIMING_OUTPUT)
+    add_definitions(-DUSE_TIMINGOUTPUT)
+endif()
+
 #####################################################################################
 ## MPI
 
diff --git a/TurTLE/_code.py b/TurTLE/_code.py
index 2835ff914073804776640057672d4471ef6618fe..359f95867f36b8df3aa265c104370fbe310b6200 100644
--- a/TurTLE/_code.py
+++ b/TurTLE/_code.py
@@ -224,6 +224,12 @@ class _code(_base):
             outfile.write('set(CMAKE_CXX_COMPILE_FLAGS "${CMAKE_CXX_COMPILE_FLAGS} ${TURTLE_CXX_COMPILE_FLAGS}")\n')
             outfile.write('set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_COMPILE_FLAGS}")\n')
             outfile.write('set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${TURTLE_EXE_LINKER_FLAGS}")\n')
+            outfile.write('if(NDEBUG)\n')
+            outfile.write('    add_definitions(-DNDEBUG)\n')
+            outfile.write('endif()\n')
+            outfile.write('if(TIMING_OUTPUT)\n')
+            outfile.write('    add_definitions(-DUSE_TIMINGOUTPUT)\n')
+            outfile.write('endif()\n')
             outfile.write('include_directories(${TURTLE_INCLUDE_DIRECTORIES} ${TURTLE_INCLUDE_DIR}/TurTLE)\n')
             outfile.write('link_directories(${TURTLE_LINK_DIRECTORIES} ${TURTLE_LIBRARIES_DIR})\n')
             outfile.write('find_library(TURTLE_STATIC_LIBRARY TurTLE)\n')
diff --git a/cmake/TurTLEConfig.cmake.in b/cmake/TurTLEConfig.cmake.in
index f91c66e5de2c269eb36a80d1f64eea0603cc515c..1b4a7057a30fe453211fff0eb4d73b1996af32d7 100644
--- a/cmake/TurTLEConfig.cmake.in
+++ b/cmake/TurTLEConfig.cmake.in
@@ -50,6 +50,8 @@ SET(TURTLE_C_COMPILER  "@CMAKE_C_COMPILER@")
 SET(TURTLE_EXE_LINKER_FLAGS  "@CMAKE_EXE_LINKER_FLAGS@")
 SET(TURTLE_LIBS  "@TURTLE_LIBS@")
 set(TURTLE_DEFINITIONS @COMPILE_DEFINITIONS@)
+set(NDEBUG "@NDEBUG@")
+set(TIMING_OUTPUT "@TIMING_OUTPUT@")
 
 #
 SET(TURTLE_SOURCE_DIR	   "@TURTLE_SOURCE_DIR@")
diff --git a/cpp/fftw_tools.cpp b/cpp/fftw_tools.cpp
index 55794b41ebf8ebfa03977d5a79704aa38b39af52..e28d86c0a4f8eba08faf979bcb52eced4efcd972 100644
--- a/cpp/fftw_tools.cpp
+++ b/cpp/fftw_tools.cpp
@@ -29,8 +29,6 @@
 #include "fftw_tools.hpp"
 #include "fftw_interface.hpp"
 
-#define NDEBUG
-
 std::map<std::string, unsigned> fftw_planner_string_to_flag = {
     {"FFTW_ESTIMATE", FFTW_ESTIMATE},
     {"FFTW_MEASURE", FFTW_MEASURE},
diff --git a/cpp/field.cpp b/cpp/field.cpp
index c26b1c9ee65fd1ab9764c01ac23955ff0c4edd4a..657cc0cb3d7d9c630ac7e0a949c9cde6dae4ce96 100644
--- a/cpp/field.cpp
+++ b/cpp/field.cpp
@@ -33,8 +33,6 @@
 #include "scope_timer.hpp"
 #include "shared_array.hpp"
 
-#define NDEBUG
-
 template <typename rnumber,
           field_backend be,
           field_components fc>
diff --git a/cpp/field_layout.cpp b/cpp/field_layout.cpp
index 61dd3f2ac1094e5f93a375fa295cffab669b34f9..e2872a64fd157532bf60d036fc2dc71797f10e71 100644
--- a/cpp/field_layout.cpp
+++ b/cpp/field_layout.cpp
@@ -24,8 +24,6 @@
 
 
 
-#define NDEBUG
-
 #include <cassert>
 #include "field_layout.hpp"
 #include "scope_timer.hpp"
diff --git a/cpp/full_code/NSVE.cpp b/cpp/full_code/NSVE.cpp
index 7b1b2d9550c45f9166c37e1b8132427fed046597..21788cc9f305570dfdcd066421a83bbc065120ae 100644
--- a/cpp/full_code/NSVE.cpp
+++ b/cpp/full_code/NSVE.cpp
@@ -23,8 +23,6 @@
 
 
 
-#define NDEBUG
-
 #include <string>
 #include <cmath>
 #include "NSVE.hpp"
diff --git a/cpp/full_code/NSVEcomplex_particles.cpp b/cpp/full_code/NSVEcomplex_particles.cpp
index 701892f93dafaaf06ecdbd0c58bf3963c5b1c8e9..81408d2bf739d85a6fb668da9cb74d35d8ad2882 100644
--- a/cpp/full_code/NSVEcomplex_particles.cpp
+++ b/cpp/full_code/NSVEcomplex_particles.cpp
@@ -32,8 +32,6 @@
 #include "particles/p2p_computer.hpp"
 #include "particles/particles_inner_computer.hpp"
 
-#define NDEBUG
-
 template <typename rnumber>
 int NSVEcomplex_particles<rnumber>::initialize(void)
 {
diff --git a/cpp/full_code/NSVEparticles.cpp b/cpp/full_code/NSVEparticles.cpp
index 1952bcfccb6255bb357a8d603a74efea086db3c2..81e946771bccca1046e60ece2c568bf131ce0db7 100644
--- a/cpp/full_code/NSVEparticles.cpp
+++ b/cpp/full_code/NSVEparticles.cpp
@@ -29,8 +29,6 @@
 #include "NSVEparticles.hpp"
 #include "scope_timer.hpp"
 
-#define NDEBUG
-
 template <typename rnumber>
 int NSVEparticles<rnumber>::initialize(void)
 {
diff --git a/cpp/full_code/code_base.cpp b/cpp/full_code/code_base.cpp
index f412a792b642e70fdf36d88d0f327501a4d6ce0a..e9d062f909cf570d37bc3075b9828e27c66e6e96 100644
--- a/cpp/full_code/code_base.cpp
+++ b/cpp/full_code/code_base.cpp
@@ -27,8 +27,6 @@
 #include "code_base.hpp"
 #include "scope_timer.hpp"
 
-#define NDEBUG
-
 code_base::code_base(
         const MPI_Comm COMMUNICATOR,
         const std::string &simulation_name):
diff --git a/cpp/full_code/direct_numerical_simulation.cpp b/cpp/full_code/direct_numerical_simulation.cpp
index 955c1f2e6bcb75bd1a7538da5edd2ac2d9520ccc..15312236766534b2168abfb4da1601c86f24e6f2 100644
--- a/cpp/full_code/direct_numerical_simulation.cpp
+++ b/cpp/full_code/direct_numerical_simulation.cpp
@@ -30,8 +30,6 @@
 #include "scope_timer.hpp"
 #include "hdf5_tools.hpp"
 
-#define NDEBUG
-
 int direct_numerical_simulation::grow_file_datasets()
 {
     TIMEZONE("direct_numerical_simulation::grow_file_datasets");
diff --git a/cpp/kspace.cpp b/cpp/kspace.cpp
index 452ca305dcf6730824d27aca23b25ffa567de8ff..86d692a25c099ab5d97dd0fd5b247533815e61b6 100644
--- a/cpp/kspace.cpp
+++ b/cpp/kspace.cpp
@@ -32,8 +32,6 @@
 #include "scope_timer.hpp"
 #include "shared_array.hpp"
 
-#define NDEBUG
-
 template <field_backend be,
           kspace_dealias_type dt>
 template <field_components fc>
diff --git a/cpp/vorticity_equation.cpp b/cpp/vorticity_equation.cpp
index 38ca8f6dc55b77e8ab66b91693076dc074a3affc..58de8a5eca1d331b9fe4b4915603504c7aaab289 100644
--- a/cpp/vorticity_equation.cpp
+++ b/cpp/vorticity_equation.cpp
@@ -33,8 +33,6 @@
 #include "scope_timer.hpp"
 #include "shared_array.hpp"
 
-#define NDEBUG
-
 
 
 template <class rnumber,