diff --git a/Core/Export/PyFmt.cpp b/Core/Export/PyFmt.cpp
index 273849e4681f5b35be66d99de166012259dd9340..410a88b08cc209c1e8a480a9f2f161ed548a1dc2 100644
--- a/Core/Export/PyFmt.cpp
+++ b/Core/Export/PyFmt.cpp
@@ -47,15 +47,15 @@ std::string printDouble(double input) {
 std::string printLightDouble(double input) {
     std::ostringstream inter;
     int ival = std::lround(input);
-    if (std::abs(input-ival)<1e-11)
+    if (std::abs(input - ival) < 1e-11)
         inter << ival;
     else {
         inter << std::setprecision(12);
         if (std::abs(input) < std::numeric_limits<double>::epsilon())
             return "0.0";
         inter << input;
-        if (inter.str().find('e') == std::string::npos &&
-            inter.str().find('.') == std::string::npos)
+        if (inter.str().find('e') == std::string::npos
+            && inter.str().find('.') == std::string::npos)
             inter << ".0";
     }
     return inter.str();
diff --git a/Core/Export/SimulationToPython.cpp b/Core/Export/SimulationToPython.cpp
index 2f20a2d9876895a1fdc7010edc3150f4d297cb40..70fe7e8dfa3f60ea94ef2d24c1541168fad00c6d 100644
--- a/Core/Export/SimulationToPython.cpp
+++ b/Core/Export/SimulationToPython.cpp
@@ -131,17 +131,14 @@ std::string defineDetector(const ISimulation* simulation) {
         ASSERT(det->dimension() == 2);
         result << indent() << "detector = ba.SphericalDetector(";
         if (DetectorUtils::isQuadratic(*det)) {
-            result << det->axis(0).size() << ", "
-                   << pyfmt::printDegrees(det->axis(0).span()) << ", "
-                   << pyfmt::printDegrees(det->axis(0).center()) << ", "
+            result << det->axis(0).size() << ", " << pyfmt::printDegrees(det->axis(0).span())
+                   << ", " << pyfmt::printDegrees(det->axis(0).center()) << ", "
                    << pyfmt::printDegrees(det->axis(1).center());
         } else {
-            result << det->axis(0).size() << ", "
-                   << pyfmt::printDegrees(det->axis(0).lowerBound()) << ", "
-                   << pyfmt::printDegrees(det->axis(0).upperBound()) << ", "
-                   << det->axis(1).size() << ", "
-                   << pyfmt::printDegrees(det->axis(1).lowerBound()) << ", "
-                   << pyfmt::printDegrees(det->axis(1).upperBound());
+            result << det->axis(0).size() << ", " << pyfmt::printDegrees(det->axis(0).lowerBound())
+                   << ", " << pyfmt::printDegrees(det->axis(0).upperBound()) << ", "
+                   << det->axis(1).size() << ", " << pyfmt::printDegrees(det->axis(1).lowerBound())
+                   << ", " << pyfmt::printDegrees(det->axis(1).upperBound());
         }
         result << ")\n";
     } else if (const auto* const det = dynamic_cast<const RectangularDetector*>(detector)) {
@@ -438,12 +435,11 @@ std::string defineSimulate(const ISimulation* simulation) {
     return result.str();
 }
 
-
 std::string simulationCode(const ISimulation& simulation) {
     if (simulation.sample() == nullptr)
         throw std::runtime_error("Cannot export: Simulation has no sample");
     return pyfmt::scriptPreamble() + SampleToPython().sampleCode(*simulation.sample())
-        + defineSimulate(&simulation);
+           + defineSimulate(&simulation);
 }
 
 } // namespace
@@ -453,14 +449,15 @@ std::string simulationCode(const ISimulation& simulation) {
 //  ************************************************************************************************
 
 std::string SimulationToPython::simulationPlotCode(const ISimulation& simulation) {
-    return simulationCode(simulation) +
-        "if __name__ == '__main__':\n"
-        "    ba.run_and_plot(get_simulation(get_sample()))\n";
+    return simulationCode(simulation)
+           + "if __name__ == '__main__':\n"
+             "    ba.run_and_plot(get_simulation(get_sample()))\n";
 }
 
-std::string SimulationToPython::simulationSaveCode(
-    const ISimulation& simulation, const std::string& fname) {
-    return simulationCode(simulation) +
-        "if __name__ == '__main__':\n"
-        "    ba.run_and_save(get_simulation(get_sample()), \"" + fname + "\")\n";
+std::string SimulationToPython::simulationSaveCode(const ISimulation& simulation,
+                                                   const std::string& fname) {
+    return simulationCode(simulation)
+           + "if __name__ == '__main__':\n"
+             "    ba.run_and_save(get_simulation(get_sample()), \""
+           + fname + "\")\n";
 }
diff --git a/Core/Fitting/FitObjective.cpp b/Core/Fitting/FitObjective.cpp
index f1e71a0075ec836460cd624165259621e59011e2..641fbfd5acc7f5b995b73e3cc6bab36085f1e9da 100644
--- a/Core/Fitting/FitObjective.cpp
+++ b/Core/Fitting/FitObjective.cpp
@@ -17,8 +17,8 @@
 #include "Core/Fitting/ObjectiveMetric.h"
 #include "Core/Fitting/ObjectiveMetricUtils.h"
 #include "Core/Fitting/PyFittingCallbacks.h"
-#include "Core/Simulation/ISimulation.h"
 #include "Core/Residual/ChiSquaredModule.h"
+#include "Core/Simulation/ISimulation.h"
 #include <stdexcept>
 
 class IMetricWrapper {
diff --git a/Core/Residual/ChiSquaredModule.cpp b/Core/Residual/ChiSquaredModule.cpp
index 8eb31544b17147da10993df6846dd92d9bfd4589..0696de41c332c0dbea2104106910464420306723 100644
--- a/Core/Residual/ChiSquaredModule.cpp
+++ b/Core/Residual/ChiSquaredModule.cpp
@@ -14,8 +14,8 @@
 
 #include "Core/Residual/ChiSquaredModule.h"
 #include "Base/Utils/Assert.h"
-#include "Core/Residual/VarianceFunctions.h"
 #include "Core/Residual/IIntensityFunction.h"
+#include "Core/Residual/VarianceFunctions.h"
 #include <cmath>
 #include <limits>
 
diff --git a/Core/Residual/IChiSquaredModule.cpp b/Core/Residual/IChiSquaredModule.cpp
index 0351bd6faa524a6a548cb90bb59b63a1d76ae315..6cc297ea12f252e790cc3aff522d0d28eaf3b95e 100644
--- a/Core/Residual/IChiSquaredModule.cpp
+++ b/Core/Residual/IChiSquaredModule.cpp
@@ -13,8 +13,8 @@
 //  ************************************************************************************************
 
 #include "Core/Residual/IChiSquaredModule.h"
-#include "Core/Residual/VarianceFunctions.h"
 #include "Core/Residual/IIntensityFunction.h"
+#include "Core/Residual/VarianceFunctions.h"
 
 IChiSquaredModule::IChiSquaredModule() : m_variance_function(new VarianceSimFunction) {}
 
diff --git a/Device/Data/ArrayUtils.h b/Device/Data/ArrayUtils.h
index f433665cae9a06153ce850940822a9b452ec2b03..715d96ed052615686244483e124c09e2b4c4bdf9 100644
--- a/Device/Data/ArrayUtils.h
+++ b/Device/Data/ArrayUtils.h
@@ -79,7 +79,6 @@ template <class T> decltype(auto) createVector2D(const T& data);
 
 } // namespace ArrayUtils
 
-
 //  ************************************************************************************************
 //  implementation
 //  ************************************************************************************************
diff --git a/Device/Data/DataUtils.cpp b/Device/Data/DataUtils.cpp
index bc48648cac08d422d8d9dc0aa56b8e686e6f0b90..4e66a04b1baaea7c036216b2199df534db0dac8c 100644
--- a/Device/Data/DataUtils.cpp
+++ b/Device/Data/DataUtils.cpp
@@ -13,9 +13,9 @@
 //  ************************************************************************************************
 
 #include "Device/Data/DataUtils.h"
-#include "Device/Data/ArrayUtils.h"
 #include "Base/Math/FourierTransform.h"
 #include "Base/Math/Numeric.h"
+#include "Device/Data/ArrayUtils.h"
 #include <iostream>
 
 namespace {
@@ -33,9 +33,6 @@ std::vector<std::vector<double>> FT2DArray(const std::vector<std::vector<double>
 //! Returns relative difference between two data sets sum(dat[i] - ref[i])/ref[i]).
 double DataUtils::relativeDataDifference(const OutputData<double>& dat,
                                          const OutputData<double>& ref) {
-    std::cerr << "DEBUG rDD" << std::endl;
-    std::cerr << "DEBUG rDD ref rank=" << ref.rank() << ", size=" << ref.getAllocatedSize() << std::endl;
-    std::cerr << "DEBUG rDD dat rank=" << dat.rank() << ", size=" << dat.getAllocatedSize() << std::endl;
     if (!dat.hasSameDimensions(ref))
         throw std::runtime_error("OutputData dimension differs from reference");
 
@@ -51,9 +48,7 @@ double DataUtils::relativeDataDifference(const OutputData<double>& dat,
 //! Returns true is relative difference is below threshold; prints informative output
 bool DataUtils::checkRelativeDifference(const OutputData<double>& dat,
                                         const OutputData<double>& ref, const double threshold) {
-    std::cerr << "DEBUG cRD" << std::endl;
     const double diff = relativeDataDifference(dat, ref);
-    std::cerr << "DEBUG cRD -> " << diff << std::endl;
     if (diff > threshold) {
         std::cerr << "FAILED: relative deviation of dat from ref is " << diff
                   << ", above given threshold " << threshold << std::endl;
diff --git a/Device/Histo/Histogram2D.h b/Device/Histo/Histogram2D.h
index c26532ea12eaf91b466f03ba840bec02c0dc675b..ade59d9319ad21f4c14af79db0cf172268332c53 100644
--- a/Device/Histo/Histogram2D.h
+++ b/Device/Histo/Histogram2D.h
@@ -15,8 +15,8 @@
 #ifndef BORNAGAIN_DEVICE_HISTO_HISTOGRAM2D_H
 #define BORNAGAIN_DEVICE_HISTO_HISTOGRAM2D_H
 
-#include "Device/Histo/IHistogram.h"
 #include "Device/Data/ArrayUtils.h"
+#include "Device/Histo/IHistogram.h"
 
 //! Two dimensional histogram.
 //! @ingroup tools
diff --git a/Device/InputOutput/OutputDataReadWriteINT.cpp b/Device/InputOutput/OutputDataReadWriteINT.cpp
index fbc3d10d599c56f62ec4ef3853c8c53fff4f9e6d..984b606bd931abde9d5053e891eb34bb6118f4a6 100644
--- a/Device/InputOutput/OutputDataReadWriteINT.cpp
+++ b/Device/InputOutput/OutputDataReadWriteINT.cpp
@@ -14,8 +14,8 @@
 
 #include "Device/InputOutput/OutputDataReadWriteINT.h"
 #include "Base/Utils/StringUtils.h"
-#include "Device/InputOutput/DataFormatUtils.h"
 #include "Device/Data/ArrayUtils.h"
+#include "Device/InputOutput/DataFormatUtils.h"
 
 OutputData<double>* OutputDataReadWriteINT::readOutputData(std::istream& input_stream) {
     OutputData<double>* result = new OutputData<double>;
diff --git a/Device/InputOutput/OutputDataReadWriteNumpyTXT.cpp b/Device/InputOutput/OutputDataReadWriteNumpyTXT.cpp
index 717da3a86be652971999a1ef60876d679d48af18..b8ac28245273aca6eca54c5ccc9216b71a7a9162 100644
--- a/Device/InputOutput/OutputDataReadWriteNumpyTXT.cpp
+++ b/Device/InputOutput/OutputDataReadWriteNumpyTXT.cpp
@@ -14,8 +14,8 @@
 
 #include "Device/InputOutput/OutputDataReadWriteNumpyTXT.h"
 #include "Base/Utils/StringUtils.h"
-#include "Device/InputOutput/DataFormatUtils.h"
 #include "Device/Data/ArrayUtils.h"
+#include "Device/InputOutput/DataFormatUtils.h"
 #include <string>
 #include <vector>
 
diff --git a/Tests/Functional/Python/PyPersistence/PyPersistence.py.in b/Tests/Functional/Python/PyPersistence/PyPersistence.py.in
index 49e04c47196f10624cd6865c5eebdf25d035fa9a..44b63df7a801836a0c8d68fc03980d6fd6b797bb 100644
--- a/Tests/Functional/Python/PyPersistence/PyPersistence.py.in
+++ b/Tests/Functional/Python/PyPersistence/PyPersistence.py.in
@@ -25,7 +25,7 @@ def get_simulation_SpecularSimulation():
     """
     Returns custom simulation for SpecularSimulation.py.
     """
-    simulation = example.get_simulation(scan_size=10)
+    simulation = example.get_simulation(example.get_sample(), scan_size=10)
     return simulation
 
 
diff --git a/Tests/Functional/Python/Std/Check.cpp b/Tests/Functional/Python/Std/Check.cpp
index f7bbe28304c01732feb4e4283cffa17189c8ea15..07ce95eab8bb4b24834108f0add26fe9a099b16b 100644
--- a/Tests/Functional/Python/Std/Check.cpp
+++ b/Tests/Functional/Python/Std/Check.cpp
@@ -56,8 +56,8 @@ std::unique_ptr<OutputData<double>> domainData(const std::string& test_name,
     if (err)
         throw std::runtime_error("Exported Python script did not execute properly");
 
-    auto ret = std::unique_ptr<OutputData<double>>(
-        IntensityDataIOFactory::readOutputData(output_path));
+    auto ret =
+        std::unique_ptr<OutputData<double>>(IntensityDataIOFactory::readOutputData(output_path));
     if (!ret)
         throw std::runtime_error("Could not read back simulation output from file " + output_path);
     return ret;
diff --git a/Tests/Performance/GUI/CsvImportAssistantPerformanceTest.cpp b/Tests/Performance/GUI/CsvImportAssistantPerformanceTest.cpp
index 5013199da8d4bec966a0fecf1b6e8438e20a4cba..5e0114ed582610b7b105fc98880583a1e0a85302 100644
--- a/Tests/Performance/GUI/CsvImportAssistantPerformanceTest.cpp
+++ b/Tests/Performance/GUI/CsvImportAssistantPerformanceTest.cpp
@@ -13,8 +13,8 @@
 //  ************************************************************************************************
 
 #include "Tests/Performance/GUI/CsvImportAssistantPerformanceTest.h"
-#include "Device/Histo/IntensityDataIOFactory.h"
 #include "Device/Data/ArrayUtils.h"
+#include "Device/Histo/IntensityDataIOFactory.h"
 #include "GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportAssistant.h"
 #include <ctime>
 #include <iostream>
diff --git a/Tests/UnitTests/Core/Data/ChiSquaredModuleTest.cpp b/Tests/UnitTests/Core/Data/ChiSquaredModuleTest.cpp
index 26d540d7b7f1c39c1c37f04da6f9f76952ce8644..11a8e98652faa4883e46ecc06d9cfb71f181e2ca 100644
--- a/Tests/UnitTests/Core/Data/ChiSquaredModuleTest.cpp
+++ b/Tests/UnitTests/Core/Data/ChiSquaredModuleTest.cpp
@@ -1,6 +1,6 @@
 #include "Core/Residual/ChiSquaredModule.h"
-#include "Device/Data/OutputData.h"
 #include "Core/Residual/VarianceFunctions.h"
+#include "Device/Data/OutputData.h"
 #include "Tests/GTestWrapper/google_test.h"
 
 // TODO revise test
diff --git a/Tests/UnitTests/GUI/TestCsvImportAssistant.cpp b/Tests/UnitTests/GUI/TestCsvImportAssistant.cpp
index e26d642f7b6d52ab1f2cd465f449ebc4102f105c..246c8f0ec22235100e769e8370af7f83259b0770 100644
--- a/Tests/UnitTests/GUI/TestCsvImportAssistant.cpp
+++ b/Tests/UnitTests/GUI/TestCsvImportAssistant.cpp
@@ -1,5 +1,5 @@
-#include "Device/Histo/IntensityDataIOFactory.h"
 #include "Device/Data/ArrayUtils.h"
+#include "Device/Histo/IntensityDataIOFactory.h"
 #include "Device/Unit/AxisNames.h"
 #include "GUI/coregui/Models/JobItemUtils.h"
 #include "GUI/coregui/Models/SpecularDataItem.h"