diff --git a/Core/Computation/ConstantBackground.cpp b/Core/Computation/ConstantBackground.cpp
index 888b0d3d6ebc761b05ea15d201cb3a6f02d81ec0..442138a77c66e7ea4841a2728289b6e496654fac 100644
--- a/Core/Computation/ConstantBackground.cpp
+++ b/Core/Computation/ConstantBackground.cpp
@@ -33,7 +33,7 @@ ConstantBackground* ConstantBackground::clone() const
     return new ConstantBackground(m_background_value);
 }
 
-double ConstantBackground::addBackGround(double intensity) const
+double ConstantBackground::addBackground(double intensity) const
 {
     return intensity + m_background_value;
 }
diff --git a/Core/Computation/ConstantBackground.h b/Core/Computation/ConstantBackground.h
index 39a49bec6c363a7df49ffb72fa913f970bee0000..b671f22e33ebafe0d384ab95454998fc4c50ce67 100644
--- a/Core/Computation/ConstantBackground.h
+++ b/Core/Computation/ConstantBackground.h
@@ -33,7 +33,7 @@ public:
 
     void accept(INodeVisitor* visitor) const override { visitor->visit(this); }
 
-    double addBackGround(double intensity) const override final;
+    double addBackground(double intensity) const override final;
 
 private:
     const double& m_background_value;
diff --git a/Core/Computation/IBackground.h b/Core/Computation/IBackground.h
index e11fa25d4b559b06a384acd4e94fe6e99e6b0da8..4b0531ea74d056a84e1da18cb9bcf0b044bea437 100644
--- a/Core/Computation/IBackground.h
+++ b/Core/Computation/IBackground.h
@@ -29,7 +29,7 @@ public:
     virtual ~IBackground();
     virtual IBackground* clone() const = 0;
 
-    virtual double addBackGround(double element) const = 0;
+    virtual double addBackground(double element) const = 0;
 };
 
 #endif // BORNAGAIN_CORE_COMPUTATION_IBACKGROUND_H
diff --git a/Core/Computation/PoissonNoiseBackground.cpp b/Core/Computation/PoissonNoiseBackground.cpp
index c2947389f91f45ca57870555ddb91553e0d25166..1f2c7637c1205b0371e5f5365558bec35a750087 100644
--- a/Core/Computation/PoissonNoiseBackground.cpp
+++ b/Core/Computation/PoissonNoiseBackground.cpp
@@ -25,7 +25,7 @@ PoissonNoiseBackground* PoissonNoiseBackground::clone() const
     return new PoissonNoiseBackground;
 }
 
-double PoissonNoiseBackground::addBackGround(double intensity) const
+double PoissonNoiseBackground::addBackground(double intensity) const
 {
     return MathFunctions::GeneratePoissonRandom(intensity);
 }
diff --git a/Core/Computation/PoissonNoiseBackground.h b/Core/Computation/PoissonNoiseBackground.h
index 2262e32d593c492eb1479f7600608fb184d4ddb2..14062c0ec2de7f199498ca7caba62a99a64f9e44 100644
--- a/Core/Computation/PoissonNoiseBackground.h
+++ b/Core/Computation/PoissonNoiseBackground.h
@@ -29,7 +29,7 @@ public:
 
     void accept(INodeVisitor* visitor) const override { visitor->visit(this); }
 
-    double addBackGround(double intensity) const override final;
+    double addBackground(double intensity) const override final;
 };
 
 #endif // BORNAGAIN_CORE_COMPUTATION_POISSONNOISEBACKGROUND_H
diff --git a/Core/Computation/RoughMultiLayerComputation.cpp b/Core/Computation/RoughMultiLayerComputation.cpp
index d411862980a0e5973e266889582c78f883d34dea..1be44ca381e18d25c4db34ec865ac96020ea2ba4 100644
--- a/Core/Computation/RoughMultiLayerComputation.cpp
+++ b/Core/Computation/RoughMultiLayerComputation.cpp
@@ -18,9 +18,9 @@
 #include "Core/Computation/ProcessedSample.h"
 #include "Sample/Fresnel/IFresnelMap.h"
 #include "Sample/Multilayer/Layer.h"
-#include "Sample/Slice/LayerInterface.h"
 #include "Sample/Multilayer/MultiLayer.h"
 #include "Sample/RT/ILayerRTCoefficients.h"
+#include "Sample/Slice/LayerInterface.h"
 #include "Sample/Slice/LayerRoughness.h"
 
 #include <cerf>
diff --git a/Core/Computation/SpecularComputationTerm.cpp b/Core/Computation/SpecularComputationTerm.cpp
index 0ba8dddb332254d408a75b47750c4520686c5cc9..72f2fe77008ddbb0d2c7ca9dd52ad08eb85e750b 100644
--- a/Core/Computation/SpecularComputationTerm.cpp
+++ b/Core/Computation/SpecularComputationTerm.cpp
@@ -15,7 +15,6 @@
 #include "Core/Computation/SpecularComputationTerm.h"
 #include "Core/Computation/DelayedProgressCounter.h"
 #include "Sample/RT/ILayerRTCoefficients.h"
-#include "Sample/Specular/ISpecularStrategy.h"
 #include "Sample/Slice/SpecularSimulationElement.h"
 
 SpecularComputationTerm::SpecularComputationTerm(std::unique_ptr<ISpecularStrategy> strategy)
diff --git a/Core/Export/SampleToPython.cpp b/Core/Export/SampleToPython.cpp
index 32cd4fa48be41c478e1980f71b978d49e006fc33..4426a7dcaf9b2897ddbeb7264862785a484c9c75 100644
--- a/Core/Export/SampleToPython.cpp
+++ b/Core/Export/SampleToPython.cpp
@@ -21,7 +21,6 @@
 #include "Sample/Aggregate/InterferenceFunctions.h"
 #include "Sample/Aggregate/ParticleLayout.h"
 #include "Sample/Multilayer/Layer.h"
-#include "Sample/Slice/LayerInterface.h"
 #include "Sample/Multilayer/MultiLayer.h"
 #include "Sample/Particle/Crystal.h"
 #include "Sample/Particle/MesoCrystal.h"
@@ -29,6 +28,7 @@
 #include "Sample/Particle/ParticleComposition.h"
 #include "Sample/Particle/ParticleCoreShell.h"
 #include "Sample/Particle/ParticleDistribution.h"
+#include "Sample/Slice/LayerInterface.h"
 #include "Sample/Slice/LayerRoughness.h"
 #include <iomanip>
 #include <map>
diff --git a/Core/Export/SimulationToPython.cpp b/Core/Export/SimulationToPython.cpp
index ca87bfe2eb5217615fe097e0a3252410e564c936..a622368761281e05226523fac86f9c1d6fb5f742 100644
--- a/Core/Export/SimulationToPython.cpp
+++ b/Core/Export/SimulationToPython.cpp
@@ -145,7 +145,7 @@ std::string SimulationToPython::defineSpecularSimulation(const SpecularSimulatio
 
 std::string SimulationToPython::defineDetector(const Simulation* simulation) const
 {
-    const IDetector* const detector = simulation->getInstrument().getDetector();
+    const IDetector* const detector = simulation->instrument().getDetector();
     if (detector->dimension() != 2)
         throw Exceptions::RuntimeErrorException("SimulationToPython::defineDetector: "
                                                 "detector must be two-dimensional for GISAS");
@@ -220,7 +220,7 @@ std::string SimulationToPython::defineDetector(const Simulation* simulation) con
 std::string SimulationToPython::defineDetectorResolutionFunction(const Simulation* simulation) const
 {
     std::ostringstream result;
-    const IDetector* detector = simulation->getInstrument().getDetector();
+    const IDetector* detector = simulation->instrument().getDetector();
 
     if (const IDetectorResolution* p_resfunc = detector->detectorResolution()) {
         if (auto* p_convfunc = dynamic_cast<const ConvolutionDetectorResolution*>(p_resfunc)) {
@@ -246,7 +246,7 @@ std::string
 SimulationToPython::defineDetectorPolarizationAnalysis(const Simulation* simulation) const
 {
     std::ostringstream result;
-    const IDetector* detector = simulation->getInstrument().getDetector();
+    const IDetector* detector = simulation->instrument().getDetector();
     kvector_t analyzer_direction = detector->detectionProperties().analyzerDirection();
     double analyzer_efficiency = detector->detectionProperties().analyzerEfficiency();
     double analyzer_total_transmission =
@@ -268,7 +268,7 @@ SimulationToPython::defineDetectorPolarizationAnalysis(const Simulation* simulat
 std::string SimulationToPython::defineGISASBeam(const GISASSimulation& simulation) const
 {
     std::ostringstream result;
-    const Beam& beam = simulation.getInstrument().getBeam();
+    const Beam& beam = simulation.instrument().getBeam();
 
     result << pyfmt::indent() << "simulation.setBeamParameters("
            << pyfmt::printNm(beam.getWavelength()) << ", " << pyfmt::printDegrees(beam.getAlpha())
@@ -283,7 +283,7 @@ std::string SimulationToPython::defineGISASBeam(const GISASSimulation& simulatio
 std::string SimulationToPython::defineOffSpecBeam(const OffSpecSimulation& simulation) const
 {
     std::ostringstream result;
-    const Beam& beam = simulation.getInstrument().getBeam();
+    const Beam& beam = simulation.instrument().getBeam();
 
     const std::string axis_def = pyfmt::indent() + "alpha_i_axis = ";
     result << axis_def << simulation.beamAxis()->pyString("rad", axis_def.size()) << "\n";
@@ -307,7 +307,7 @@ std::string SimulationToPython::defineSpecularScan(const SpecularSimulation& sim
     result << *scan << "\n";
 
     result << pyfmt::indent() << "simulation.setScan(scan)\n";
-    result << defineBeamIntensity(simulation.getInstrument().getBeam());
+    result << defineBeamIntensity(simulation.instrument().getBeam());
     result << "\n";
     return result.str();
 }
@@ -371,7 +371,7 @@ std::string SimulationToPython::defineMasks(const Simulation* simulation) const
     std::ostringstream result;
     result << std::setprecision(12);
 
-    const IDetector* detector = simulation->getInstrument().getDetector();
+    const IDetector* detector = simulation->instrument().getDetector();
     const DetectorMask* detectorMask = detector->detectorMask();
     if (detectorMask && detectorMask->numberOfMasks()) {
         result << "\n";
diff --git a/Core/Fitting/ObjectiveMetric.cpp b/Core/Fitting/ObjectiveMetric.cpp
index a8aff56d0b42b061827538ae8f47abf4f8b1a75a..6c093dc0ab1a0459dc5f9beda862d70686796c7e 100644
--- a/Core/Fitting/ObjectiveMetric.cpp
+++ b/Core/Fitting/ObjectiveMetric.cpp
@@ -27,9 +27,9 @@ const double ln10 = std::log(10.0);
 
 template <class T> T* copyMetric(const T& metric)
 {
-    std::unique_ptr<T> result(new T());
+    auto* result = new T;
     result->setNorm(metric.norm());
-    return result.release();
+    return result;
 }
 
 void checkIntegrity(const std::vector<double>& sim_data, const std::vector<double>& exp_data,
diff --git a/Core/Simulation/DepthProbeSimulation.cpp b/Core/Simulation/DepthProbeSimulation.cpp
index 7811829263546d22565f2ca582b318050c0d3ffe..d3f10b808158fd5b16f469b199c23fdf61fec0aa 100644
--- a/Core/Simulation/DepthProbeSimulation.cpp
+++ b/Core/Simulation/DepthProbeSimulation.cpp
@@ -99,7 +99,7 @@ size_t DepthProbeSimulation::intensityMapSize() const
 
 std::unique_ptr<IUnitConverter> DepthProbeSimulation::createUnitConverter() const
 {
-    return std::make_unique<DepthProbeConverter>(m_instrument.getBeam(), *m_alpha_axis, *m_z_axis);
+    return std::make_unique<DepthProbeConverter>(instrument().getBeam(), *m_alpha_axis, *m_z_axis);
 }
 
 DepthProbeSimulation::DepthProbeSimulation(const DepthProbeSimulation& other)
@@ -133,21 +133,21 @@ void DepthProbeSimulation::setBeamParameters(double lambda, const IAxis& alpha_a
             "Error in DepthProbeSimulation::setBeamParameters: angle axis is empty");
 
     SpecularDetector1D detector(alpha_axis);
-    m_instrument.setDetector(detector);
+    instrument().setDetector(detector);
     m_alpha_axis.reset(alpha_axis.clone());
 
     // beam is initialized with zero-valued angles
     // Zero-valued incident alpha is required for proper
     // taking into account beam resolution effects
-    m_instrument.setBeamParameters(lambda, zero_alpha_i, zero_phi_i);
+    instrument().setBeamParameters(lambda, zero_alpha_i, zero_phi_i);
 
     if (beam_shape)
-        m_instrument.getBeam().setFootprintFactor(*beam_shape);
+        instrument().getBeam().setFootprintFactor(*beam_shape);
 }
 
 void DepthProbeSimulation::initSimulationElementVector()
 {
-    const auto& beam = m_instrument.getBeam();
+    const auto& beam = instrument().getBeam();
     m_sim_elements = generateSimulationElements(beam);
 
     if (!m_cache.empty())
@@ -178,7 +178,7 @@ DepthProbeSimulation::generateSingleThreadedComputation(size_t start, size_t n_e
 {
     ASSERT(start < m_sim_elements.size() && start + n_elements <= m_sim_elements.size());
     const auto& begin = m_sim_elements.begin() + static_cast<long>(start);
-    return std::make_unique<DepthProbeComputation>(*sample(), m_options, m_progress, begin,
+    return std::make_unique<DepthProbeComputation>(*sample(), options(), progress(), begin,
                                                    begin + static_cast<long>(n_elements));
 }
 
@@ -224,7 +224,7 @@ void DepthProbeSimulation::initialize()
 
     // allow for negative inclinations in the beam of specular simulation
     // it is required for proper averaging in the case of divergent beam
-    auto inclination = m_instrument.getBeam().parameter("InclinationAngle");
+    auto inclination = instrument().getBeam().parameter("InclinationAngle");
     inclination->setLimits(RealLimits::limited(-M_PI_2, M_PI_2));
 }
 
@@ -236,7 +236,7 @@ void DepthProbeSimulation::normalize(size_t start_ind, size_t n_elements)
     for (size_t i = start_ind, stop_point = start_ind + n_elements; i < stop_point; ++i) {
         auto& element = m_sim_elements[i];
         const double alpha_i = -element.getAlphaI();
-        const auto footprint = m_instrument.getBeam().footprintFactor();
+        const auto footprint = instrument().getBeam().footprintFactor();
         double intensity_factor = beam_intensity;
         if (footprint != nullptr)
             intensity_factor = intensity_factor * footprint->calculate(alpha_i);
@@ -244,12 +244,11 @@ void DepthProbeSimulation::normalize(size_t start_ind, size_t n_elements)
     }
 }
 
-void DepthProbeSimulation::addBackGroundIntensity(size_t, size_t)
+void DepthProbeSimulation::addBackgroundIntensity(size_t, size_t)
 {
-    if (!mP_background)
-        return;
-    throw std::runtime_error("Error in DepthProbeSimulation::addBackGroundIntensity: background is "
-                             "not allowed for this type of simulation");
+    if (background())
+        throw std::runtime_error(
+            "Error: nonzero background is not supported by DepthProbeSimulation");
 }
 
 void DepthProbeSimulation::addDataToCache(double weight)
diff --git a/Core/Simulation/DepthProbeSimulation.h b/Core/Simulation/DepthProbeSimulation.h
index da7dfefe37dca04d69fd515c61f4cb0b94e18f49..099f2c741198fc4a2c5adff2ed56e748306d36e6 100644
--- a/Core/Simulation/DepthProbeSimulation.h
+++ b/Core/Simulation/DepthProbeSimulation.h
@@ -103,7 +103,7 @@ private:
     //! @param n_elements Number of elements to process
     void normalize(size_t start_ind, size_t n_elements) override;
 
-    void addBackGroundIntensity(size_t start_ind, size_t n_elements) override;
+    void addBackgroundIntensity(size_t start_ind, size_t n_elements) override;
 
     void addDataToCache(double weight) override;
 
diff --git a/Core/Simulation/GISASSimulation.cpp b/Core/Simulation/GISASSimulation.cpp
index 87a1ffc6174805ba8800c35ff16e4a3a7b43e274..a71f9be94b067c967e5e63e014b374cb7c676d86 100644
--- a/Core/Simulation/GISASSimulation.cpp
+++ b/Core/Simulation/GISASSimulation.cpp
@@ -27,20 +27,19 @@ GISASSimulation::GISASSimulation()
 
 void GISASSimulation::prepareSimulation()
 {
-    if (m_instrument.getDetectorDimension() != 2)
+    if (instrument().getDetectorDimension() != 2)
         throw Exceptions::LogicErrorException(
             "GISASSimulation::prepareSimulation() "
             "-> Error. The detector was not properly configured.");
-    getInstrument().initDetector();
+    instrument().initDetector();
     Simulation2D::prepareSimulation();
 }
 
 SimulationResult GISASSimulation::result() const
 {
-    const auto& instrument = getInstrument();
-    const auto converter = UnitConverterUtils::createConverterForGISAS(instrument);
+    const auto converter = UnitConverterUtils::createConverterForGISAS(instrument());
     const std::unique_ptr<OutputData<double>> data(
-        instrument.detector().createDetectorIntensity(m_sim_elements));
+        instrument().detector().createDetectorIntensity(m_sim_elements));
     return SimulationResult(*data, *converter);
 }
 
@@ -49,13 +48,13 @@ void GISASSimulation::setBeamParameters(double wavelength, double alpha_i, doubl
     if (wavelength <= 0.0)
         throw Exceptions::ClassInitializationException(
             "Simulation::setBeamParameters() -> Error. Incoming wavelength <= 0.");
-    m_instrument.setBeamParameters(wavelength, alpha_i, phi_i);
+    instrument().setBeamParameters(wavelength, alpha_i, phi_i);
 }
 
 size_t GISASSimulation::intensityMapSize() const
 {
     size_t result = 0;
-    getInstrument().detector().iterate([&result](IDetector::const_iterator) { ++result; }, true);
+    instrument().detector().iterate([&result](IDetector::const_iterator) { ++result; }, true);
     return result;
 }
 
@@ -66,7 +65,7 @@ GISASSimulation::GISASSimulation(const GISASSimulation& other) : Simulation2D(ot
 
 void GISASSimulation::initSimulationElementVector()
 {
-    auto beam = m_instrument.getBeam();
+    auto beam = instrument().getBeam();
     m_sim_elements = generateSimulationElements(beam);
     if (m_cache.empty())
         m_cache.resize(m_sim_elements.size(), 0.0);
diff --git a/Core/Simulation/OffSpecSimulation.cpp b/Core/Simulation/OffSpecSimulation.cpp
index ad551ecd291df97eabe6c5d2871561e918394d66..8ae936d202a54958ab68dca8f4890e343a637f20 100644
--- a/Core/Simulation/OffSpecSimulation.cpp
+++ b/Core/Simulation/OffSpecSimulation.cpp
@@ -42,7 +42,7 @@ size_t OffSpecSimulation::numberOfSimulationElements() const
 SimulationResult OffSpecSimulation::result() const
 {
     auto data = std::unique_ptr<OutputData<double>>(m_intensity_map.clone());
-    OffSpecularConverter converter(getInstrument().detector2D(), getInstrument().getBeam(),
+    OffSpecularConverter converter(instrument().detector2D(), instrument().getBeam(),
                                    *mP_alpha_i_axis);
     return SimulationResult(*data, converter);
 }
@@ -54,7 +54,7 @@ void OffSpecSimulation::setBeamParameters(double wavelength, const IAxis& alpha_
         throw Exceptions::ClassInitializationException("OffSpecSimulation::prepareSimulation() "
                                                        "-> Error. Incoming alpha range size < 1.");
     const double alpha_zero = alpha_axis.getMin();
-    m_instrument.setBeamParameters(wavelength, alpha_zero, phi_i);
+    instrument().setBeamParameters(wavelength, alpha_zero, phi_i);
     updateIntensityMap();
 }
 
@@ -69,14 +69,14 @@ std::unique_ptr<IUnitConverter> OffSpecSimulation::createUnitConverter() const
     if (!axis)
         throw std::runtime_error("Error in OffSpecSimulation::createUnitConverter:"
                                  " missing inclination angle axis");
-    return std::make_unique<OffSpecularConverter>(getInstrument().detector2D(),
-                                                  getInstrument().getBeam(), *axis);
+    return std::make_unique<OffSpecularConverter>(instrument().detector2D(), instrument().getBeam(),
+                                                  *axis);
 }
 
 size_t OffSpecSimulation::intensityMapSize() const
 {
     checkInitialization();
-    return mP_alpha_i_axis->size() * m_instrument.getDetectorAxis(1).size();
+    return mP_alpha_i_axis->size() * instrument().getDetectorAxis(1).size();
 }
 
 OffSpecSimulation::OffSpecSimulation(const OffSpecSimulation& other) : Simulation2D(other)
@@ -90,7 +90,7 @@ OffSpecSimulation::OffSpecSimulation(const OffSpecSimulation& other) : Simulatio
 void OffSpecSimulation::initSimulationElementVector()
 {
     m_sim_elements.clear();
-    Beam beam = m_instrument.getBeam();
+    Beam beam = instrument().getBeam();
     const double wavelength = beam.getWavelength();
     const double phi_i = beam.getPhi();
 
@@ -125,7 +125,7 @@ void OffSpecSimulation::validateParametrization(const ParameterDistribution& par
 void OffSpecSimulation::transferResultsToIntensityMap()
 {
     checkInitialization();
-    const IAxis& phi_axis = m_instrument.getDetectorAxis(0);
+    const IAxis& phi_axis = instrument().getDetectorAxis(0);
     size_t phi_f_size = phi_axis.size();
     if (phi_f_size * m_intensity_map.getAllocatedSize() != m_sim_elements.size())
         throw Exceptions::RuntimeErrorException(
@@ -140,23 +140,23 @@ void OffSpecSimulation::updateIntensityMap()
     m_intensity_map.clear();
     if (mP_alpha_i_axis)
         m_intensity_map.addAxis(*mP_alpha_i_axis);
-    size_t detector_dimension = m_instrument.getDetectorDimension();
+    size_t detector_dimension = instrument().getDetectorDimension();
     if (detector_dimension == 2)
-        m_intensity_map.addAxis(m_instrument.getDetectorAxis(1));
+        m_intensity_map.addAxis(instrument().getDetectorAxis(1));
     m_intensity_map.setAllTo(0.);
 }
 
 void OffSpecSimulation::transferDetectorImage(size_t index)
 {
     OutputData<double> detector_image;
-    size_t detector_dimension = m_instrument.getDetectorDimension();
+    size_t detector_dimension = instrument().getDetectorDimension();
     for (size_t dim = 0; dim < detector_dimension; ++dim)
-        detector_image.addAxis(m_instrument.getDetectorAxis(dim));
+        detector_image.addAxis(instrument().getDetectorAxis(dim));
     size_t detector_size = detector_image.getAllocatedSize();
     for (size_t i = 0; i < detector_size; ++i)
         detector_image[i] = m_sim_elements[index * detector_size + i].getIntensity();
-    m_instrument.applyDetectorResolution(&detector_image);
-    size_t y_axis_size = m_instrument.getDetectorAxis(1).size();
+    instrument().applyDetectorResolution(&detector_image);
+    size_t y_axis_size = instrument().getDetectorAxis(1).size();
     for (size_t i = 0; i < detector_size; ++i)
         m_intensity_map[index * y_axis_size + i % y_axis_size] += detector_image[i];
 }
@@ -166,7 +166,7 @@ void OffSpecSimulation::checkInitialization() const
     if (!mP_alpha_i_axis || mP_alpha_i_axis->size() < 1)
         throw Exceptions::ClassInitializationException("OffSpecSimulation::checkInitialization() "
                                                        "Incoming alpha range not configured.");
-    if (m_instrument.getDetectorDimension() != 2)
+    if (instrument().getDetectorDimension() != 2)
         throw Exceptions::RuntimeErrorException(
             "OffSpecSimulation::checkInitialization: detector is not two-dimensional");
 }
diff --git a/Core/Simulation/Simulation.cpp b/Core/Simulation/Simulation.cpp
index 0709743257882a1a76a75f2e16412bfc802a867e..9ea4672d44454c90906dc4b163c58433271d08a8 100644
--- a/Core/Simulation/Simulation.cpp
+++ b/Core/Simulation/Simulation.cpp
@@ -17,7 +17,6 @@
 #include "Core/Computation/IComputation.h"
 #include "Core/Simulation/MPISimulation.h"
 #include "Core/Simulation/UnitConverterUtils.h"
-#include "Device/Detector/DetectorFunctions.h"
 #include "Fit/Tools/StringUtils.h"
 #include "Param/Base/ParameterPool.h"
 #include "Sample/Multilayer/MultiLayer.h"
@@ -31,6 +30,18 @@
 namespace
 {
 
+bool detHasSameDimensions(const IDetector& detector, const OutputData<double>& data)
+{
+    if (data.getRank() != detector.dimension())
+        return false;
+
+    for (size_t i = 0; i < detector.dimension(); ++i)
+        if (data.getAxis(i).size() != detector.getAxis(i).size())
+            return false;
+
+    return true;
+}
+
 size_t getIndexStep(size_t total_size, size_t n_handlers)
 {
     ASSERT(total_size > 0);
@@ -111,12 +122,12 @@ Simulation::Simulation()
 }
 
 Simulation::Simulation(const Simulation& other)
-    : ICloneable(), INode(), m_sample_provider(other.m_sample_provider), m_options(other.m_options),
-      m_distribution_handler(other.m_distribution_handler), m_progress(other.m_progress),
-      m_instrument(other.m_instrument)
+    : ICloneable(), INode(), m_options(other.m_options), m_progress(other.m_progress),
+      m_sample_provider(other.m_sample_provider),
+      m_distribution_handler(other.m_distribution_handler), m_instrument(other.instrument())
 {
-    if (other.mP_background)
-        setBackground(*other.mP_background);
+    if (other.m_background)
+        setBackground(*other.m_background);
     initialize();
 }
 
@@ -142,35 +153,35 @@ void Simulation::setTerminalProgressMonitor()
 
 void Simulation::setDetectorResolutionFunction(const IResolutionFunction2D& resolution_function)
 {
-    m_instrument.setDetectorResolutionFunction(resolution_function);
+    instrument().setDetectorResolutionFunction(resolution_function);
 }
 
 void Simulation::removeDetectorResolutionFunction()
 {
-    m_instrument.removeDetectorResolution();
+    instrument().removeDetectorResolution();
 }
 
 //! Sets the polarization analyzer characteristics of the detector
 void Simulation::setAnalyzerProperties(const kvector_t direction, double efficiency,
                                        double total_transmission)
 {
-    m_instrument.setAnalyzerProperties(direction, efficiency, total_transmission);
+    instrument().setAnalyzerProperties(direction, efficiency, total_transmission);
 }
 
 void Simulation::setBeamIntensity(double intensity)
 {
-    m_instrument.setBeamIntensity(intensity);
+    instrument().setBeamIntensity(intensity);
 }
 
 double Simulation::getBeamIntensity() const
 {
-    return m_instrument.getBeamIntensity();
+    return instrument().getBeamIntensity();
 }
 
 //! Sets the beam polarization according to the given Bloch vector
 void Simulation::setBeamPolarization(const kvector_t bloch_vector)
 {
-    m_instrument.setBeamPolarization(bloch_vector);
+    instrument().setBeamPolarization(bloch_vector);
 }
 
 void Simulation::prepareSimulation()
@@ -219,9 +230,9 @@ void Simulation::runMPISimulation()
     ompi.runSimulation(this);
 }
 
-void Simulation::setInstrument(const Instrument& instrument)
+void Simulation::setInstrument(const Instrument& instrument_)
 {
-    m_instrument = instrument;
+    m_instrument = instrument_;
     updateIntensityMap();
 }
 
@@ -243,17 +254,17 @@ void Simulation::setSampleBuilder(const std::shared_ptr<class ISampleBuilder>& s
 
 void Simulation::setBackground(const IBackground& bg)
 {
-    mP_background.reset(bg.clone());
-    registerChild(mP_background.get());
+    m_background.reset(bg.clone());
+    registerChild(m_background.get());
 }
 
 std::vector<const INode*> Simulation::getChildren() const
 {
     std::vector<const INode*> result;
-    result.push_back(&m_instrument);
+    result.push_back(&instrument());
     result << m_sample_provider.getChildren();
-    if (mP_background)
-        result.push_back(mP_background.get());
+    if (m_background)
+        result.push_back(m_background.get());
     return result;
 }
 
@@ -293,7 +304,7 @@ void Simulation::runSingleSimulation(size_t batch_start, size_t batch_size, doub
     runComputations(std::move(computations));
 
     normalize(batch_start, batch_size);
-    addBackGroundIntensity(batch_start, batch_size);
+    addBackgroundIntensity(batch_start, batch_size);
     addDataToCache(weight);
 }
 
@@ -307,7 +318,7 @@ SimulationResult Simulation::convertData(const OutputData<double>& data,
     auto converter = UnitConverterUtils::createConverter(*this);
     auto roi_data = UnitConverterUtils::createOutputData(*converter, converter->defaultUnits());
 
-    const IDetector& detector = getInstrument().detector();
+    const IDetector& detector = instrument().detector();
 
     if (roi_data->hasSameDimensions(data)) {
         // data is already cropped to ROI
@@ -321,7 +332,7 @@ SimulationResult Simulation::convertData(const OutputData<double>& data,
             roi_data->setRawDataVector(data.getRawDataVector());
         }
 
-    } else if (DetectorFunctions::hasSameDimensions(detector, data)) {
+    } else if (detHasSameDimensions(detector, data)) {
         // exp data has same shape as the detector, we have to put orig data to smaller roi map
         detector.iterate(
             [&](IDetector::const_iterator it) {
diff --git a/Core/Simulation/Simulation.h b/Core/Simulation/Simulation.h
index def41e1dc848ecc48a94aba570085dde7d749a96..8dda1d7137ccbe841f16b22260c74466d83c1ca5 100644
--- a/Core/Simulation/Simulation.h
+++ b/Core/Simulation/Simulation.h
@@ -51,9 +51,9 @@ public:
     //! Run a simulation in a MPI environment
     void runMPISimulation();
 
-    void setInstrument(const Instrument& instrument);
-    const Instrument& getInstrument() const { return m_instrument; }
-    Instrument& getInstrument() { return m_instrument; }
+    void setInstrument(const Instrument& instrument_);
+    const Instrument& instrument() const { return m_instrument; }
+    Instrument& instrument() { return m_instrument; }
 
     void setBeamIntensity(double intensity);
     double getBeamIntensity() const;
@@ -72,7 +72,7 @@ public:
     void setSampleBuilder(const std::shared_ptr<ISampleBuilder>& sample_builder);
 
     void setBackground(const IBackground& bg);
-    const IBackground* background() const { return mP_background.get(); }
+    const IBackground* background() const { return m_background.get(); }
 
     //! Returns the total number of the intensity values in the simulation result
     virtual size_t intensityMapSize() const = 0;
@@ -117,12 +117,8 @@ protected:
     //! Gets the number of elements this simulation needs to calculate
     virtual size_t numberOfSimulationElements() const = 0;
 
-    SampleProvider m_sample_provider;
-    SimulationOptions m_options;
-    DistributionHandler m_distribution_handler;
-    ProgressHandler m_progress;
-    Instrument m_instrument;
-    std::unique_ptr<IBackground> mP_background;
+    const SimulationOptions& options() const { return m_options; }
+    ProgressHandler& progress() { return m_progress; }
 
 private:
     void initialize();
@@ -138,7 +134,7 @@ private:
     //! Checks the distribution validity for simulation.
     virtual void validateParametrization(const ParameterDistribution&) const {}
 
-    virtual void addBackGroundIntensity(size_t start_ind, size_t n_elements) = 0;
+    virtual void addBackgroundIntensity(size_t start_ind, size_t n_elements) = 0;
 
     //! Normalize the detector counts to beam intensity, to solid angle, and to exposure angle.
     //! @param start_ind Index of the first element to operate on
@@ -152,6 +148,13 @@ private:
     // used in MPI calculations for transfer of partial results
     virtual std::vector<double> rawResults() const = 0;
     virtual void setRawResults(const std::vector<double>& raw_data) = 0;
+
+    SimulationOptions m_options;
+    ProgressHandler m_progress;
+    SampleProvider m_sample_provider;
+    DistributionHandler m_distribution_handler;
+    Instrument m_instrument;
+    std::unique_ptr<IBackground> m_background;
 };
 
 #endif // BORNAGAIN_CORE_SIMULATION_SIMULATION_H
diff --git a/Core/Simulation/Simulation2D.cpp b/Core/Simulation/Simulation2D.cpp
index dba2e9511fef487f88a66e5979488f5caf44f886..854aa239da73596054ee7d5ad70951d73d700a58 100644
--- a/Core/Simulation/Simulation2D.cpp
+++ b/Core/Simulation/Simulation2D.cpp
@@ -17,7 +17,6 @@
 #include "Core/Computation/DWBAComputation.h"
 #include "Core/Computation/IBackground.h"
 #include "Device/Detector/DetectorContext.h"
-#include "Device/Detector/DetectorFunctions.h"
 #include "Device/Histo/Histogram2D.h"
 
 Simulation2D::Simulation2D() = default;
@@ -27,27 +26,27 @@ Simulation2D::~Simulation2D() = default;
 void Simulation2D::prepareSimulation()
 {
     Simulation::prepareSimulation();
-    m_detector_context = m_instrument.detector2D().createContext();
+    m_detector_context = instrument().detector2D().createContext();
 }
 
 void Simulation2D::removeMasks()
 {
-    m_instrument.detector2D().removeMasks();
+    instrument().detector2D().removeMasks();
 }
 
 void Simulation2D::addMask(const IShape2D& shape, bool mask_value)
 {
-    m_instrument.detector2D().addMask(shape, mask_value);
+    instrument().detector2D().addMask(shape, mask_value);
 }
 
 void Simulation2D::maskAll()
 {
-    m_instrument.detector2D().maskAll();
+    instrument().detector2D().maskAll();
 }
 
 void Simulation2D::setRegionOfInterest(double xlow, double ylow, double xup, double yup)
 {
-    m_instrument.detector2D().setRegionOfInterest(xlow, ylow, xup, yup);
+    instrument().detector2D().setRegionOfInterest(xlow, ylow, xup, yup);
 }
 
 Simulation2D::Simulation2D(const Simulation2D& other)
@@ -65,13 +64,13 @@ size_t Simulation2D::numberOfSimulationElements() const
 void Simulation2D::setDetectorParameters(size_t n_x, double x_min, double x_max, size_t n_y,
                                          double y_min, double y_max)
 {
-    m_instrument.detector2D().setDetectorParameters(n_x, x_min, x_max, n_y, y_min, y_max);
+    instrument().detector2D().setDetectorParameters(n_x, x_min, x_max, n_y, y_min, y_max);
     updateIntensityMap();
 }
 
 void Simulation2D::setDetector(const IDetector2D& detector)
 {
-    m_instrument.setDetector(detector);
+    instrument().setDetector(detector);
     initUnitConverter();
 }
 
@@ -80,7 +79,7 @@ std::unique_ptr<IComputation> Simulation2D::generateSingleThreadedComputation(si
 {
     ASSERT(start < m_sim_elements.size() && start + n_elements <= m_sim_elements.size());
     const auto& begin = m_sim_elements.begin() + static_cast<long>(start);
-    return std::make_unique<DWBAComputation>(*sample(), m_options, m_progress, begin,
+    return std::make_unique<DWBAComputation>(*sample(), options(), progress(), begin,
                                              begin + static_cast<long>(n_elements));
 }
 
@@ -91,7 +90,7 @@ std::vector<SimulationElement> Simulation2D::generateSimulationElements(const Be
     const double phi_i = beam.getPhi();
     const Eigen::Matrix2cd beam_polarization = beam.getPolarization();
 
-    const IDetector2D& detector = m_instrument.detector2D();
+    const IDetector2D& detector = instrument().detector2D();
     const Eigen::Matrix2cd analyzer_operator = detector.detectionProperties().analyzerOperator();
     const size_t spec_index = detector.indexOfSpecular(beam);
 
@@ -126,13 +125,13 @@ void Simulation2D::normalize(size_t start_ind, size_t n_elements)
     }
 }
 
-void Simulation2D::addBackGroundIntensity(size_t start_ind, size_t n_elements)
+void Simulation2D::addBackgroundIntensity(size_t start_ind, size_t n_elements)
 {
-    if (!mP_background)
+    if (!background())
         return;
     for (size_t i = start_ind, stop_point = start_ind + n_elements; i < stop_point; ++i) {
         SimulationElement& element = m_sim_elements[i];
-        element.setIntensity(mP_background->addBackGround(element.getIntensity()));
+        element.setIntensity(background()->addBackground(element.getIntensity()));
     }
 }
 
diff --git a/Core/Simulation/Simulation2D.h b/Core/Simulation/Simulation2D.h
index 82e85a3abde75b12cfbada93455cb467ecce496c..59ac897e0582cdd284360ec266fe0fca07a0db1c 100644
--- a/Core/Simulation/Simulation2D.h
+++ b/Core/Simulation/Simulation2D.h
@@ -85,7 +85,7 @@ protected:
     //! @param n_elements Number of elements to process
     void normalize(size_t start_ind, size_t n_elements) override;
 
-    void addBackGroundIntensity(size_t start_ind, size_t n_elements) override;
+    void addBackgroundIntensity(size_t start_ind, size_t n_elements) override;
 
     void addDataToCache(double weight) override;
 
diff --git a/Core/Simulation/SpecularSimulation.cpp b/Core/Simulation/SpecularSimulation.cpp
index ef2ea82a9de6680e580773d0d71edcd909458c84..92dfdca83bb26e0d87a27bcfef40e5aadcaf82cd 100644
--- a/Core/Simulation/SpecularSimulation.cpp
+++ b/Core/Simulation/SpecularSimulation.cpp
@@ -14,7 +14,6 @@
 
 #include "Core/Simulation/SpecularSimulation.h"
 #include "Base/Axis/PointwiseAxis.h"
-#include "Base/Const/MathConstants.h"
 #include "Core/Computation/IBackground.h"
 #include "Core/Computation/SpecularComputation.h"
 #include "Device/Beam/IFootprintFactor.h"
@@ -25,20 +24,29 @@
 #include "Param/Base/ParameterPool.h"
 #include "Param/Base/RealParameter.h"
 #include "Param/Distrib/Distributions.h"
-#include "Sample/Material/MaterialUtils.h"
-#include "Sample/Multilayer/MultiLayer.h"
-#include "Sample/SampleBuilderEngine/ISampleBuilder.h"
 #include "Sample/Slice/SpecularSimulationElement.h"
 
 namespace
 {
 // TODO: remove when pointwise resolution is implemented
-std::unique_ptr<ISpecularScan> mangledDataHandler(const ISpecularScan& data_handler,
-                                                  const Beam& beam);
+std::unique_ptr<AngularSpecScan> mangledDataHandler(const ISpecularScan& data_handler,
+                                                    const Beam& beam)
+{
+    if (data_handler.dataType() != ISpecularScan::angle)
+        throw std::runtime_error("Error in mangledDataHandler: invalid usage");
+    const auto& scan = static_cast<const AngularSpecScan&>(data_handler);
 
-const RealLimits alpha_limits = RealLimits::limited(0.0, M_PI_2);
-const double zero_phi_i = 0.0;
-const double zero_alpha_i = 0.0;
+    const double wl = beam.getWavelength();
+    const double angle_shift = beam.getAlpha();
+    std::vector<double> angles = scan.coordinateAxis()->getBinCenters();
+    for (auto& val : angles)
+        val += angle_shift;
+    auto* result = new AngularSpecScan(wl, PointwiseAxis("alpha_i", std::move(angles)));
+    result->setFootprintFactor(scan.footprintFactor());
+    result->setWavelengthResolution(*scan.wavelengthResolution());
+    result->setAngleResolution(*scan.angleResolution());
+    return std::unique_ptr<AngularSpecScan>(result);
+}
 } // namespace
 
 SpecularSimulation::SpecularSimulation() : Simulation()
@@ -46,6 +54,14 @@ SpecularSimulation::SpecularSimulation() : Simulation()
     initialize();
 }
 
+SpecularSimulation::SpecularSimulation(const SpecularSimulation& other)
+    : Simulation(other),
+      m_data_handler(other.m_data_handler ? other.m_data_handler->clone() : nullptr),
+      m_sim_elements(other.m_sim_elements), m_cache(other.m_cache)
+{
+    initialize();
+}
+
 SpecularSimulation::~SpecularSimulation() = default;
 
 SpecularSimulation* SpecularSimulation::clone() const
@@ -55,10 +71,10 @@ SpecularSimulation* SpecularSimulation::clone() const
 
 void SpecularSimulation::prepareSimulation()
 {
-    if (m_instrument.getDetectorDimension() != 1) // detector must have only one axis
+    if (instrument().getDetectorDimension() != 1) // detector must have only one axis
         throw std::runtime_error("Error in SpecularSimulation::prepareSimulation: the detector was "
                                  "not properly configured.");
-    getInstrument().initDetector();
+    instrument().initDetector();
     Simulation::prepareSimulation();
 }
 
@@ -69,9 +85,16 @@ size_t SpecularSimulation::numberOfSimulationElements() const
 
 SimulationResult SpecularSimulation::result() const
 {
-    auto data = createIntensityData();
+    OutputData<double> data;
+    data.addAxis(*coordinateAxis());
+
+    if (!m_sim_elements.empty())
+        data.setRawDataVector(m_data_handler->createIntensities(m_sim_elements));
+    else
+        data.setAllTo(0.0);
+
     auto converter = UnitConverter1D::createUnitConverter(*m_data_handler);
-    return SimulationResult(*data, *converter);
+    return SimulationResult(data, *converter);
 }
 
 void SpecularSimulation::setScan(const ISpecularScan& scan)
@@ -84,12 +107,12 @@ void SpecularSimulation::setScan(const ISpecularScan& scan)
     m_data_handler.reset(scan.clone());
 
     SpecularDetector1D detector(*scan.coordinateAxis());
-    m_instrument.setDetector(detector);
+    instrument().setDetector(detector);
 
     // TODO: remove when pointwise resolution is implemented
     if (scan.dataType() == ISpecularScan::angle) {
         const auto& angular_scan = static_cast<const AngularSpecScan&>(scan);
-        m_instrument.setBeamParameters(angular_scan.wavelength(), zero_alpha_i, zero_phi_i);
+        instrument().setBeamParameters(angular_scan.wavelength(), 0.0, 0.0);
     }
 }
 
@@ -113,7 +136,7 @@ size_t SpecularSimulation::intensityMapSize() const
 
 void SpecularSimulation::initSimulationElementVector()
 {
-    const auto& beam = m_instrument.getBeam();
+    const auto& beam = instrument().getBeam();
     m_sim_elements = generateSimulationElements(beam);
 
     if (!m_cache.empty())
@@ -138,7 +161,7 @@ SpecularSimulation::generateSimulationElements(const Beam& beam)
 
     // add polarization and analyzer operators
     const auto& polarization = beam.getPolarization();
-    const auto& analyzer = m_instrument.detector().detectionProperties().analyzerOperator();
+    const auto& analyzer = instrument().detector().detectionProperties().analyzerOperator();
 
     for (auto& elem : elements)
         elem.setPolarizationHandler({polarization, analyzer});
@@ -151,18 +174,10 @@ SpecularSimulation::generateSingleThreadedComputation(size_t start, size_t n_ele
 {
     ASSERT(start < m_sim_elements.size() && start + n_elements <= m_sim_elements.size());
     const auto& begin = m_sim_elements.begin() + static_cast<long>(start);
-    return std::make_unique<SpecularComputation>(*sample(), m_options, m_progress, begin,
+    return std::make_unique<SpecularComputation>(*sample(), options(), progress(), begin,
                                                  begin + static_cast<long>(n_elements));
 }
 
-SpecularSimulation::SpecularSimulation(const SpecularSimulation& other)
-    : Simulation(other),
-      m_data_handler(other.m_data_handler ? other.m_data_handler->clone() : nullptr),
-      m_sim_elements(other.m_sim_elements), m_cache(other.m_cache)
-{
-    initialize();
-}
-
 void SpecularSimulation::checkCache() const
 {
     if (m_sim_elements.size() != m_cache.size())
@@ -191,8 +206,10 @@ void SpecularSimulation::initialize()
 
     // allow for negative inclinations in the beam of specular simulation
     // it is required for proper averaging in the case of divergent beam
-    auto inclination = m_instrument.getBeam().parameter("InclinationAngle");
-    inclination->setLimits(RealLimits::limited(-M_PI_2, M_PI_2));
+    instrument()
+        .getBeam()
+        .parameter("InclinationAngle")
+        ->setLimits(RealLimits::limited(-M_PI_2, M_PI_2));
 }
 
 void SpecularSimulation::normalize(size_t start_ind, size_t n_elements)
@@ -204,7 +221,7 @@ void SpecularSimulation::normalize(size_t start_ind, size_t n_elements)
     std::vector<double> footprints;
     // TODO: use just m_data_handler when pointwise resolution is implemented
     if (m_data_handler->dataType() == ISpecularScan::angle)
-        footprints = mangledDataHandler(*m_data_handler, getInstrument().getBeam())
+        footprints = mangledDataHandler(*m_data_handler, instrument().getBeam())
                          ->footprint(start_ind, n_elements);
     else
         footprints = m_data_handler->footprint(start_ind, n_elements);
@@ -215,13 +232,13 @@ void SpecularSimulation::normalize(size_t start_ind, size_t n_elements)
     }
 }
 
-void SpecularSimulation::addBackGroundIntensity(size_t start_ind, size_t n_elements)
+void SpecularSimulation::addBackgroundIntensity(size_t start_ind, size_t n_elements)
 {
-    if (!mP_background)
+    if (!background())
         return;
     for (size_t i = start_ind, stop_point = start_ind + n_elements; i < stop_point; ++i) {
         auto& element = m_sim_elements[i];
-        element.setIntensity(mP_background->addBackGround(element.getIntensity()));
+        element.setIntensity(background()->addBackground(element.getIntensity()));
     }
 }
 
@@ -241,20 +258,6 @@ void SpecularSimulation::moveDataFromCache()
     m_cache.shrink_to_fit();
 }
 
-std::unique_ptr<OutputData<double>> SpecularSimulation::createIntensityData() const
-{
-    std::unique_ptr<OutputData<double>> result(new OutputData<double>);
-    result->addAxis(*coordinateAxis());
-
-    if (!m_sim_elements.empty()) {
-        std::vector<double> data = m_data_handler->createIntensities(m_sim_elements);
-        result->setRawDataVector(data);
-    } else
-        result->setAllTo(0.0);
-
-    return result;
-}
-
 std::vector<double> SpecularSimulation::rawResults() const
 {
     std::vector<double> result;
@@ -274,27 +277,3 @@ void SpecularSimulation::setRawResults(const std::vector<double>& raw_data)
         m_sim_elements[i].setIntensity(raw_data[i]);
     transferResultsToIntensityMap();
 }
-
-namespace
-{
-// TODO: remove when pointwise resolution is implemented
-std::unique_ptr<ISpecularScan> mangledDataHandler(const ISpecularScan& data_handler,
-                                                  const Beam& beam)
-{
-    if (data_handler.dataType() != ISpecularScan::angle)
-        throw std::runtime_error("Error in mangledDataHandler: invalid usage");
-    auto& scan = static_cast<const AngularSpecScan&>(data_handler);
-
-    const double wl = beam.getWavelength();
-    const double angle_shift = beam.getAlpha();
-    std::vector<double> angles = scan.coordinateAxis()->getBinCenters();
-    for (auto& val : angles)
-        val += angle_shift;
-    auto result =
-        std::make_unique<AngularSpecScan>(wl, PointwiseAxis("alpha_i", std::move(angles)));
-    result->setFootprintFactor(scan.footprintFactor());
-    result->setWavelengthResolution(*scan.wavelengthResolution());
-    result->setAngleResolution(*scan.angleResolution());
-    return std::unique_ptr<ISpecularScan>(result.release());
-}
-} // namespace
diff --git a/Core/Simulation/SpecularSimulation.h b/Core/Simulation/SpecularSimulation.h
index 5b797d799adec4881ecddd5a79ca7f6fdf68bcd6..53063674c0bdeaf39a78377780bbd7ac7e8585f7 100644
--- a/Core/Simulation/SpecularSimulation.h
+++ b/Core/Simulation/SpecularSimulation.h
@@ -16,7 +16,6 @@
 #define BORNAGAIN_CORE_SIMULATION_SPECULARSIMULATION_H
 
 #include "Core/Simulation/Simulation.h"
-#include "Sample/RT/ILayerRTCoefficients.h"
 
 class IAxis;
 class IComputation;
@@ -93,7 +92,7 @@ private:
     //! @param n_elements Number of elements to process
     void normalize(size_t start_ind, size_t n_elements) override;
 
-    void addBackGroundIntensity(size_t start_ind, size_t n_elements) override;
+    void addBackgroundIntensity(size_t start_ind, size_t n_elements) override;
 
     void addDataToCache(double weight) override;
 
@@ -102,9 +101,6 @@ private:
     //! Gets the number of elements this simulation needs to calculate
     size_t numberOfSimulationElements() const override;
 
-    //! Creates intensity data from simulation elements
-    std::unique_ptr<OutputData<double>> createIntensityData() const;
-
     std::vector<double> rawResults() const override;
     void setRawResults(const std::vector<double>& raw_data) override;
 
diff --git a/Core/Simulation/StandardSimulations.cpp b/Core/Simulation/StandardSimulations.cpp
index 6e91b0dcae0a9d53e1ece66ff4efb9da65f542f0..c0aa2374d1505f69c285492d58089256c57560a4 100644
--- a/Core/Simulation/StandardSimulations.cpp
+++ b/Core/Simulation/StandardSimulations.cpp
@@ -393,14 +393,14 @@ GISASSimulation* StandardSimulations::ConstantBackgroundGISAS()
 
 GISASSimulation* StandardSimulations::ExtraLongWavelengthGISAS()
 {
-    std::unique_ptr<GISASSimulation> simulation(new GISASSimulation());
+    auto* simulation = new GISASSimulation;
     simulation->setDetectorParameters(100, -1.0 * Units::deg, 1.0 * Units::deg, 100, 0.0,
                                       2.0 * Units::deg);
 
     simulation->setBeamParameters(13.52 * Units::nm, 0.2 * Units::deg, 0.0 * Units::deg);
     simulation->setBeamIntensity(1.0e+08);
     simulation->getOptions().setIncludeSpecular(true);
-    return simulation.release();
+    return simulation;
 }
 
 SpecularSimulation* StandardSimulations::BasicSpecular()
@@ -411,10 +411,10 @@ SpecularSimulation* StandardSimulations::BasicSpecular()
     const double max_angle = 5 * Units::deg;
     AngularSpecScan scan(wavelength, FixedBinAxis("axis", number_of_bins, min_angle, max_angle));
 
-    std::unique_ptr<SpecularSimulation> result(new SpecularSimulation());
+    auto* result = new SpecularSimulation();
     result->setScan(scan);
     result->getOptions().setUseAvgMaterials(true);
-    return result.release();
+    return result;
 }
 
 SpecularSimulation* StandardSimulations::BasicSpecularQ()
@@ -434,10 +434,10 @@ SpecularSimulation* StandardSimulations::BasicSpecularQ()
     }
     QSpecScan q_scan(qs);
 
-    std::unique_ptr<SpecularSimulation> result(new SpecularSimulation());
+    auto* result = new SpecularSimulation;
     result->setScan(q_scan);
     result->getOptions().setUseAvgMaterials(true);
-    return result.release();
+    return result;
 }
 
 SpecularSimulation* StandardSimulations::SpecularWithGaussianBeam()
@@ -450,9 +450,9 @@ SpecularSimulation* StandardSimulations::SpecularWithGaussianBeam()
     AngularSpecScan scan(wavelength, FixedBinAxis("axis", number_of_bins, min_angle, max_angle));
     scan.setFootprintFactor(gaussian_ff.get());
 
-    std::unique_ptr<SpecularSimulation> result(new SpecularSimulation());
+    auto* result = new SpecularSimulation;
     result->setScan(scan);
-    return result.release();
+    return result;
 }
 
 SpecularSimulation* StandardSimulations::SpecularWithSquareBeam()
@@ -465,9 +465,9 @@ SpecularSimulation* StandardSimulations::SpecularWithSquareBeam()
     AngularSpecScan scan(wavelength, FixedBinAxis("axis", number_of_bins, min_angle, max_angle));
     scan.setFootprintFactor(square_ff.get());
 
-    std::unique_ptr<SpecularSimulation> result(new SpecularSimulation());
+    auto* result = new SpecularSimulation;
     result->setScan(scan);
-    return result.release();
+    return result;
 }
 
 SpecularSimulation* StandardSimulations::SpecularDivergentBeam()
@@ -492,10 +492,9 @@ SpecularSimulation* StandardSimulations::SpecularDivergentBeam()
     scan.setWavelengthResolution(*wl_res);
     scan.setAngleResolution(*ang_res);
 
-    std::unique_ptr<SpecularSimulation> result(new SpecularSimulation());
+    auto* result = new SpecularSimulation;
     result->setScan(scan);
-
-    return result.release();
+    return result;
 }
 
 SpecularSimulation* StandardSimulations::TOFRWithRelativeResolution()
@@ -504,10 +503,10 @@ SpecularSimulation* StandardSimulations::TOFRWithRelativeResolution()
     QSpecScan q_scan(qs);
     q_scan.setRelativeQResolution(RangedDistributionGaussian(20, 2.0), 0.03);
 
-    std::unique_ptr<SpecularSimulation> result(new SpecularSimulation());
+    auto* result = new SpecularSimulation;
     result->setScan(q_scan);
     result->getOptions().setUseAvgMaterials(true);
-    return result.release();
+    return result;
 }
 
 SpecularSimulation* StandardSimulations::TOFRWithPointwiseResolution()
@@ -522,75 +521,75 @@ SpecularSimulation* StandardSimulations::TOFRWithPointwiseResolution()
                   [&resolutions](double q_val) { resolutions.push_back(0.03 * q_val); });
     q_scan.setAbsoluteQResolution(RangedDistributionGaussian(20, 2.0), resolutions);
 
-    std::unique_ptr<SpecularSimulation> result(new SpecularSimulation());
+    auto* result = new SpecularSimulation;
     result->setScan(q_scan);
     result->getOptions().setUseAvgMaterials(true);
-    return result.release();
+    return result;
 }
 
 // ------------ polarized specular ----------------
 SpecularSimulation* StandardSimulations::BasicSpecularPP()
 {
-    std::unique_ptr<SpecularSimulation> simulation(BasicSpecular());
+    auto* simulation = BasicSpecular();
     simulation->setBeamPolarization({0.0, 1.0, 0.0});
     simulation->setAnalyzerProperties({0.0, 1.0, 0.0}, 1.0, 0.5);
-    return simulation.release();
+    return simulation;
 }
 
 SpecularSimulation* StandardSimulations::BasicSpecularPM()
 {
-    std::unique_ptr<SpecularSimulation> simulation(BasicSpecular());
+    auto* simulation = BasicSpecular();
     simulation->setBeamPolarization({0.0, 1.0, 0.0});
     simulation->setAnalyzerProperties({0.0, -1.0, 0.0}, 1.0, 0.5);
-    return simulation.release();
+    return simulation;
 }
 
 SpecularSimulation* StandardSimulations::BasicSpecularMP()
 {
-    std::unique_ptr<SpecularSimulation> simulation(BasicSpecular());
+    auto* simulation = BasicSpecular();
     simulation->setBeamPolarization({0.0, -1.0, 0.0});
     simulation->setAnalyzerProperties({0.0, 1.0, 0.0}, 1.0, 0.5);
-    return simulation.release();
+    return simulation;
 }
 
 SpecularSimulation* StandardSimulations::BasicSpecularMM()
 {
-    std::unique_ptr<SpecularSimulation> simulation(BasicSpecular());
+    auto* simulation = BasicSpecular();
     simulation->setBeamPolarization({0.0, -1.0, 0.0});
     simulation->setAnalyzerProperties({0.0, -1.0, 0.0}, 1.0, 0.5);
-    return simulation.release();
+    return simulation;
 }
 
 SpecularSimulation* StandardSimulations::BasicSpecularQPP()
 {
-    std::unique_ptr<SpecularSimulation> simulation(BasicSpecularQ());
+    auto* simulation = BasicSpecularQ();
     simulation->setBeamPolarization({0.0, 1.0, 0.0});
     simulation->setAnalyzerProperties({0.0, 1.0, 0.0}, 1.0, 0.5);
-    return simulation.release();
+    return simulation;
 }
 
 SpecularSimulation* StandardSimulations::BasicSpecularQMM()
 {
-    std::unique_ptr<SpecularSimulation> simulation(BasicSpecularQ());
+    auto* simulation = BasicSpecularQ();
     simulation->setBeamPolarization({0.0, -1.0, 0.0});
     simulation->setAnalyzerProperties({0.0, -1.0, 0.0}, 1.0, 0.5);
-    return simulation.release();
+    return simulation;
 }
 
 SpecularSimulation* StandardSimulations::BasicSpecularQPM()
 {
-    std::unique_ptr<SpecularSimulation> simulation(BasicSpecularQ());
+    auto* simulation = BasicSpecularQ();
     simulation->setBeamPolarization({0.0, 1.0, 0.0});
     simulation->setAnalyzerProperties({0.0, -1.0, 0.0}, 1.0, 0.5);
-    return simulation.release();
+    return simulation;
 }
 
 SpecularSimulation* StandardSimulations::BasicSpecularQMP()
 {
-    std::unique_ptr<SpecularSimulation> simulation(BasicSpecularQ());
+    auto* simulation = BasicSpecularQ();
     simulation->setBeamPolarization({0.0, -1.0, 0.0});
     simulation->setAnalyzerProperties({0.0, 1.0, 0.0}, 1.0, 0.5);
-    return simulation.release();
+    return simulation;
 }
 
 // ----------------------- off-spec simulations ------------------
@@ -598,7 +597,7 @@ SpecularSimulation* StandardSimulations::BasicSpecularQMP()
 // OffSpec simulation used in ResonatorOffSpecSetup.py
 OffSpecSimulation* StandardSimulations::MiniOffSpec()
 {
-    std::unique_ptr<OffSpecSimulation> result(new OffSpecSimulation());
+    auto* result = new OffSpecSimulation;
 
     const int n_alpha(19);
     const double alpha_min(0.0 * Units::deg);
@@ -619,12 +618,12 @@ OffSpecSimulation* StandardSimulations::MiniOffSpec()
     result->setBeamIntensity(1e9);
     result->getOptions().setIncludeSpecular(true);
 
-    return result.release();
+    return result;
 }
 
 DepthProbeSimulation* StandardSimulations::BasicDepthProbe()
 {
-    auto result = std::make_unique<DepthProbeSimulation>();
+    auto* result = new DepthProbeSimulation;
 
     const double wavelength = 10.0 * Units::angstrom;
     const size_t n_alpha = 20;
@@ -637,14 +636,14 @@ DepthProbeSimulation* StandardSimulations::BasicDepthProbe()
     result->setBeamParameters(wavelength, n_alpha, alpha_min, alpha_max);
     result->setZSpan(n_z, z_min, z_max);
 
-    return result.release();
+    return result;
 }
 
 //! Simulation with fitting.
 //! Beam intensity set to provide reasonably large values in detector channels.
 GISASSimulation* StandardSimulations::MiniGISASFit()
 {
-    GISASSimulation* result = new GISASSimulation();
+    auto* result = new GISASSimulation;
     result->setDetectorParameters(25, -2.0 * Units::degree, 2.0 * Units::degree, 25,
                                   0.0 * Units::degree, 2.0 * Units::degree);
     result->setBeamParameters(1.0 * Units::angstrom, 0.2 * Units::degree, 0.0 * Units::degree);
diff --git a/Core/Simulation/UnitConverterUtils.cpp b/Core/Simulation/UnitConverterUtils.cpp
index fd5ef173f5036d587256ca0963946918d5245da3..207c605c700e32db1547849b93a1245fe6e7c432 100644
--- a/Core/Simulation/UnitConverterUtils.cpp
+++ b/Core/Simulation/UnitConverterUtils.cpp
@@ -48,7 +48,7 @@ UnitConverterUtils::createConverterForGISAS(const Instrument& instrument)
 std::unique_ptr<IUnitConverter> UnitConverterUtils::createConverter(const Simulation& simulation)
 {
     if (auto gisas = dynamic_cast<const GISASSimulation*>(&simulation)) {
-        return createConverterForGISAS(gisas->getInstrument());
+        return createConverterForGISAS(gisas->instrument());
 
     } else if (auto spec = dynamic_cast<const SpecularSimulation*>(&simulation)) {
         return UnitConverter1D::createUnitConverter(*spec->dataHandler());
diff --git a/Device/Detector/DetectorFunctions.cpp b/Device/Detector/DetectorFunctions.cpp
deleted file mode 100644
index 5b0ef50383fdac98d38b135316a2333ef9827caa..0000000000000000000000000000000000000000
--- a/Device/Detector/DetectorFunctions.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-// ************************************************************************** //
-//
-//  BornAgain: simulate and fit scattering at grazing incidence
-//
-//! @file      Device/Detector/DetectorFunctions.cpp
-//! @brief     Implements namespace DetectorFunctions.
-//!
-//! @homepage  http://www.bornagainproject.org
-//! @license   GNU General Public License v3 or higher (see COPYING)
-//! @copyright Forschungszentrum Jülich GmbH 2018
-//! @authors   Scientific Computing Group at MLZ (see CITATION, AUTHORS)
-//
-// ************************************************************************** //
-
-#include "Device/Detector/DetectorFunctions.h"
-#include "Device/Data/OutputData.h"
-#include "Device/Detector/SimulationArea.h"
-#include "Fit/Tools/StringUtils.h"
-#include <algorithm>
-#include <cctype>
-#include <map>
-#include <sstream>
-
-bool DetectorFunctions::hasSameDimensions(const IDetector& detector, const OutputData<double>& data)
-{
-    if (data.getRank() != detector.dimension())
-        return false;
-
-    for (size_t i = 0; i < detector.dimension(); ++i)
-        if (data.getAxis(i).size() != detector.getAxis(i).size())
-            return false;
-
-    return true;
-}
-
-std::string DetectorFunctions::axesToString(const IDetector& detector)
-{
-    std::ostringstream result;
-
-    result << "(";
-    for (size_t i = 0; i < detector.dimension(); ++i) {
-        result << detector.getAxis(i).size();
-        if (i != detector.dimension() - 1)
-            result << ",";
-    }
-    result << ")";
-
-    return result.str();
-}
-
-std::string DetectorFunctions::axesToString(const OutputData<double>& data)
-{
-    std::ostringstream result;
-
-    result << "(";
-    for (size_t i = 0; i < data.getRank(); ++i) {
-        result << data.getAxis(i).size();
-        if (i != data.getRank() - 1)
-            result << ",";
-    }
-    result << ")";
-
-    return result.str();
-}
diff --git a/Device/Detector/DetectorFunctions.h b/Device/Detector/DetectorFunctions.h
deleted file mode 100644
index cb35a0832415a9d178decb6d49cb310bb2e37e2b..0000000000000000000000000000000000000000
--- a/Device/Detector/DetectorFunctions.h
+++ /dev/null
@@ -1,47 +0,0 @@
-// ************************************************************************** //
-//
-//  BornAgain: simulate and fit scattering at grazing incidence
-//
-//! @file      Device/Detector/DetectorFunctions.h
-//! @brief     Defines namespace DetectorFunctions.
-//!
-//! @homepage  http://www.bornagainproject.org
-//! @license   GNU General Public License v3 or higher (see COPYING)
-//! @copyright Forschungszentrum Jülich GmbH 2018
-//! @authors   Scientific Computing Group at MLZ (see CITATION, AUTHORS)
-//
-// ************************************************************************** //
-
-#ifndef BORNAGAIN_CORE_DETECTOR_DETECTORFUNCTIONS_H
-#define BORNAGAIN_CORE_DETECTOR_DETECTORFUNCTIONS_H
-
-#include "Device/Detector/IDetector.h"
-#include <functional>
-#include <memory>
-#include <string>
-template <class T> class OutputData;
-class Instrument;
-class IDetector;
-class SimulationAreaIterator;
-
-//! Contains set of detector-related convenience functions.
-//! @ingroup detector
-
-namespace DetectorFunctions
-{
-
-//! Returns true if the data has same axes size (nx,ny) with the detector.
-bool hasSameDimensions(const IDetector& detector, const OutputData<double>& data);
-
-// TODO replace two functions below with the template function after change of
-// OutputData::getAxis signature
-
-//! Returns string representation of axes dimension in the form "(nx,ny)"
-std::string axesToString(const IDetector& detector);
-
-//! Returns string representation of axes dimension in the form "(nx,ny)"
-std::string axesToString(const OutputData<double>& data);
-
-} // namespace DetectorFunctions
-
-#endif // BORNAGAIN_CORE_DETECTOR_DETECTORFUNCTIONS_H
diff --git a/Device/Detector/IDetector2D.cpp b/Device/Detector/IDetector2D.cpp
index a457ee63cf5d6d4552213cf127a40d8104194531..a2b23d866f384d38919b858c10c13f549045cc0c 100644
--- a/Device/Detector/IDetector2D.cpp
+++ b/Device/Detector/IDetector2D.cpp
@@ -17,7 +17,6 @@
 #include "Base/Pixel/SimulationElement.h"
 #include "Device/Beam/Beam.h"
 #include "Device/Detector/DetectorContext.h"
-#include "Device/Detector/DetectorFunctions.h"
 #include "Device/Detector/RegionOfInterest.h"
 #include "Device/Detector/SimulationArea.h"
 #include "Device/Mask/InfinitePlane.h"
diff --git a/Device/Instrument/Instrument.cpp b/Device/Instrument/Instrument.cpp
index 35f65e3206bd96e0329714cdf0fddc40332defa4..4b957c112dfd1e446438baf1726b5331fa835491 100644
--- a/Device/Instrument/Instrument.cpp
+++ b/Device/Instrument/Instrument.cpp
@@ -13,22 +13,21 @@
 // ************************************************************************** //
 
 #include "Device/Instrument/Instrument.h"
-#include "Device/Detector/DetectorFunctions.h"
 #include "Device/Detector/SphericalDetector.h"
 #include "Device/Histo/Histogram2D.h"
 #include "Device/Resolution/IResolutionFunction2D.h"
 
-Instrument::Instrument() : mP_detector(new SphericalDetector), m_beam(Beam::horizontalBeam())
+Instrument::Instrument() : m_detector(new SphericalDetector), m_beam(Beam::horizontalBeam())
 {
     setName("Instrument");
-    registerChild(mP_detector.get());
+    registerChild(m_detector.get());
     registerChild(&m_beam);
 }
 
 Instrument::Instrument(const Instrument& other) : INode(), m_beam(other.m_beam)
 {
-    if (other.mP_detector)
-        setDetector(*other.mP_detector);
+    if (other.m_detector)
+        setDetector(*other.m_detector);
     registerChild(&m_beam);
     setName(other.getName());
 }
@@ -40,67 +39,67 @@ Instrument& Instrument::operator=(const Instrument& other)
     if (this != &other) {
         m_beam = other.m_beam;
         registerChild(&m_beam);
-        if (other.mP_detector)
-            setDetector(*other.mP_detector);
+        if (other.m_detector)
+            setDetector(*other.m_detector);
     }
     return *this;
 }
 
 void Instrument::setDetector(const IDetector& detector)
 {
-    mP_detector.reset(detector.clone());
-    registerChild(mP_detector.get());
+    m_detector.reset(detector.clone());
+    registerChild(m_detector.get());
     initDetector();
 }
 
 void Instrument::initDetector()
 {
-    if (!mP_detector)
+    if (!m_detector)
         throw Exceptions::RuntimeErrorException(
             "Instrument::initDetector() -> Error. Detector is not initialized.");
-    mP_detector->init(getBeam());
+    m_detector->init(getBeam());
 }
 
 std::vector<const INode*> Instrument::getChildren() const
 {
     std::vector<const INode*> result;
     result.push_back(&m_beam);
-    if (mP_detector)
-        result.push_back(mP_detector.get());
+    if (m_detector)
+        result.push_back(m_detector.get());
     return result;
 }
 
 void Instrument::setDetectorResolutionFunction(const IResolutionFunction2D& p_resolution_function)
 {
-    mP_detector->setResolutionFunction(p_resolution_function);
+    m_detector->setResolutionFunction(p_resolution_function);
 }
 
 void Instrument::removeDetectorResolution()
 {
-    mP_detector->removeDetectorResolution();
+    m_detector->removeDetectorResolution();
 }
 
 void Instrument::applyDetectorResolution(OutputData<double>* p_intensity_map) const
 {
-    mP_detector->applyDetectorResolution(p_intensity_map);
+    m_detector->applyDetectorResolution(p_intensity_map);
 }
 
 void Instrument::setBeamParameters(double wavelength, double alpha_i, double phi_i)
 {
     m_beam.setCentralK(wavelength, alpha_i, phi_i);
-    if (mP_detector)
+    if (m_detector)
         initDetector();
 }
 
 const DetectorMask* Instrument::getDetectorMask() const
 {
-    return mP_detector->detectorMask();
+    return m_detector->detectorMask();
 }
 
 void Instrument::setBeam(const Beam& beam)
 {
     m_beam = beam;
-    if (mP_detector)
+    if (m_detector)
         initDetector();
 }
 
@@ -121,26 +120,26 @@ double Instrument::getBeamIntensity() const
 
 const IDetector* Instrument::getDetector() const
 {
-    ASSERT(mP_detector);
-    return mP_detector.get();
+    ASSERT(m_detector);
+    return m_detector.get();
 }
 
 const IDetector& Instrument::detector() const
 {
-    ASSERT(mP_detector);
-    return *mP_detector;
+    ASSERT(m_detector);
+    return *m_detector;
 }
 
 IDetector& Instrument::detector()
 {
-    ASSERT(mP_detector);
-    return *mP_detector;
+    ASSERT(m_detector);
+    return *m_detector;
 }
 
 IDetector2D& Instrument::detector2D()
 {
-    ASSERT(mP_detector);
-    IDetector2D* p = dynamic_cast<IDetector2D*>(mP_detector.get());
+    ASSERT(m_detector);
+    IDetector2D* p = dynamic_cast<IDetector2D*>(m_detector.get());
     if (!p)
         throw std::runtime_error("Error: Detector is not twodimensional");
     return *p;
@@ -148,8 +147,8 @@ IDetector2D& Instrument::detector2D()
 
 const IDetector2D& Instrument::detector2D() const
 {
-    ASSERT(mP_detector);
-    IDetector2D* const p = dynamic_cast<IDetector2D* const>(mP_detector.get());
+    ASSERT(m_detector);
+    IDetector2D* const p = dynamic_cast<IDetector2D* const>(m_detector.get());
     if (!p)
         throw std::runtime_error("Error: Detector is not twodimensional");
     return *p;
@@ -157,16 +156,16 @@ const IDetector2D& Instrument::detector2D() const
 
 const IAxis& Instrument::getDetectorAxis(size_t index) const
 {
-    return mP_detector->getAxis(index);
+    return m_detector->getAxis(index);
 }
 
 size_t Instrument::getDetectorDimension() const
 {
-    return mP_detector->dimension();
+    return m_detector->dimension();
 }
 
 void Instrument::setAnalyzerProperties(const kvector_t direction, double efficiency,
                                        double total_transmission)
 {
-    mP_detector->setAnalyzerProperties(direction, efficiency, total_transmission);
+    m_detector->setAnalyzerProperties(direction, efficiency, total_transmission);
 }
diff --git a/Device/Instrument/Instrument.h b/Device/Instrument/Instrument.h
index d9d347ab7b4a2a710c0ce3e680440d0875fa5e1b..0fa54a173228c454b667545442c2b554f705d894 100644
--- a/Device/Instrument/Instrument.h
+++ b/Device/Instrument/Instrument.h
@@ -16,13 +16,13 @@
 #define BORNAGAIN_CORE_INSTRUMENT_INSTRUMENT_H
 
 #include "Device/Beam/Beam.h"
-#include "Device/Detector/IDetector.h"
 #include <memory>
 
 template <class T> class OutputData;
 class Histogram2D;
 class DetectorMask;
 class IAxis;
+class IDetector;
 class IDetector2D;
 class IResolutionFunction2D;
 class SimulationElement;
@@ -90,7 +90,7 @@ public:
     std::vector<const INode*> getChildren() const;
 
 protected:
-    std::unique_ptr<IDetector> mP_detector;
+    std::unique_ptr<IDetector> m_detector;
     Beam m_beam;
 };
 
diff --git a/Device/Scan/AngularSpecScan.cpp b/Device/Scan/AngularSpecScan.cpp
index 8db0eae38ee29bc5780b64e3012515d870296e8e..4ba8edd111d416b2b8e0ce138c706b6d1a85f0cf 100644
--- a/Device/Scan/AngularSpecScan.cpp
+++ b/Device/Scan/AngularSpecScan.cpp
@@ -25,10 +25,22 @@ namespace
 {
 std::vector<std::vector<double>>
 extractValues(std::vector<std::vector<ParameterSample>> samples,
-              const std::function<double(const ParameterSample&)> extractor);
+              const std::function<double(const ParameterSample&)> extractor)
+{
+    std::vector<std::vector<double>> result;
+    result.resize(samples.size());
+    for (size_t i = 0, size = result.size(); i < size; ++i) {
+        const auto& sample_row = samples[i];
+        auto& result_row = result[i];
+        result_row.reserve(sample_row.size());
+        std::for_each(sample_row.begin(), sample_row.end(),
+                      [&result_row, &extractor](const ParameterSample& sample) {
+                          result_row.push_back(extractor(sample));
+                      });
+    }
+    return result;
+}
 
-const RealLimits wl_limits = RealLimits::nonnegative();
-const RealLimits inc_limits = RealLimits::limited(0.0, M_PI_2);
 } // namespace
 
 AngularSpecScan::AngularSpecScan(double wl, std::vector<double> inc_angle)
@@ -59,11 +71,11 @@ AngularSpecScan::AngularSpecScan(double wl, int nbins, double alpha_i_min, doubl
 
 AngularSpecScan* AngularSpecScan::clone() const
 {
-    auto result = std::make_unique<AngularSpecScan>(m_wl, *m_inc_angle);
+    auto* result = new AngularSpecScan(m_wl, *m_inc_angle);
     result->setFootprintFactor(m_footprint.get());
     result->setWavelengthResolution(*m_wl_resolution);
     result->setAngleResolution(*m_inc_resolution);
-    return result.release();
+    return result;
 }
 
 AngularSpecScan::~AngularSpecScan() = default;
@@ -79,7 +91,7 @@ std::vector<SpecularSimulationElement> AngularSpecScan::generateSimulationElemen
         const double wl = paired_values[i].first;
         const double inc = paired_values[i].second;
         result.emplace_back(wl, -inc);
-        if (!wl_limits.isInRange(wl) || !inc_limits.isInRange(inc))
+        if (wl < 0 || inc < 0 || inc > M_PI_2)
             result.back().setCalculationFlag(false); // false = exclude from calculations
     }
 
@@ -183,7 +195,7 @@ std::vector<double> AngularSpecScan::footprint(size_t start, size_t n_elements)
     const auto sample_values = extractValues(
         applyIncResolution(), [](const ParameterSample& sample) { return sample.value; });
 
-    size_t pos_out = start / (n_wl_samples * n_inc_samples);
+    const size_t pos_out = start / (n_wl_samples * n_inc_samples);
     size_t pos_inc = (start - pos_out * n_wl_samples * n_inc_samples) / n_wl_samples;
     size_t pos_wl = (start - pos_inc * n_wl_samples);
     int left = static_cast<int>(n_elements);
@@ -191,8 +203,9 @@ std::vector<double> AngularSpecScan::footprint(size_t start, size_t n_elements)
     for (size_t i = pos_out; left > 0; ++i)
         for (size_t k = pos_inc; k < n_inc_samples && left > 0; ++k) {
             pos_inc = 0;
-            double angle = sample_values[i][k];
-            double footprint = inc_limits.isInRange(angle) ? m_footprint->calculate(angle) : 1.0;
+            const double angle = sample_values[i][k];
+            const double footprint =
+                (angle >= 0 && angle <= M_PI_2) ? m_footprint->calculate(angle) : 1.0;
             for (size_t j = pos_wl; j < n_wl_samples && left > 0; ++j) {
                 pos_wl = 0;
                 result[pos_res] = footprint;
@@ -214,10 +227,10 @@ AngularSpecScan::createIntensities(const std::vector<SpecularSimulationElement>&
     const size_t axis_size = m_inc_angle->size();
     std::vector<double> result(axis_size, 0.0);
 
-    auto wl_weights = extractValues(applyWlResolution(),
-                                    [](const ParameterSample& sample) { return sample.weight; });
-    auto inc_weights = extractValues(applyIncResolution(),
-                                     [](const ParameterSample& sample) { return sample.weight; });
+    const auto wl_weights = extractValues(
+        applyWlResolution(), [](const ParameterSample& sample) { return sample.weight; });
+    const auto inc_weights = extractValues(
+        applyIncResolution(), [](const ParameterSample& sample) { return sample.weight; });
 
     size_t elem_pos = 0;
     for (size_t i = 0; i < axis_size; ++i) {
@@ -266,7 +279,7 @@ void AngularSpecScan::checkInitialization()
         throw std::runtime_error(
             "Error in AngularSpecScan::checkInitialization: wavelength shell be positive");
 
-    std::vector<double> axis_values = m_inc_angle->getBinCenters();
+    const std::vector<double> axis_values = m_inc_angle->getBinCenters();
     if (!std::is_sorted(axis_values.begin(), axis_values.end()))
         throw std::runtime_error("Error in AngularSpecScan::checkInitialization: q-vector values "
                                  "shall be sorted in ascending order.");
@@ -306,24 +319,3 @@ AngularSpecScan::DistrOutput AngularSpecScan::applyIncResolution() const
         m_inc_res_cache = m_inc_resolution->generateSamples(m_inc_angle->getBinCenters());
     return m_inc_res_cache;
 }
-
-namespace
-{
-std::vector<std::vector<double>>
-extractValues(std::vector<std::vector<ParameterSample>> samples,
-              const std::function<double(const ParameterSample&)> extractor)
-{
-    std::vector<std::vector<double>> result;
-    result.resize(samples.size());
-    for (size_t i = 0, size = result.size(); i < size; ++i) {
-        auto& sample_row = samples[i];
-        auto& result_row = result[i];
-        result_row.reserve(sample_row.size());
-        std::for_each(sample_row.begin(), sample_row.end(),
-                      [&result_row, &extractor](const ParameterSample& sample) {
-                          result_row.push_back(extractor(sample));
-                      });
-    }
-    return result;
-}
-} // namespace
diff --git a/Device/Scan/AngularSpecScan.h b/Device/Scan/AngularSpecScan.h
index a814c081342dbb52261ed220655f8c5d95f9360c..42f0abd6edfe5ba48ee73789980611c780998a96 100644
--- a/Device/Scan/AngularSpecScan.h
+++ b/Device/Scan/AngularSpecScan.h
@@ -22,8 +22,8 @@ class ParameterSample;
 class RangedDistribution;
 class ScanResolution;
 
-//! Scan type with inclination angles as coordinate
-//! values and a unique wavelength. Features footprint correction.
+//! Scan type with inclination angles as coordinate values and a unique wavelength.
+//! Features footprint correction.
 class AngularSpecScan : public ISpecularScan
 {
 public:
diff --git a/Device/Scan/QSpecScan.cpp b/Device/Scan/QSpecScan.cpp
index f1a1d5e4a23b39a09d6eafc57ab3fb4ad5e8b44b..71c2c8574a522af0cb1c9039b861c0c0bc9e9162 100644
--- a/Device/Scan/QSpecScan.cpp
+++ b/Device/Scan/QSpecScan.cpp
@@ -20,11 +20,6 @@
 #include "Param/Distrib/RangedDistributions.h"
 #include "Sample/Slice/SpecularSimulationElement.h"
 
-namespace
-{
-const RealLimits qz_limits = RealLimits::nonnegative();
-}
-
 QSpecScan::QSpecScan(std::vector<double> qs_nm)
     : ISpecularScan(SPECULAR_DATA_TYPE::q),
       m_qs(std::make_unique<PointwiseAxis>("qs", std::move(qs_nm))),
@@ -52,21 +47,21 @@ QSpecScan::~QSpecScan() = default;
 
 QSpecScan* QSpecScan::clone() const
 {
-    auto result = std::make_unique<QSpecScan>(*m_qs);
+    auto* result = new QSpecScan(*m_qs);
     result->setQResolution(*m_resolution);
-    return result.release();
+    return result;
 }
 
 //! Generates simulation elements for specular simulations
 std::vector<SpecularSimulationElement> QSpecScan::generateSimulationElements() const
 {
     std::vector<SpecularSimulationElement> result;
-    std::vector<double> qz = generateQzVector();
+    const std::vector<double> qz = generateQzVector();
 
     result.reserve(qz.size());
     for (size_t i = 0, size = qz.size(); i < size; ++i) {
         result.emplace_back(-qz[i] / 2.0);
-        if (!qz_limits.isInRange(qz[i]))
+        if (qz[i] < 0)
             result.back().setCalculationFlag(false); // false = exclude from calculations
     }
 
@@ -93,7 +88,7 @@ QSpecScan::createIntensities(const std::vector<SpecularSimulationElement>& sim_e
     const size_t axis_size = m_qs->size();
     std::vector<double> result(axis_size, 0.0);
 
-    auto samples = applyQResolution();
+    const auto samples = applyQResolution();
 
     size_t elem_pos = 0;
     for (size_t i = 0; i < axis_size; ++i) {
@@ -165,14 +160,14 @@ void QSpecScan::checkInitialization()
         throw std::runtime_error("Error in QSpecScan::checkInitialization: q-vector values shall "
                                  "be sorted in ascending order.");
 
-    if (!qz_limits.isInRange(axis_values.front()))
+    if (axis_values.front() < 0)
         throw std::runtime_error("Error in QSpecScan::checkInitialization: q-vector values are out "
                                  "of acceptable range.");
 }
 
 std::vector<double> QSpecScan::generateQzVector() const
 {
-    auto samples = applyQResolution();
+    const auto samples = applyQResolution();
 
     std::vector<double> result;
     result.reserve(numberOfSimulationElements());
diff --git a/Device/Scan/QSpecScan.h b/Device/Scan/QSpecScan.h
index eb4f3423857d42a6ba628560efc998d3f666463e..c22fc36e5cbb9e005c1a14a2ceb4f85ce165d57c 100644
--- a/Device/Scan/QSpecScan.h
+++ b/Device/Scan/QSpecScan.h
@@ -22,9 +22,8 @@ class ParameterSample;
 class RangedDistribution;
 class ScanResolution;
 
-//! Scan type with z-components of scattering vector
-//! as coordinate values. Wavelength and incident angles
-//! are not accessible separately.
+//! Scan type with z-components of scattering vector as coordinate values.
+//! Wavelength and incident angles are not accessible separately.
 
 class QSpecScan : public ISpecularScan
 {
diff --git a/GUI/coregui/Models/GUIObjectBuilder.cpp b/GUI/coregui/Models/GUIObjectBuilder.cpp
index 4e8bd0bf33630092809a745d68a28c22cee07e58..116398e94ba45b936f26db629bd60c595eca0cc4 100644
--- a/GUI/coregui/Models/GUIObjectBuilder.cpp
+++ b/GUI/coregui/Models/GUIObjectBuilder.cpp
@@ -68,7 +68,7 @@ SessionItem* GUIObjectBuilder::populateInstrumentModel(InstrumentModel* p_instru
     ASSERT(p_instrument_model);
 
     QString name = instrument_name.isEmpty()
-                       ? QString::fromStdString(simulation.getInstrument().getName())
+                       ? QString::fromStdString(simulation.instrument().getName())
                        : instrument_name;
 
     if (auto gisasSimulation = dynamic_cast<const GISASSimulation*>(&simulation)) {
diff --git a/GUI/coregui/Models/JobModelFunctions.cpp b/GUI/coregui/Models/JobModelFunctions.cpp
index 6991fcb36740947214ce79e08941d094cfc8e7ac..d67f9d1e78a068536a80b0b39abd5bb84181429c 100644
--- a/GUI/coregui/Models/JobModelFunctions.cpp
+++ b/GUI/coregui/Models/JobModelFunctions.cpp
@@ -13,7 +13,6 @@
 // ************************************************************************** //
 
 #include "GUI/coregui/Models/JobModelFunctions.h"
-#include "Device/Detector/DetectorFunctions.h"
 #include "Device/Detector/IDetector2D.h"
 #include "Device/Instrument/Instrument.h"
 #include "GUI/coregui/Models/Data1DViewItem.h"
diff --git a/GUI/coregui/Models/TransformFromDomain.cpp b/GUI/coregui/Models/TransformFromDomain.cpp
index 9005bd3322598ffe49d0ae58eb53a65052289821..6497c5b2bb980938256f18e554cd2fc8e1c21899 100644
--- a/GUI/coregui/Models/TransformFromDomain.cpp
+++ b/GUI/coregui/Models/TransformFromDomain.cpp
@@ -59,8 +59,8 @@
 #include "Param/Varia/ParameterPattern.h"
 #include "Sample/Aggregate/InterferenceFunctions.h"
 #include "Sample/Multilayer/Layer.h"
-#include "Sample/Slice/LayerInterface.h"
 #include "Sample/Particle/Particle.h"
+#include "Sample/Slice/LayerInterface.h"
 #include "Sample/Slice/LayerRoughness.h"
 
 using namespace INodeUtils;
@@ -240,7 +240,7 @@ bool TransformFromDomain::isValidRoughness(const LayerRoughness* roughness)
 void TransformFromDomain::setGISASBeamItem(BeamItem* beam_item, const GISASSimulation& simulation)
 {
     ASSERT(beam_item);
-    Beam beam = simulation.getInstrument().getBeam();
+    Beam beam = simulation.instrument().getBeam();
 
     beam_item->setIntensity(beam.getIntensity());
     beam_item->setWavelength(beam.getWavelength());
@@ -266,7 +266,7 @@ void TransformFromDomain::setGISASBeamItem(BeamItem* beam_item, const GISASSimul
 void TransformFromDomain::setOffSpecBeamItem(BeamItem* beam_item,
                                              const OffSpecSimulation& simulation)
 {
-    Beam beam = simulation.getInstrument().getBeam();
+    Beam beam = simulation.instrument().getBeam();
 
     beam_item->setIntensity(beam.getIntensity());
     beam_item->setWavelength(beam.getWavelength());
@@ -278,7 +278,7 @@ void TransformFromDomain::setOffSpecBeamItem(BeamItem* beam_item,
 void TransformFromDomain::setSpecularBeamItem(SpecularBeamItem* beam_item,
                                               const SpecularSimulation& simulation)
 {
-    const Beam& beam = simulation.getInstrument().getBeam();
+    const Beam& beam = simulation.instrument().getBeam();
 
     beam_item->setIntensity(beam.getIntensity());
     beam_item->setWavelength(beam.getWavelength());
@@ -313,7 +313,7 @@ void TransformFromDomain::setSpecularBeamItem(SpecularBeamItem* beam_item,
 void TransformFromDomain::setDetector(Instrument2DItem* instrument_item,
                                       const Simulation2D& simulation)
 {
-    const IDetector* p_detector = simulation.getInstrument().getDetector();
+    const IDetector* p_detector = simulation.instrument().getDetector();
     setDetectorGeometry(instrument_item, *p_detector);
 
     auto detector_item = instrument_item->detectorItem();
@@ -474,7 +474,7 @@ void TransformFromDomain::setRectangularDetector(RectangularDetectorItem* detect
 void TransformFromDomain::setDetectorMasks(DetectorItem* detector_item,
                                            const Simulation& simulation)
 {
-    const IDetector* detector = simulation.getInstrument().getDetector();
+    const IDetector* detector = simulation.instrument().getDetector();
     if ((detector->detectorMask() && detector->detectorMask()->numberOfMasks())
         || detector->regionOfInterest()) {
         detector_item->createMaskContainer();
diff --git a/GUI/coregui/Views/ImportDataWidgets/LinkInstrumentManager.cpp b/GUI/coregui/Views/ImportDataWidgets/LinkInstrumentManager.cpp
index 4283126283b5339ecaa1052b9d57f143abeba9cd..40c3c97026e360c7c67b82121cd75f0b77a4ba26 100644
--- a/GUI/coregui/Views/ImportDataWidgets/LinkInstrumentManager.cpp
+++ b/GUI/coregui/Views/ImportDataWidgets/LinkInstrumentManager.cpp
@@ -55,7 +55,7 @@ void LinkInstrumentManager::setModels(InstrumentModel* instrumentModel,
 
 //! Returns InstrumentItem for given identifier.
 
-InstrumentItem* LinkInstrumentManager::getInstrument(const QString& identifier)
+InstrumentItem* LinkInstrumentManager::instrument(const QString& identifier)
 {
     for (int i = 0; i < m_instrumentVec.size(); ++i)
         if (m_instrumentVec[i].m_identifier == identifier)
@@ -99,7 +99,7 @@ QString LinkInstrumentManager::instrumentIdentifier(int comboIndex)
 bool LinkInstrumentManager::canLinkDataToInstrument(const RealDataItem* realDataItem,
                                                     const QString& identifier)
 {
-    auto instrumentItem = getInstrument(identifier);
+    auto instrumentItem = instrument(identifier);
 
     // linking to null instrument is possible, it means unlinking from currently linked
     if (!instrumentItem)
@@ -143,7 +143,7 @@ void LinkInstrumentManager::setOnRealDataPropertyChange(SessionItem* dataItem,
     if (property == RealDataItem::P_INSTRUMENT_ID) {
         RealDataItem* realDataItem = dynamic_cast<RealDataItem*>(dataItem);
         QString identifier = dataItem->getItemValue(RealDataItem::P_INSTRUMENT_ID).toString();
-        realDataItem->linkToInstrument(getInstrument(identifier));
+        realDataItem->linkToInstrument(instrument(identifier));
     }
 }
 
@@ -187,7 +187,7 @@ void LinkInstrumentManager::updateLinks()
 {
     for (auto realDataItem : m_realDataModel->topItems<RealDataItem>()) {
         QString identifier = realDataItem->getItemValue(RealDataItem::P_INSTRUMENT_ID).toString();
-        auto instrumentItem = getInstrument(identifier);
+        auto instrumentItem = instrument(identifier);
 
         if (!instrumentItem) {
             // if no instrument with P_INSTRUMENT_ID exists, break the link
diff --git a/GUI/coregui/Views/ImportDataWidgets/LinkInstrumentManager.h b/GUI/coregui/Views/ImportDataWidgets/LinkInstrumentManager.h
index e8e7ab41bb7b7140ce69bbb8d51de55d74a17a33..0c2e8ceb7c853776662b52bcd046bb649b66bab4 100644
--- a/GUI/coregui/Views/ImportDataWidgets/LinkInstrumentManager.h
+++ b/GUI/coregui/Views/ImportDataWidgets/LinkInstrumentManager.h
@@ -49,7 +49,7 @@ public:
 
     void setModels(InstrumentModel* instrumentModel, RealDataModel* realDataModel);
 
-    InstrumentItem* getInstrument(const QString& identifier);
+    InstrumentItem* instrument(const QString& identifier);
     QStringList instrumentNames() const;
     int instrumentComboIndex(const QString& identifier);
     QString instrumentIdentifier(int comboIndex);
diff --git a/Param/Base/IParameterized.cpp b/Param/Base/IParameterized.cpp
index 8f51f8c76d71e25dcee69b38c1dff7bfdc858d27..80fcbf961e9b64ba26f5ecfd8b39c2616dbe1829 100644
--- a/Param/Base/IParameterized.cpp
+++ b/Param/Base/IParameterized.cpp
@@ -32,9 +32,9 @@ IParameterized::~IParameterized() = default;
 
 ParameterPool* IParameterized::createParameterTree() const
 {
-    std::unique_ptr<ParameterPool> result(new ParameterPool);
-    m_pool->copyToExternalPool("/" + getName() + "/", result.get());
-    return result.release();
+    auto* result = new ParameterPool;
+    m_pool->copyToExternalPool("/" + getName() + "/", result);
+    return result;
 }
 
 std::string IParameterized::parametersToString() const
diff --git a/Param/Node/INode.cpp b/Param/Node/INode.cpp
index e4841468c6031fe4fe4925719dc6987b186b3285..57f6aa49436d888a6f5746bc96357e48054271a2 100644
--- a/Param/Node/INode.cpp
+++ b/Param/Node/INode.cpp
@@ -13,9 +13,9 @@
 // ************************************************************************** //
 
 #include "Base/Utils/Algorithms.h"
-#include "Param/Base/IterationStrategy.h"
 #include "Param/Base/ParameterPool.h"
 #include "Param/Base/RealParameter.h"
+#include "Param/Node/IterationStrategy.h"
 #include "Param/Node/NodeIterator.h"
 #include "Param/Node/NodeUtils.h"
 #include <algorithm>
diff --git a/Param/Node/INodeVisitor.cpp b/Param/Node/INodeVisitor.cpp
index 110d528178e10551c6c415fe9fb6e0ba7d57de44..a4149896f17f12332a1c6d0d18dba89021cb20c5 100644
--- a/Param/Node/INodeVisitor.cpp
+++ b/Param/Node/INodeVisitor.cpp
@@ -12,7 +12,7 @@
 //
 // ************************************************************************** //
 
-#include "Param/Base/IterationStrategy.h"
+#include "Param/Node/IterationStrategy.h"
 #include "Param/Node/NodeIterator.h"
 
 void VisitNodesPreorder(const INode& node, INodeVisitor& visitor)
diff --git a/Param/Base/IterationStrategy.cpp b/Param/Node/IterationStrategy.cpp
similarity index 96%
rename from Param/Base/IterationStrategy.cpp
rename to Param/Node/IterationStrategy.cpp
index 502aa4c21f16b7adaa8ba53ec8d6b34cf1319f68..12aceb9a3fe61fd79bb05c2abeeb5aeef9404372 100644
--- a/Param/Base/IterationStrategy.cpp
+++ b/Param/Node/IterationStrategy.cpp
@@ -2,7 +2,7 @@
 //
 //  BornAgain: simulate and fit scattering at grazing incidence
 //
-//! @file      Param/Base/IterationStrategy.cpp
+//! @file      Param/Node/IterationStrategy.cpp
 //! @brief     Implements class IterationStrategy and children.
 //!
 //! @homepage  http://www.bornagainproject.org
@@ -12,7 +12,7 @@
 //
 // ************************************************************************** //
 
-#include "Param/Base/IterationStrategy.h"
+#include "Param/Node/IterationStrategy.h"
 #include "Base/Utils/Assert.h"
 #include "Param/Node/NodeIterator.h"
 
diff --git a/Param/Base/IterationStrategy.h b/Param/Node/IterationStrategy.h
similarity index 97%
rename from Param/Base/IterationStrategy.h
rename to Param/Node/IterationStrategy.h
index fb224f3edee50aaf8e9c73cea68e23cddcffbb14..eb3d0d4561e28293bcd2162dcc918adf136a3578 100644
--- a/Param/Base/IterationStrategy.h
+++ b/Param/Node/IterationStrategy.h
@@ -2,7 +2,7 @@
 //
 //  BornAgain: simulate and fit scattering at grazing incidence
 //
-//! @file      Param/Base/IterationStrategy.h
+//! @file      Param/Node/IterationStrategy.h
 //! @brief     Defines class IterationStrategy and children.
 //!
 //! @homepage  http://www.bornagainproject.org
diff --git a/Param/Node/NodeUtils.cpp b/Param/Node/NodeUtils.cpp
index 31904bf3e3c68ce9d17f6ac9bb99defbb4e28be2..2d6de97820b780c24d6e9a750479b372899c0353 100644
--- a/Param/Node/NodeUtils.cpp
+++ b/Param/Node/NodeUtils.cpp
@@ -14,9 +14,9 @@
 
 #include "Param/Node/NodeUtils.h"
 #include "Base/Types/Exceptions.h"
-#include "Param/Base/IterationStrategy.h"
 #include "Param/Base/ParameterPool.h"
 #include "Param/Base/RealParameter.h"
+#include "Param/Node/IterationStrategy.h"
 #include "Param/Node/NodeIterator.h"
 #include <algorithm>
 #include <functional>
diff --git a/Sample/Aggregate/ParticleLayout.cpp b/Sample/Aggregate/ParticleLayout.cpp
index f1dad10b23c4da83e41def2a049d3c91403068ad..223042dd7aeea0552c8d586a9fda7c1dce7f17fa 100644
--- a/Sample/Aggregate/ParticleLayout.cpp
+++ b/Sample/Aggregate/ParticleLayout.cpp
@@ -76,14 +76,14 @@ ParticleLayout* ParticleLayout::clone() const
 void ParticleLayout::addParticle(const IAbstractParticle& particle, double abundance,
                                  const kvector_t position, const IRotation& rotation)
 {
-    std::unique_ptr<IAbstractParticle> P_particle_clone{particle.clone()};
+    IAbstractParticle* particle_clone = particle.clone();
     if (abundance >= 0.0)
-        P_particle_clone->setAbundance(abundance);
+        particle_clone->setAbundance(abundance);
     if (!rotation.isIdentity())
-        P_particle_clone->rotate(rotation);
+        particle_clone->rotate(rotation);
     if (position != kvector_t(0, 0, 0))
-        P_particle_clone->translate(position);
-    addAndRegisterAbstractParticle(P_particle_clone.release());
+        particle_clone->translate(position);
+    addAndRegisterAbstractParticle(particle_clone);
 }
 
 //! Returns information on all particles (type and abundance)
diff --git a/Sample/Lattice/ILatticeOrientation.cpp b/Sample/Lattice/ILatticeOrientation.cpp
index 5f463f2684882c85fde3c6b9f9d5c20be679b8f7..db239c6a3dd97495eb7a9a3c2fe87d73ce442bd4 100644
--- a/Sample/Lattice/ILatticeOrientation.cpp
+++ b/Sample/Lattice/ILatticeOrientation.cpp
@@ -43,9 +43,9 @@ MillerIndexOrientation::MillerIndexOrientation(MillerIndexOrientation::QComponen
 
 MillerIndexOrientation* MillerIndexOrientation::clone() const
 {
-    auto P_result = std::make_unique<MillerIndexOrientation>(m_q1, m_ind1, m_q2, m_ind2);
-    P_result->usePrimitiveLattice(m_prim_lattice);
-    return P_result.release();
+    auto* result = new MillerIndexOrientation(m_q1, m_ind1, m_q2, m_ind2);
+    result->usePrimitiveLattice(m_prim_lattice);
+    return result;
 }
 
 MillerIndexOrientation::~MillerIndexOrientation() = default;
diff --git a/Sample/Material/MagneticMaterialImpl.cpp b/Sample/Material/MagneticMaterialImpl.cpp
index 648ef9de7f528dde8156499ec73ac6c8fbc8e15e..7ea2ce555e718ecfdb6a2fcb3bc76f15c5f7ef50 100644
--- a/Sample/Material/MagneticMaterialImpl.cpp
+++ b/Sample/Material/MagneticMaterialImpl.cpp
@@ -44,9 +44,9 @@ MagneticMaterialImpl::MagneticMaterialImpl(const std::string& name, kvector_t ma
 MagneticMaterialImpl* MagneticMaterialImpl::inverted() const
 {
     std::string name = isScalarMaterial() ? getName() : getName() + "_inv";
-    std::unique_ptr<MagneticMaterialImpl> result(this->clone());
+    MagneticMaterialImpl* result = this->clone();
     result->setMagnetization(-magnetization());
-    return result.release();
+    return result;
 }
 
 bool MagneticMaterialImpl::isScalarMaterial() const
@@ -74,7 +74,7 @@ Eigen::Matrix2cd MagneticMaterialImpl::polarizedSubtrSLD(const WavevectorInfo& w
 MagneticMaterialImpl* MagneticMaterialImpl::rotatedMaterial(const Transform3D& transform) const
 {
     kvector_t transformed_field = transform.transformed(m_magnetization);
-    std::unique_ptr<MagneticMaterialImpl> result(this->clone());
+    MagneticMaterialImpl* result = this->clone();
     result->setMagnetization(transformed_field);
-    return result.release();
+    return result;
 }
diff --git a/Sample/Multilayer/MultiLayer.cpp b/Sample/Multilayer/MultiLayer.cpp
index da362d063347ef2e6fae960013c24782c85a7487..1a9228ab7bc95209fb4b7130aee2df0d50179ff5 100644
--- a/Sample/Multilayer/MultiLayer.cpp
+++ b/Sample/Multilayer/MultiLayer.cpp
@@ -19,9 +19,9 @@
 #include "Sample/Correlations/ILayout.h"
 #include "Sample/Material/MaterialUtils.h"
 #include "Sample/Multilayer/Layer.h"
+#include "Sample/Multilayer/MultiLayerUtils.h"
 #include "Sample/Scattering/LayerFillLimits.h"
 #include "Sample/Slice/LayerInterface.h"
-#include "Sample/Multilayer/MultiLayerUtils.h"
 #include "Sample/Slice/LayerRoughness.h"
 
 MultiLayer::MultiLayer() : m_crossCorrLength(0)
@@ -35,7 +35,7 @@ MultiLayer::~MultiLayer() = default;
 
 MultiLayer* MultiLayer::clone() const
 {
-    std::unique_ptr<MultiLayer> ret(new MultiLayer());
+    auto* ret = new MultiLayer;
     ret->setCrossCorrLength(crossCorrLength());
     ret->setExternalField(externalField());
     ret->setRoughnessModel(roughnessModel());
@@ -47,7 +47,7 @@ MultiLayer* MultiLayer::clone() const
         else
             ret->addLayer(*layer);
     }
-    return ret.release();
+    return ret;
 }
 
 //! Adds layer with default (zero) roughness
diff --git a/Sample/Multilayer/MultiLayerUtils.cpp b/Sample/Multilayer/MultiLayerUtils.cpp
index 19a8aa423bf470738ba57f5ab7ed114b27dede40..befbd7a17c2ac8781bf9a17a2eb6973cae180cc7 100644
--- a/Sample/Multilayer/MultiLayerUtils.cpp
+++ b/Sample/Multilayer/MultiLayerUtils.cpp
@@ -16,10 +16,10 @@
 #include "Sample/Correlations/ILayout.h"
 #include "Sample/Material/MaterialUtils.h"
 #include "Sample/Multilayer/Layer.h"
-#include "Sample/Scattering/LayerFillLimits.h"
-#include "Sample/Slice/LayerInterface.h"
 #include "Sample/Multilayer/MultiLayer.h"
 #include "Sample/Particle/IParticle.h"
+#include "Sample/Scattering/LayerFillLimits.h"
+#include "Sample/Slice/LayerInterface.h"
 
 namespace
 {
diff --git a/Sample/Particle/Crystal.cpp b/Sample/Particle/Crystal.cpp
index 41da52a4b8fe5f02ebb216c5a764b14d2bd369e0..f601fd2038e2efaa13dcea07846460abf180ace9 100644
--- a/Sample/Particle/Crystal.cpp
+++ b/Sample/Particle/Crystal.cpp
@@ -47,9 +47,8 @@ IFormFactor* Crystal::createTotalFormFactor(const IFormFactor& meso_crystal_form
         P_basis_clone->rotate(*p_rotation);
     P_basis_clone->translate(translation);
     const std::unique_ptr<IFormFactor> P_basis_ff(P_basis_clone->createFormFactor());
-    std::unique_ptr<FormFactorCrystal> P_ff_crystal(new FormFactorCrystal(
-        transformed_lattice, *P_basis_ff, meso_crystal_form_factor, m_position_variance));
-    return P_ff_crystal.release();
+    return new FormFactorCrystal(transformed_lattice, *P_basis_ff, meso_crystal_form_factor,
+                                 m_position_variance);
 }
 
 std::vector<HomogeneousRegion> Crystal::homogeneousRegions() const
diff --git a/Sample/Particle/FormFactorCoreShell.cpp b/Sample/Particle/FormFactorCoreShell.cpp
index c072cee2a43c2cbd5f28c4808f5d394454c310d6..6066d2aad29f728b6ba0495fec62850888911ba5 100644
--- a/Sample/Particle/FormFactorCoreShell.cpp
+++ b/Sample/Particle/FormFactorCoreShell.cpp
@@ -42,9 +42,9 @@ double FormFactorCoreShell::topZ(const IRotation& rotation) const
     return mP_shell->topZ(rotation);
 }
 
-void FormFactorCoreShell::setAmbientMaterial(Material material)
+void FormFactorCoreShell::setAmbientMaterial(const Material& material)
 {
-    mP_shell->setAmbientMaterial(std::move(material));
+    mP_shell->setAmbientMaterial(material);
 }
 
 complex_t FormFactorCoreShell::evaluate(const WavevectorInfo& wavevectors) const
diff --git a/Sample/Particle/FormFactorCoreShell.h b/Sample/Particle/FormFactorCoreShell.h
index 967a88fcf3d22880f8bd99b7fce904f87020d283..1c1b8353bb1207626bba70ae2343a611c13ae5c8 100644
--- a/Sample/Particle/FormFactorCoreShell.h
+++ b/Sample/Particle/FormFactorCoreShell.h
@@ -41,7 +41,7 @@ public:
 
     double topZ(const IRotation& rotation) const override final;
 
-    void setAmbientMaterial(Material material) override final;
+    void setAmbientMaterial(const Material& material) override final;
 
     complex_t evaluate(const WavevectorInfo& wavevectors) const override final;
 
diff --git a/Sample/Particle/FormFactorCrystal.h b/Sample/Particle/FormFactorCrystal.h
index 82f2ade2685bba638017272f34b0823b1fb01e84..8f0cf4672dd0debf2f8f049e267f96037fb296a9 100644
--- a/Sample/Particle/FormFactorCrystal.h
+++ b/Sample/Particle/FormFactorCrystal.h
@@ -36,9 +36,9 @@ public:
 
     void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
-    void setAmbientMaterial(Material material) override
+    void setAmbientMaterial(const Material& material) override
     {
-        mp_basis_form_factor->setAmbientMaterial(std::move(material));
+        mp_basis_form_factor->setAmbientMaterial(material);
     }
 
     double volume() const override final { return mp_meso_form_factor->volume(); }
diff --git a/Sample/Particle/FormFactorWeighted.cpp b/Sample/Particle/FormFactorWeighted.cpp
index 47968a2c3604c940d418a094a12c19c4a538ff56..7336986afc60dfb1eecafea68a68bab9738ad9b4 100644
--- a/Sample/Particle/FormFactorWeighted.cpp
+++ b/Sample/Particle/FormFactorWeighted.cpp
@@ -66,7 +66,7 @@ void FormFactorWeighted::addFormFactor(const IFormFactor& form_factor, double we
     m_weights.push_back(weight);
 }
 
-void FormFactorWeighted::setAmbientMaterial(Material material)
+void FormFactorWeighted::setAmbientMaterial(const Material& material)
 {
     for (size_t index = 0; index < m_form_factors.size(); ++index)
         m_form_factors[index]->setAmbientMaterial(material);
diff --git a/Sample/Particle/FormFactorWeighted.h b/Sample/Particle/FormFactorWeighted.h
index d0b621ebd5ae03367fd16645f209df1a275520a5..20ee91190f9399d4595e6443becc31d25fb2a6f1 100644
--- a/Sample/Particle/FormFactorWeighted.h
+++ b/Sample/Particle/FormFactorWeighted.h
@@ -43,7 +43,7 @@ public:
 
     void addFormFactor(const IFormFactor& form_factor, double weight = 1.0);
 
-    void setAmbientMaterial(Material material) override final;
+    void setAmbientMaterial(const Material& material) override final;
 
     complex_t evaluate(const WavevectorInfo& wavevectors) const override final;
 
diff --git a/Sample/Particle/ParticleComposition.cpp b/Sample/Particle/ParticleComposition.cpp
index ba279008b737a8c0370393dc669d320fb22e4cd3..1dd41420ac016bfb0ff1ad13db05cdc7cb94dcc4 100644
--- a/Sample/Particle/ParticleComposition.cpp
+++ b/Sample/Particle/ParticleComposition.cpp
@@ -48,13 +48,13 @@ IFormFactor* ParticleComposition::createFormFactor() const
 {
     if (m_particles.empty())
         return {};
-    std::unique_ptr<FormFactorWeighted> P_result{new FormFactorWeighted()};
+    auto* result = new FormFactorWeighted;
     auto particles = decompose();
     for (auto p_particle : particles) {
         std::unique_ptr<IFormFactor> P_particle_ff{p_particle->createFormFactor()};
-        P_result->addFormFactor(*P_particle_ff);
+        result->addFormFactor(*P_particle_ff);
     }
-    return P_result.release();
+    return result;
 }
 
 void ParticleComposition::addParticle(const IParticle& particle)
diff --git a/Sample/Scattering/FormFactorBAPol.h b/Sample/Scattering/FormFactorBAPol.h
index 8dd82ce483b92752f2c5e2ec73e4642a1126c4a6..f12f96309ce3267b3fe7cf3fcbcd9132f66c2098 100644
--- a/Sample/Scattering/FormFactorBAPol.h
+++ b/Sample/Scattering/FormFactorBAPol.h
@@ -32,9 +32,9 @@ public:
 
     void accept(INodeVisitor* visitor) const override { visitor->visit(this); }
 
-    void setAmbientMaterial(Material material) override
+    void setAmbientMaterial(const Material& material) override
     {
-        mP_form_factor->setAmbientMaterial(std::move(material));
+        mP_form_factor->setAmbientMaterial(material);
     }
 
     //! Throws not-implemented exception
diff --git a/Sample/Scattering/FormFactorDWBA.h b/Sample/Scattering/FormFactorDWBA.h
index cd217b0f350d383c06a11b257331abcd0f5ba40a..fadeddfe15556c77cae099a2caeac0ff7cf62855 100644
--- a/Sample/Scattering/FormFactorDWBA.h
+++ b/Sample/Scattering/FormFactorDWBA.h
@@ -33,9 +33,9 @@ public:
 
     void accept(INodeVisitor* visitor) const override { visitor->visit(this); }
 
-    void setAmbientMaterial(Material material) override
+    void setAmbientMaterial(const Material& material) override
     {
-        mP_form_factor->setAmbientMaterial(std::move(material));
+        mP_form_factor->setAmbientMaterial(material);
     }
 
     //! Calculates and returns a form factor calculation in DWBA
diff --git a/Sample/Scattering/FormFactorDWBAPol.h b/Sample/Scattering/FormFactorDWBAPol.h
index 5eb3fdfea35ad7b80f30c32d80b335124b815309..5433bbc642287d8cf68bdded0c480efcf6235dfb 100644
--- a/Sample/Scattering/FormFactorDWBAPol.h
+++ b/Sample/Scattering/FormFactorDWBAPol.h
@@ -34,9 +34,9 @@ public:
 
     void accept(INodeVisitor* visitor) const override { visitor->visit(this); }
 
-    void setAmbientMaterial(Material material) override
+    void setAmbientMaterial(const Material& material) override
     {
-        mP_form_factor->setAmbientMaterial(std::move(material));
+        mP_form_factor->setAmbientMaterial(material);
     }
 
     //! Throws not-implemented exception
diff --git a/Sample/Scattering/FormFactorDecoratorMaterial.cpp b/Sample/Scattering/FormFactorDecoratorMaterial.cpp
index 8ce20777c14e42e430a701394a75e8f6c3d5d6c4..626fc18eed8aa878276af77e5fe7131f7d43e24f 100644
--- a/Sample/Scattering/FormFactorDecoratorMaterial.cpp
+++ b/Sample/Scattering/FormFactorDecoratorMaterial.cpp
@@ -28,21 +28,20 @@ FormFactorDecoratorMaterial::~FormFactorDecoratorMaterial() = default;
 
 FormFactorDecoratorMaterial* FormFactorDecoratorMaterial::clone() const
 {
-    std::unique_ptr<FormFactorDecoratorMaterial> P_result(
-        new FormFactorDecoratorMaterial(*mp_form_factor));
-    P_result->setMaterial(m_material);
-    P_result->setAmbientMaterial(m_ambient_material);
-    return P_result.release();
+    auto* result = new FormFactorDecoratorMaterial(*mp_form_factor);
+    result->setMaterial(m_material);
+    result->setAmbientMaterial(m_ambient_material);
+    return result;
 }
 
-void FormFactorDecoratorMaterial::setMaterial(Material material)
+void FormFactorDecoratorMaterial::setMaterial(const Material& material)
 {
-    m_material = std::move(material);
+    m_material = material;
 }
 
-void FormFactorDecoratorMaterial::setAmbientMaterial(Material material)
+void FormFactorDecoratorMaterial::setAmbientMaterial(const Material& material)
 {
-    m_ambient_material = std::move(material);
+    m_ambient_material = material;
 }
 
 complex_t FormFactorDecoratorMaterial::evaluate(const WavevectorInfo& wavevectors) const
diff --git a/Sample/Scattering/FormFactorDecoratorMaterial.h b/Sample/Scattering/FormFactorDecoratorMaterial.h
index e39329928ebe6fa5680d6b77db5d817e29f504ac..64cd9ff44628854108b042d3284f410a2bc3a69e 100644
--- a/Sample/Scattering/FormFactorDecoratorMaterial.h
+++ b/Sample/Scattering/FormFactorDecoratorMaterial.h
@@ -15,6 +15,7 @@
 #ifndef BORNAGAIN_CORE_SCATTERING_FORMFACTORDECORATORMATERIAL_H
 #define BORNAGAIN_CORE_SCATTERING_FORMFACTORDECORATORMATERIAL_H
 
+#include "Sample/Material/Material.h"
 #include "Sample/Scattering/IFormFactorDecorator.h"
 #include <memory>
 
@@ -34,10 +35,10 @@ public:
     void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     //! Sets the material of the scatterer
-    void setMaterial(Material material);
+    void setMaterial(const Material& material);
 
     //! Sets the ambient material
-    void setAmbientMaterial(Material material) override;
+    void setAmbientMaterial(const Material& material) override;
 
     complex_t evaluate(const WavevectorInfo& wavevectors) const override;
 #ifndef SWIG
diff --git a/Sample/Scattering/IFormFactor.h b/Sample/Scattering/IFormFactor.h
index 879e88eee0fe6447b80f7ce30e56995fb6220118..603b2aadae1ce0ad26cc5d2b0e46cab7145a64fc 100644
--- a/Sample/Scattering/IFormFactor.h
+++ b/Sample/Scattering/IFormFactor.h
@@ -15,12 +15,14 @@
 #ifndef BORNAGAIN_CORE_SCATTERING_IFORMFACTOR_H
 #define BORNAGAIN_CORE_SCATTERING_IFORMFACTOR_H
 
-#include "Sample/Material/Material.h"
+#include "Base/Types/Complex.h"
 #include "Sample/Scattering/ISample.h"
 #include "Sample/Scattering/ZLimits.h"
+#include <Eigen/Core>
 
 class ILayerRTCoefficients;
 class IRotation;
+class Material;
 class WavevectorInfo;
 
 //! Pure virtual base class for all form factors.
@@ -48,7 +50,7 @@ public:
                                         kvector_t translation) const;
 
     //! Passes the material in which this particle is embedded.
-    virtual void setAmbientMaterial(Material) = 0;
+    virtual void setAmbientMaterial(const Material&) = 0;
 
     //! Returns scattering amplitude for complex wavevectors ki, kf.
     virtual complex_t evaluate(const WavevectorInfo& wavevectors) const = 0;
diff --git a/Sample/Scattering/IFormFactorBorn.h b/Sample/Scattering/IFormFactorBorn.h
index 171b5d71ae55f9741456233011cc8a6325c51b5e..a873ed4bdf2a9cdf498b56a1300b560479a2452a 100644
--- a/Sample/Scattering/IFormFactorBorn.h
+++ b/Sample/Scattering/IFormFactorBorn.h
@@ -37,7 +37,7 @@ public:
 
     IFormFactorBorn* clone() const override = 0;
 
-    void setAmbientMaterial(Material) override {}
+    void setAmbientMaterial(const Material&) override {}
 
     complex_t evaluate(const WavevectorInfo& wavevectors) const override;
 
diff --git a/Sample/Scattering/IFormFactorDecorator.h b/Sample/Scattering/IFormFactorDecorator.h
index 5ea66cb35d611fd68ac4cda4226fd872332c7d33..9b0100b8e7e3a37184206cd37adf98a3b03f9ad7 100644
--- a/Sample/Scattering/IFormFactorDecorator.h
+++ b/Sample/Scattering/IFormFactorDecorator.h
@@ -32,7 +32,7 @@ public:
     ~IFormFactorDecorator() override { delete mp_form_factor; }
     IFormFactorDecorator* clone() const override = 0;
 
-    void setAmbientMaterial(Material material) override
+    void setAmbientMaterial(const Material& material) override
     {
         mp_form_factor->setAmbientMaterial(material);
     }
diff --git a/Sample/Specular/SpecularMagneticOldStrategy.cpp b/Sample/Specular/SpecularMagneticOldStrategy.cpp
index 2d3d8b1d8cecd8a326d88837e224de8a0fcf5d3e..b58f980c5011ddf9b6a755fa05bc8bef4bf63623 100644
--- a/Sample/Specular/SpecularMagneticOldStrategy.cpp
+++ b/Sample/Specular/SpecularMagneticOldStrategy.cpp
@@ -15,8 +15,8 @@
 #include "Sample/Specular/SpecularMagneticOldStrategy.h"
 #include "Sample/Material/WavevectorInfo.h"
 #include "Sample/Multilayer/Layer.h"
-#include "Sample/Slice/LayerInterface.h"
 #include "Sample/Multilayer/MultiLayer.h"
+#include "Sample/Slice/LayerInterface.h"
 #include "Sample/Slice/Slice.h"
 #include <Eigen/LU>
 
diff --git a/Sample/Specular/SpecularScalarStrategy.cpp b/Sample/Specular/SpecularScalarStrategy.cpp
index 2012ab735bf739d4f2cce2fdfe79581a74cd15f3..e341927376138bfa96d3b3e9320db0cf9652652c 100644
--- a/Sample/Specular/SpecularScalarStrategy.cpp
+++ b/Sample/Specular/SpecularScalarStrategy.cpp
@@ -13,8 +13,8 @@
 // ************************************************************************** //
 
 #include "Sample/Specular/SpecularScalarStrategy.h"
-#include "Sample/Slice/KzComputation.h"
 #include "Sample/Multilayer/Layer.h"
+#include "Sample/Slice/KzComputation.h"
 #include "Sample/Slice/LayerRoughness.h"
 #include "Sample/Slice/Slice.h"
 #include <Eigen/Dense>
diff --git a/Sample/StandardSamples/CylindersBuilder.cpp b/Sample/StandardSamples/CylindersBuilder.cpp
index 896f10d228b29cedf92868b43662fb536e8ef3cd..034d965458885668e83027e09bcbb6093f1a0abd 100644
--- a/Sample/StandardSamples/CylindersBuilder.cpp
+++ b/Sample/StandardSamples/CylindersBuilder.cpp
@@ -17,9 +17,9 @@
 #include "Sample/Aggregate/ParticleLayout.h"
 #include "Sample/HardParticle/FormFactorCylinder.h"
 #include "Sample/Multilayer/Layer.h"
-#include "Sample/Slice/LayerInterface.h"
 #include "Sample/Multilayer/MultiLayer.h"
 #include "Sample/Particle/Particle.h"
+#include "Sample/Slice/LayerInterface.h"
 #include "Sample/StandardSamples/ReferenceMaterials.h"
 
 // -----------------------------------------------------------------------------
diff --git a/Sample/StandardSamples/LayersWithAbsorptionBuilder.cpp b/Sample/StandardSamples/LayersWithAbsorptionBuilder.cpp
index ba42d4eb4fb9b01c6e5ac314636d4d02fde0eb34..cce776fcf147a5a9b497f82455c3a09e2240e6bc 100644
--- a/Sample/StandardSamples/LayersWithAbsorptionBuilder.cpp
+++ b/Sample/StandardSamples/LayersWithAbsorptionBuilder.cpp
@@ -17,10 +17,10 @@
 #include "Sample/Aggregate/ParticleLayout.h"
 #include "Sample/HardParticle/FormFactorFullSphere.h"
 #include "Sample/Multilayer/Layer.h"
-#include "Sample/Slice/LayerInterface.h"
 #include "Sample/Multilayer/MultiLayer.h"
 #include "Sample/Particle/Particle.h"
 #include "Sample/SampleBuilderEngine/SampleComponents.h"
+#include "Sample/Slice/LayerInterface.h"
 #include "Sample/StandardSamples/ReferenceMaterials.h"
 
 namespace
diff --git a/Sample/StandardSamples/MagneticParticlesBuilder.cpp b/Sample/StandardSamples/MagneticParticlesBuilder.cpp
index 9f3a9e2977cecc333ffae231868ca7b7d3e367c9..8d2387fb7ff25c204e6a441ca767f68390c311ea 100644
--- a/Sample/StandardSamples/MagneticParticlesBuilder.cpp
+++ b/Sample/StandardSamples/MagneticParticlesBuilder.cpp
@@ -19,9 +19,9 @@
 #include "Sample/HardParticle/FormFactorFullSphere.h"
 #include "Sample/Material/MaterialFactoryFuncs.h"
 #include "Sample/Multilayer/Layer.h"
-#include "Sample/Slice/LayerInterface.h"
 #include "Sample/Multilayer/MultiLayer.h"
 #include "Sample/Particle/Particle.h"
+#include "Sample/Slice/LayerInterface.h"
 #include "Sample/Slice/LayerRoughness.h"
 
 // ----------------------------------------------------------------------------
diff --git a/Sample/StandardSamples/ResonatorBuilder.cpp b/Sample/StandardSamples/ResonatorBuilder.cpp
index 521efc9d6ae5a814849c2eb5416b7092fcd16190..db67f2591cf219e0f4fd2c8d24a758211effc027 100644
--- a/Sample/StandardSamples/ResonatorBuilder.cpp
+++ b/Sample/StandardSamples/ResonatorBuilder.cpp
@@ -27,7 +27,7 @@ ResonatorBuilder::ResonatorBuilder() : ISampleBuilder(), m_l_ti(13.0 * Units::nm
 
 MultiLayer* ResonatorBuilder::buildSample() const
 {
-    std::unique_ptr<MultiLayer> result(new MultiLayer);
+    auto* result = new MultiLayer;
 
     Material m_Si = HomogeneousMaterial("Si", 8.25218379931e-06, 0.0);
     Material m_Ti = HomogeneousMaterial("Ti", -7.6593316363e-06, 3.81961616312e-09);
@@ -58,5 +58,5 @@ MultiLayer* ResonatorBuilder::buildSample() const
 
     result->setCrossCorrLength(400 * Units::nm);
 
-    return result.release();
+    return result;
 }
diff --git a/Tests/Functional/Python/PyPersistence/example_template.py b/Tests/Functional/Python/PyPersistence/example_template.py
index 48f6b4d5655296929be9024e8e00792be4485936..e3f9676bb77c78cc7fb645580a05ab533a8722c4 100644
--- a/Tests/Functional/Python/PyPersistence/example_template.py
+++ b/Tests/Functional/Python/PyPersistence/example_template.py
@@ -34,7 +34,7 @@ def get_simulation_DepthProbe():
     Returns custom simulation in the case of depth probe.
     """
     simulation = example.get_simulation()
-    beam = simulation.getInstrument().getBeam()
+    beam = simulation.instrument().getBeam()
     wavelength = beam.getWavelength()
     incl_axis = simulation.getAlphaAxis()
     z_axis = simulation.getZAxis()
@@ -62,7 +62,7 @@ def get_simulation_GenericExample():
     threads settings etc) remains intact.
     """
     simulation = example.get_simulation()
-    detector = simulation.getInstrument().getDetector()
+    detector = simulation.instrument().getDetector()
 
     # preserving axes range, making less bins
     ax = detector.getAxis(0)
diff --git a/Tests/UnitTests/Core/Detector/RectangularDetectorTest.cpp b/Tests/UnitTests/Core/Detector/RectangularDetectorTest.cpp
index 99c1ef6c98308f11fe815112c80ad89561b905be..6159e4de9a8d2985aa2dce8a12df26e9650f813f 100644
--- a/Tests/UnitTests/Core/Detector/RectangularDetectorTest.cpp
+++ b/Tests/UnitTests/Core/Detector/RectangularDetectorTest.cpp
@@ -81,13 +81,13 @@ TEST_F(RectangularDetectorTest, PerpToSample)
     // initializing with the simulation
     GISASSimulation simulation;
     simulation.setBeamParameters(1.0, 10.0 * Units::degree, 0.0);
-    det.init(simulation.getInstrument().getBeam());
+    det.init(simulation.instrument().getBeam());
     EXPECT_TRUE(kvector_t(distance, 0, 0) == det.getNormalVector());
     EXPECT_TRUE(kvector_t(0.0, -1.0, 0.0) == det.getDirectionVector());
 
     // FIXME cleanup, replace with DetectorContext tests
     //    std::vector<DetectorElement> elements
-    //        = det.createDetectorElements(simulation.getInstrument().getBeam());
+    //        = det.createDetectorElements(simulation.instrument().getBeam());
     //    EXPECT_EQ(elements.size(), nbinsx * nbinsy);
 
     //    double wavelength = 1.0;
@@ -135,13 +135,13 @@ TEST_F(RectangularDetectorTest, PerpToDirectBeam)
     // initializing with the simulation
     GISASSimulation simulation;
     simulation.setBeamParameters(1.0, alpha_i, 0.0);
-    det.init(simulation.getInstrument().getBeam());
+    det.init(simulation.instrument().getBeam());
     kvector_t normal(distance * cos(alpha_i), 0.0, -1.0 * distance * sin(alpha_i));
     EXPECT_TRUE(isEqual(normal, det.getNormalVector()));
     EXPECT_TRUE(kvector_t(0.0, -1.0, 0.0) == det.getDirectionVector());
 
     //    std::vector<DetectorElement> elements
-    //        = det.createDetectorElements(simulation.getInstrument().getBeam());
+    //        = det.createDetectorElements(simulation.instrument().getBeam());
     //    EXPECT_EQ(elements.size(), nbinsx * nbinsy);
 
     //    // lower left bin
@@ -178,14 +178,14 @@ TEST_F(RectangularDetectorTest, PerpToReflectedBeam)
     // initializing with the simulation
     GISASSimulation simulation;
     simulation.setBeamParameters(1.0, alpha_i, 0.0);
-    det.init(simulation.getInstrument().getBeam());
+    det.init(simulation.instrument().getBeam());
     kvector_t normal(distance * cos(alpha_i), 0.0, 1.0 * distance * sin(alpha_i));
     EXPECT_TRUE(isEqual(normal, det.getNormalVector()));
     EXPECT_TRUE(kvector_t(0.0, -1.0, 0.0) == det.getDirectionVector());
 
     //    // checking detector elements
     //    std::vector<DetectorElement> elements
-    //        = det.createDetectorElements(simulation.getInstrument().getBeam());
+    //        = det.createDetectorElements(simulation.instrument().getBeam());
     //    EXPECT_EQ(elements.size(), nbinsx * nbinsy);
 
     //    double ds = v0 - dy / 2.;
@@ -233,7 +233,7 @@ TEST_F(RectangularDetectorTest, PerpToReflectedBeamDpos)
     // initializing with the simulation
     GISASSimulation simulation;
     simulation.setBeamParameters(1.0, alpha_i, 0.0);
-    det.init(simulation.getInstrument().getBeam());
+    det.init(simulation.instrument().getBeam());
 
     kvector_t normal(distance * cos(alpha_i), 0.0, 1.0 * distance * sin(alpha_i));
     EXPECT_TRUE(isEqual(normal, det.getNormalVector()));
@@ -243,7 +243,7 @@ TEST_F(RectangularDetectorTest, PerpToReflectedBeamDpos)
 
     //    // checking detector elements
     //    std::vector<DetectorElement> elements
-    //        = det.createDetectorElements(simulation.getInstrument().getBeam());
+    //        = det.createDetectorElements(simulation.instrument().getBeam());
     //    EXPECT_EQ(elements.size(), nbinsx * nbinsy);
 
     //    double ds = v0 - dy / 2.;
diff --git a/Tests/UnitTests/Core/Detector/SimulationAreaTest.cpp b/Tests/UnitTests/Core/Detector/SimulationAreaTest.cpp
index 3e5b7c8ec74ea830ae45bac79bc831fd76006c5b..6b83b9abd3fccd8c122bf0886e2e85e4fdc4bc42 100644
--- a/Tests/UnitTests/Core/Detector/SimulationAreaTest.cpp
+++ b/Tests/UnitTests/Core/Detector/SimulationAreaTest.cpp
@@ -1,5 +1,4 @@
 #include "Device/Detector/SimulationArea.h"
-#include "Device/Detector/DetectorFunctions.h"
 #include "Device/Detector/SphericalDetector.h"
 #include "Device/Mask/Rectangle.h"
 #include "Tests/GTestWrapper/google_test.h"
diff --git a/Tests/UnitTests/Core/Detector/SphericalDetectorTest.cpp b/Tests/UnitTests/Core/Detector/SphericalDetectorTest.cpp
index 184f9b0f029bbf3edf35c2347c298813659576e7..bd363f72a915cfc3cd0bffebb95c2fbec8cc612d 100644
--- a/Tests/UnitTests/Core/Detector/SphericalDetectorTest.cpp
+++ b/Tests/UnitTests/Core/Detector/SphericalDetectorTest.cpp
@@ -1,7 +1,6 @@
 #include "Device/Detector/SphericalDetector.h"
 #include "Base/Const/Units.h"
 #include "Device/Beam/Beam.h"
-#include "Device/Detector/DetectorFunctions.h"
 #include "Device/Detector/RegionOfInterest.h"
 #include "Device/Detector/SimulationArea.h"
 #include "Device/Mask/Polygon.h"
diff --git a/Tests/UnitTests/Core/Fresnel/DepthProbeSimulationTest.cpp b/Tests/UnitTests/Core/Fresnel/DepthProbeSimulationTest.cpp
index 1eba17627bc83b18dd8ad06aa467f0b4b6cd1675..41524cc1b5292cc1d5f7244f81010d204f476d06 100644
--- a/Tests/UnitTests/Core/Fresnel/DepthProbeSimulationTest.cpp
+++ b/Tests/UnitTests/Core/Fresnel/DepthProbeSimulationTest.cpp
@@ -49,7 +49,7 @@ std::unique_ptr<DepthProbeSimulation> DepthProbeSimulationTest::defaultSimulatio
 
 void DepthProbeSimulationTest::checkBeamState(const DepthProbeSimulation& sim)
 {
-    const auto* inclination = sim.getInstrument().getBeam().parameter("InclinationAngle");
+    const auto* inclination = sim.instrument().getBeam().parameter("InclinationAngle");
     const auto test_limits = RealLimits::limited(-M_PI_2, M_PI_2);
     EXPECT_EQ(test_limits, inclination->limits());
     EXPECT_EQ(0.0, inclination->value());
@@ -99,7 +99,7 @@ TEST_F(DepthProbeSimulationTest, CheckAxesOfDefaultSimulation)
 TEST_F(DepthProbeSimulationTest, SetBeamParameters)
 {
     DepthProbeSimulation sim;
-    const auto& beam = sim.getInstrument().getBeam();
+    const auto& beam = sim.instrument().getBeam();
 
     sim.setBeamParameters(1.0, 10, 1.0 * Units::degree, 10.0 * Units::degree);
     EXPECT_EQ(10u, sim.getAlphaAxis()->size());
diff --git a/Tests/UnitTests/Core/Fresnel/SpecularMagneticTest.cpp b/Tests/UnitTests/Core/Fresnel/SpecularMagneticTest.cpp
index 4fb93d55443c2a49409391a0c2c0704daca93803..76c4ebfe8401599917798eb1f5e6ec047bb3db15 100644
--- a/Tests/UnitTests/Core/Fresnel/SpecularMagneticTest.cpp
+++ b/Tests/UnitTests/Core/Fresnel/SpecularMagneticTest.cpp
@@ -1,10 +1,10 @@
 #include "Base/Const/Units.h"
 #include "Core/Computation/ProcessedSample.h"
 #include "Sample/Material/MaterialFactoryFuncs.h"
-#include "Sample/Slice/KzComputation.h"
 #include "Sample/Multilayer/Layer.h"
 #include "Sample/Multilayer/MultiLayer.h"
 #include "Sample/RT/SimulationOptions.h"
+#include "Sample/Slice/KzComputation.h"
 #include "Sample/Specular/SpecularMagneticNewTanhStrategy.h"
 #include "Sample/Specular/SpecularMagneticStrategy.h"
 #include "Sample/Specular/SpecularScalarTanhStrategy.h"
@@ -52,7 +52,7 @@ template <> void SpecularMagneticTest::test_degenerate<SpecularMagneticNewTanhSt
     }
 }
 
-    //! Compares results with scalar case
+//! Compares results with scalar case
 template <typename Strategy>
 void SpecularMagneticTest::testZeroField(const kvector_t& k, const ProcessedSample& sample)
 {
diff --git a/Tests/UnitTests/Core/Fresnel/SpecularSimulationTest.cpp b/Tests/UnitTests/Core/Fresnel/SpecularSimulationTest.cpp
index 61674187658979b26aab7435efa852d84792b683..28b10bbf2a1904aaa227229e18119e4393f33eb1 100644
--- a/Tests/UnitTests/Core/Fresnel/SpecularSimulationTest.cpp
+++ b/Tests/UnitTests/Core/Fresnel/SpecularSimulationTest.cpp
@@ -61,7 +61,7 @@ std::unique_ptr<SpecularSimulation> SpecularSimulationTest::defaultSimulation()
 
 void SpecularSimulationTest::checkBeamState(const SpecularSimulation& sim)
 {
-    const auto* inclination = sim.getInstrument().getBeam().parameter("InclinationAngle");
+    const auto* inclination = sim.instrument().getBeam().parameter("InclinationAngle");
     const auto test_limits = RealLimits::limited(-M_PI_2, M_PI_2);
     EXPECT_EQ(test_limits, inclination->limits());
     EXPECT_EQ(0.0, inclination->value());
@@ -86,7 +86,7 @@ TEST_F(SpecularSimulationTest, SetAngularScan)
     SpecularSimulation sim;
     AngularSpecScan scan(1.0, std::vector<double>{1.0 * Units::deg, 3.0 * Units::deg});
     sim.setScan(scan);
-    const auto& beam = sim.getInstrument().getBeam();
+    const auto& beam = sim.instrument().getBeam();
 
     EXPECT_EQ(2u, sim.coordinateAxis()->size());
     EXPECT_EQ(1.0 * Units::deg, sim.coordinateAxis()->getMin());
@@ -135,7 +135,7 @@ TEST_F(SpecularSimulationTest, SetQScan)
     QSpecScan scan(std::vector<double>{1.0, 3.0});
     sim.setScan(scan);
 
-    const auto& beam = sim.getInstrument().getBeam();
+    const auto& beam = sim.instrument().getBeam();
 
     EXPECT_EQ(2u, sim.coordinateAxis()->size());
     EXPECT_EQ(1.0, sim.coordinateAxis()->getMin());
@@ -245,7 +245,7 @@ TEST_F(SpecularSimulationTest, AddingBeamDistributions)
 TEST_F(SpecularSimulationTest, OutOfRangeAngles)
 {
     auto sim = defaultSimulation();
-    auto& beam = sim->getInstrument().getBeam();
+    auto& beam = sim->instrument().getBeam();
     beam.parameter("InclinationAngle")->setValue(-0.2 * Units::deg);
 
     sim->runSimulation();
diff --git a/Tests/UnitTests/Core/Sample/MultiLayerTest.cpp b/Tests/UnitTests/Core/Sample/MultiLayerTest.cpp
index fd1818a6d099adf8b42d252d7d3b5f328ba92ee0..3834589e019a2f3dc68961d7b5327259ae202bfa 100644
--- a/Tests/UnitTests/Core/Sample/MultiLayerTest.cpp
+++ b/Tests/UnitTests/Core/Sample/MultiLayerTest.cpp
@@ -4,8 +4,8 @@
 #include "Sample/Aggregate/ParticleLayout.h"
 #include "Sample/Material/MaterialFactoryFuncs.h"
 #include "Sample/Multilayer/Layer.h"
-#include "Sample/Slice/LayerInterface.h"
 #include "Sample/Multilayer/MultiLayerUtils.h"
+#include "Sample/Slice/LayerInterface.h"
 #include "Sample/Slice/LayerRoughness.h"
 #include "Tests/GTestWrapper/google_test.h"
 
diff --git a/Tests/UnitTests/Core/Sample/RTTest.cpp b/Tests/UnitTests/Core/Sample/RTTest.cpp
index 55445a64b6e896187418d80421e3176d047be300..cd6fce27abd58d1cb906677c55d046a7c7ad0df3 100644
--- a/Tests/UnitTests/Core/Sample/RTTest.cpp
+++ b/Tests/UnitTests/Core/Sample/RTTest.cpp
@@ -3,9 +3,9 @@
 #include "Sample/Aggregate/ParticleLayout.h"
 #include "Sample/Material/MaterialFactoryFuncs.h"
 #include "Sample/Multilayer/Layer.h"
-#include "Sample/Slice/LayerInterface.h"
 #include "Sample/Multilayer/MultiLayer.h"
 #include "Sample/RT/SimulationOptions.h"
+#include "Sample/Slice/LayerInterface.h"
 #include "Sample/Slice/LayerRoughness.h"
 #include "Sample/Specular/SpecularScalarTanhStrategy.h"
 #include "Tests/GTestWrapper/google_test.h"
diff --git a/Tests/UnitTests/GUI/TestLinkInstrument.cpp b/Tests/UnitTests/GUI/TestLinkInstrument.cpp
index 9c44637e18d428ed35abe2439c39804b3111a3a0..1cef32a366474d3b3f5e2729ce055f6ea35f926e 100644
--- a/Tests/UnitTests/GUI/TestLinkInstrument.cpp
+++ b/Tests/UnitTests/GUI/TestLinkInstrument.cpp
@@ -38,14 +38,14 @@ TEST_F(TestLinkInstrument, test_linkInstrumentManager)
     EXPECT_EQ(spy.count(), 1);
     EXPECT_EQ(manager.instrumentNames(), QStringList() << "Undefined" << instrument->itemName());
 
-    EXPECT_EQ(manager.getInstrument(identifier), instrument);
+    EXPECT_EQ(manager.instrument(identifier), instrument);
     EXPECT_EQ(manager.instrumentComboIndex(identifier), 1);
 
     // removing instrument
     instrumentModel.removeRow(0);
     EXPECT_EQ(spy.count(), 2);
     EXPECT_EQ(manager.instrumentNames(), QStringList() << "Undefined");
-    QVERIFY(manager.getInstrument(identifier) == nullptr);
+    QVERIFY(manager.instrument(identifier) == nullptr);
     EXPECT_EQ(manager.instrumentComboIndex(identifier), -1);
 }
 
diff --git a/auto/Wrap/doxygenCore.i b/auto/Wrap/doxygenCore.i
index c44b75238a1fb79d3f9d7c366d12ec5bb6d4580b..04f6dec3a60a40775143fdb320b6951bd7a7ccc7 100644
--- a/auto/Wrap/doxygenCore.i
+++ b/auto/Wrap/doxygenCore.i
@@ -119,7 +119,7 @@ C++ includes: ConstantBackground.h
 %feature("docstring")  ConstantBackground::accept "void ConstantBackground::accept(INodeVisitor *visitor) const override
 ";
 
-%feature("docstring")  ConstantBackground::addBackGround "double ConstantBackground::addBackGround(double intensity) const override final
+%feature("docstring")  ConstantBackground::addBackground "double ConstantBackground::addBackground(double intensity) const override final
 ";
 
 
@@ -708,7 +708,7 @@ C++ includes: IBackground.h
 %feature("docstring")  IBackground::clone "virtual IBackground* IBackground::clone() const =0
 ";
 
-%feature("docstring")  IBackground::addBackGround "virtual double IBackground::addBackGround(double element) const =0
+%feature("docstring")  IBackground::addBackground "virtual double IBackground::addBackground(double element) const =0
 ";
 
 
@@ -1162,7 +1162,7 @@ C++ includes: PoissonNoiseBackground.h
 %feature("docstring")  PoissonNoiseBackground::accept "void PoissonNoiseBackground::accept(INodeVisitor *visitor) const override
 ";
 
-%feature("docstring")  PoissonNoiseBackground::addBackGround "double PoissonNoiseBackground::addBackGround(double intensity) const override final
+%feature("docstring")  PoissonNoiseBackground::addBackground "double PoissonNoiseBackground::addBackground(double intensity) const override final
 ";
 
 
@@ -1697,13 +1697,13 @@ Run simulation with possible averaging over parameter distributions.
 Run a simulation in a MPI environment. 
 ";
 
-%feature("docstring")  Simulation::setInstrument "void Simulation::setInstrument(const Instrument &instrument)
+%feature("docstring")  Simulation::setInstrument "void Simulation::setInstrument(const Instrument &instrument_)
 ";
 
-%feature("docstring")  Simulation::getInstrument "const Instrument& Simulation::getInstrument() const
+%feature("docstring")  Simulation::instrument "const Instrument& Simulation::instrument() const
 ";
 
-%feature("docstring")  Simulation::getInstrument "Instrument& Simulation::getInstrument()
+%feature("docstring")  Simulation::instrument "Instrument& Simulation::instrument()
 ";
 
 %feature("docstring")  Simulation::setBeamIntensity "void Simulation::setBeamIntensity(double intensity)
diff --git a/auto/Wrap/doxygenDevice.i b/auto/Wrap/doxygenDevice.i
index 27f26d7bd72e843ef3916d2ebde604ba434b3bbc..abf82dcf017ccad54afb2fd4bc2b725df62e04ca 100644
--- a/auto/Wrap/doxygenDevice.i
+++ b/auto/Wrap/doxygenDevice.i
@@ -3527,31 +3527,28 @@ Returns true if area defined by two bins is inside or on border of polygon (more
 // File: classFourierTransform_1_1Workspace.xml
 
 
-// File: namespace_0D115.xml
+// File: namespace_0D113.xml
 
 
-// File: namespace_0D117.xml
+// File: namespace_0D115.xml
 
 
-// File: namespace_0D121.xml
+// File: namespace_0D125.xml
 
 
-// File: namespace_0D127.xml
+// File: namespace_0D33.xml
 
 
-// File: namespace_0D35.xml
+// File: namespace_0D56.xml
 
 
 // File: namespace_0D58.xml
 
 
-// File: namespace_0D60.xml
-
+// File: namespace_0D62.xml
 
-// File: namespace_0D64.xml
 
-
-// File: namespace_0D70.xml
+// File: namespace_0D68.xml
 
 
 // File: namespaceArrayUtils.xml
@@ -3665,23 +3662,6 @@ Parse double values from string to vector of double.
 ";
 
 
-// File: namespaceDetectorFunctions.xml
-%feature("docstring")  DetectorFunctions::hasSameDimensions "bool DetectorFunctions::hasSameDimensions(const IDetector &detector, const OutputData< double > &data)
-
-Returns true if the data has same axes size (nx,ny) with the detector. 
-";
-
-%feature("docstring")  DetectorFunctions::axesToString "std::string DetectorFunctions::axesToString(const IDetector &detector)
-
-Returns string representation of axes dimension in the form \"(nx,ny)\". 
-";
-
-%feature("docstring")  DetectorFunctions::axesToString "std::string DetectorFunctions::axesToString(const OutputData< double > &data)
-
-Returns string representation of axes dimension in the form \"(nx,ny)\". 
-";
-
-
 // File: namespaceIntensityDataFunctions.xml
 %feature("docstring")  IntensityDataFunctions::RelativeDifference "double IntensityDataFunctions::RelativeDifference(const SimulationResult &dat, const SimulationResult &ref)
 
@@ -3862,12 +3842,6 @@ make Swappable
 // File: DetectorContext_8h.xml
 
 
-// File: DetectorFunctions_8cpp.xml
-
-
-// File: DetectorFunctions_8h.xml
-
-
 // File: DetectorMask_8cpp.xml
 
 
diff --git a/auto/Wrap/doxygenParam.i b/auto/Wrap/doxygenParam.i
index a36d9568e1bb4898121b68ebe624e0a4fed88f27..30d6a649091be31762250333a0e39025016cec7f 100644
--- a/auto/Wrap/doxygenParam.i
+++ b/auto/Wrap/doxygenParam.i
@@ -1615,10 +1615,10 @@ C++ includes: Unit.h
 ";
 
 
-// File: namespace_0D12.xml
+// File: namespace_0D10.xml
 
 
-// File: namespace_0D16.xml
+// File: namespace_0D14.xml
 
 
 // File: namespace_0D24.xml
@@ -1670,12 +1670,6 @@ Prints RealLimits in the form of argument (in the context of  ParameterDistribut
 // File: IParameterized_8h.xml
 
 
-// File: IterationStrategy_8cpp.xml
-
-
-// File: IterationStrategy_8h.xml
-
-
 // File: ParameterPool_8cpp.xml
 
 
@@ -1741,6 +1735,12 @@ Prints RealLimits in the form of argument (in the context of  ParameterDistribut
 ";
 
 
+// File: IterationStrategy_8cpp.xml
+
+
+// File: IterationStrategy_8h.xml
+
+
 // File: NodeIterator_8cpp.xml
 
 
diff --git a/auto/Wrap/doxygenSample.i b/auto/Wrap/doxygenSample.i
index 310477d6dbbd6449874ac2619da46ed8bcdb4257..daff8ab1b0cc6d12cc09d128dbfe9b6dac86049d 100644
--- a/auto/Wrap/doxygenSample.i
+++ b/auto/Wrap/doxygenSample.i
@@ -670,7 +670,7 @@ Returns a clone of this  ISample object.
 %feature("docstring")  FormFactorBAPol::accept "void FormFactorBAPol::accept(INodeVisitor *visitor) const override
 ";
 
-%feature("docstring")  FormFactorBAPol::setAmbientMaterial "void FormFactorBAPol::setAmbientMaterial(Material material) override
+%feature("docstring")  FormFactorBAPol::setAmbientMaterial "void FormFactorBAPol::setAmbientMaterial(const Material &material) override
 
 Passes the material in which this particle is embedded. 
 ";
@@ -1013,7 +1013,7 @@ Returns the z-coordinate of the lowest point in this shape after a given rotatio
 Returns the z-coordinate of the lowest point in this shape after a given rotation. 
 ";
 
-%feature("docstring")  FormFactorCoreShell::setAmbientMaterial "void FormFactorCoreShell::setAmbientMaterial(Material material) override final
+%feature("docstring")  FormFactorCoreShell::setAmbientMaterial "void FormFactorCoreShell::setAmbientMaterial(const Material &material) override final
 
 Passes the material in which this particle is embedded. 
 ";
@@ -1120,7 +1120,7 @@ Returns a clone of this  ISample object.
 %feature("docstring")  FormFactorCrystal::accept "void FormFactorCrystal::accept(INodeVisitor *visitor) const override final
 ";
 
-%feature("docstring")  FormFactorCrystal::setAmbientMaterial "void FormFactorCrystal::setAmbientMaterial(Material material) override
+%feature("docstring")  FormFactorCrystal::setAmbientMaterial "void FormFactorCrystal::setAmbientMaterial(const Material &material) override
 
 Passes the material in which this particle is embedded. 
 ";
@@ -1252,12 +1252,12 @@ Returns a clone of this  ISample object.
 %feature("docstring")  FormFactorDecoratorMaterial::accept "void FormFactorDecoratorMaterial::accept(INodeVisitor *visitor) const override final
 ";
 
-%feature("docstring")  FormFactorDecoratorMaterial::setMaterial "void FormFactorDecoratorMaterial::setMaterial(Material material)
+%feature("docstring")  FormFactorDecoratorMaterial::setMaterial "void FormFactorDecoratorMaterial::setMaterial(const Material &material)
 
 Sets the material of the scatterer. 
 ";
 
-%feature("docstring")  FormFactorDecoratorMaterial::setAmbientMaterial "void FormFactorDecoratorMaterial::setAmbientMaterial(Material material) override
+%feature("docstring")  FormFactorDecoratorMaterial::setAmbientMaterial "void FormFactorDecoratorMaterial::setAmbientMaterial(const Material &material) override
 
 Sets the ambient material. 
 ";
@@ -1449,7 +1449,7 @@ Returns a clone of this  ISample object.
 %feature("docstring")  FormFactorDWBA::accept "void FormFactorDWBA::accept(INodeVisitor *visitor) const override
 ";
 
-%feature("docstring")  FormFactorDWBA::setAmbientMaterial "void FormFactorDWBA::setAmbientMaterial(Material material) override
+%feature("docstring")  FormFactorDWBA::setAmbientMaterial "void FormFactorDWBA::setAmbientMaterial(const Material &material) override
 
 Passes the material in which this particle is embedded. 
 ";
@@ -1507,7 +1507,7 @@ Returns a clone of this  ISample object.
 %feature("docstring")  FormFactorDWBAPol::accept "void FormFactorDWBAPol::accept(INodeVisitor *visitor) const override
 ";
 
-%feature("docstring")  FormFactorDWBAPol::setAmbientMaterial "void FormFactorDWBAPol::setAmbientMaterial(Material material) override
+%feature("docstring")  FormFactorDWBAPol::setAmbientMaterial "void FormFactorDWBAPol::setAmbientMaterial(const Material &material) override
 
 Passes the material in which this particle is embedded. 
 ";
@@ -2308,7 +2308,7 @@ Returns the z-coordinate of the lowest point in this shape after a given rotatio
 %feature("docstring")  FormFactorWeighted::addFormFactor "void FormFactorWeighted::addFormFactor(const IFormFactor &form_factor, double weight=1.0)
 ";
 
-%feature("docstring")  FormFactorWeighted::setAmbientMaterial "void FormFactorWeighted::setAmbientMaterial(Material material) override final
+%feature("docstring")  FormFactorWeighted::setAmbientMaterial "void FormFactorWeighted::setAmbientMaterial(const Material &material) override final
 
 Passes the material in which this particle is embedded. 
 ";
@@ -3158,7 +3158,7 @@ Returns a clone of this  ISample object.
 Creates a (possibly sliced) form factor with the given rotation and translation. 
 ";
 
-%feature("docstring")  IFormFactor::setAmbientMaterial "virtual void IFormFactor::setAmbientMaterial(Material)=0
+%feature("docstring")  IFormFactor::setAmbientMaterial "virtual void IFormFactor::setAmbientMaterial(const Material &)=0
 
 Passes the material in which this particle is embedded. 
 ";
@@ -3223,7 +3223,7 @@ C++ includes: IFormFactorBorn.h
 Returns a clone of this  ISample object. 
 ";
 
-%feature("docstring")  IFormFactorBorn::setAmbientMaterial "void IFormFactorBorn::setAmbientMaterial(Material) override
+%feature("docstring")  IFormFactorBorn::setAmbientMaterial "void IFormFactorBorn::setAmbientMaterial(const Material &) override
 
 Passes the material in which this particle is embedded. 
 ";
@@ -3275,7 +3275,7 @@ C++ includes: IFormFactorDecorator.h
 Returns a clone of this  ISample object. 
 ";
 
-%feature("docstring")  IFormFactorDecorator::setAmbientMaterial "void IFormFactorDecorator::setAmbientMaterial(Material material) override
+%feature("docstring")  IFormFactorDecorator::setAmbientMaterial "void IFormFactorDecorator::setAmbientMaterial(const Material &material) override
 
 Passes the material in which this particle is embedded. 
 ";
diff --git a/auto/Wrap/libBornAgainCore.py b/auto/Wrap/libBornAgainCore.py
index 5d366b5c003431c332d63358299e261899c5ddfa..c41db1ffaf07126f629873f3152640646035f973 100644
--- a/auto/Wrap/libBornAgainCore.py
+++ b/auto/Wrap/libBornAgainCore.py
@@ -3458,22 +3458,22 @@ class Simulation(libBornAgainBase.ICloneable, libBornAgainParam.INode):
         """
         return _libBornAgainCore.Simulation_runMPISimulation(self)
 
-    def setInstrument(self, instrument):
+    def setInstrument(self, instrument_):
         r"""
-        setInstrument(Simulation self, Instrument const & instrument)
-        void Simulation::setInstrument(const Instrument &instrument)
+        setInstrument(Simulation self, Instrument const & instrument_)
+        void Simulation::setInstrument(const Instrument &instrument_)
 
         """
-        return _libBornAgainCore.Simulation_setInstrument(self, instrument)
+        return _libBornAgainCore.Simulation_setInstrument(self, instrument_)
 
-    def getInstrument(self, *args):
+    def instrument(self, *args):
         r"""
-        getInstrument(Simulation self) -> Instrument const
-        getInstrument(Simulation self) -> Instrument &
-        Instrument& Simulation::getInstrument()
+        instrument(Simulation self) -> Instrument const
+        instrument(Simulation self) -> Instrument &
+        Instrument& Simulation::instrument()
 
         """
-        return _libBornAgainCore.Simulation_getInstrument(self, *args)
+        return _libBornAgainCore.Simulation_instrument(self, *args)
 
     def setBeamIntensity(self, intensity):
         r"""
@@ -4192,13 +4192,13 @@ class IBackground(libBornAgainBase.ICloneable, libBornAgainParam.INode):
         """
         return _libBornAgainCore.IBackground_clone(self)
 
-    def addBackGround(self, element):
+    def addBackground(self, element):
         r"""
-        addBackGround(IBackground self, double element) -> double
-        virtual double IBackground::addBackGround(double element) const =0
+        addBackground(IBackground self, double element) -> double
+        virtual double IBackground::addBackground(double element) const =0
 
         """
-        return _libBornAgainCore.IBackground_addBackGround(self, element)
+        return _libBornAgainCore.IBackground_addBackground(self, element)
 
 # Register IBackground in _libBornAgainCore:
 _libBornAgainCore.IBackground_swigregister(IBackground)
@@ -4249,13 +4249,13 @@ class ConstantBackground(IBackground):
         """
         return _libBornAgainCore.ConstantBackground_accept(self, visitor)
 
-    def addBackGround(self, intensity):
+    def addBackground(self, intensity):
         r"""
-        addBackGround(ConstantBackground self, double intensity) -> double
-        double ConstantBackground::addBackGround(double intensity) const override final
+        addBackground(ConstantBackground self, double intensity) -> double
+        double ConstantBackground::addBackground(double intensity) const override final
 
         """
-        return _libBornAgainCore.ConstantBackground_addBackGround(self, intensity)
+        return _libBornAgainCore.ConstantBackground_addBackground(self, intensity)
     __swig_destroy__ = _libBornAgainCore.delete_ConstantBackground
 
 # Register ConstantBackground in _libBornAgainCore:
@@ -4298,13 +4298,13 @@ class PoissonNoiseBackground(IBackground):
         """
         return _libBornAgainCore.PoissonNoiseBackground_accept(self, visitor)
 
-    def addBackGround(self, intensity):
+    def addBackground(self, intensity):
         r"""
-        addBackGround(PoissonNoiseBackground self, double intensity) -> double
-        double PoissonNoiseBackground::addBackGround(double intensity) const override final
+        addBackground(PoissonNoiseBackground self, double intensity) -> double
+        double PoissonNoiseBackground::addBackground(double intensity) const override final
 
         """
-        return _libBornAgainCore.PoissonNoiseBackground_addBackGround(self, intensity)
+        return _libBornAgainCore.PoissonNoiseBackground_addBackground(self, intensity)
     __swig_destroy__ = _libBornAgainCore.delete_PoissonNoiseBackground
 
 # Register PoissonNoiseBackground in _libBornAgainCore:
diff --git a/auto/Wrap/libBornAgainCore_wrap.cpp b/auto/Wrap/libBornAgainCore_wrap.cpp
index 39b5d369bf7ebcdc6972da30044e9c5fe2a21bb0..96958905c385496a3168194a2696bbab7f2f5074 100644
--- a/auto/Wrap/libBornAgainCore_wrap.cpp
+++ b/auto/Wrap/libBornAgainCore_wrap.cpp
@@ -37932,7 +37932,7 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_Simulation_getInstrument__SWIG_0(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) {
+SWIGINTERN PyObject *_wrap_Simulation_instrument__SWIG_0(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) {
   PyObject *resultobj = 0;
   Simulation *arg1 = (Simulation *) 0 ;
   void *argp1 = 0 ;
@@ -37942,10 +37942,10 @@ SWIGINTERN PyObject *_wrap_Simulation_getInstrument__SWIG_0(PyObject *SWIGUNUSED
   if ((nobjs < 1) || (nobjs > 1)) SWIG_fail;
   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_Simulation, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Simulation_getInstrument" "', argument " "1"" of type '" "Simulation const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Simulation_instrument" "', argument " "1"" of type '" "Simulation const *""'"); 
   }
   arg1 = reinterpret_cast< Simulation * >(argp1);
-  result = (Instrument *) &((Simulation const *)arg1)->getInstrument();
+  result = (Instrument *) &((Simulation const *)arg1)->instrument();
   resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Instrument, 0 |  0 );
   return resultobj;
 fail:
@@ -37953,7 +37953,7 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_Simulation_getInstrument__SWIG_1(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) {
+SWIGINTERN PyObject *_wrap_Simulation_instrument__SWIG_1(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) {
   PyObject *resultobj = 0;
   Simulation *arg1 = (Simulation *) 0 ;
   void *argp1 = 0 ;
@@ -37963,10 +37963,10 @@ SWIGINTERN PyObject *_wrap_Simulation_getInstrument__SWIG_1(PyObject *SWIGUNUSED
   if ((nobjs < 1) || (nobjs > 1)) SWIG_fail;
   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_Simulation, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Simulation_getInstrument" "', argument " "1"" of type '" "Simulation *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Simulation_instrument" "', argument " "1"" of type '" "Simulation *""'"); 
   }
   arg1 = reinterpret_cast< Simulation * >(argp1);
-  result = (Instrument *) &(arg1)->getInstrument();
+  result = (Instrument *) &(arg1)->instrument();
   resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Instrument, 0 |  0 );
   return resultobj;
 fail:
@@ -37974,13 +37974,13 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_Simulation_getInstrument(PyObject *self, PyObject *args) {
+SWIGINTERN PyObject *_wrap_Simulation_instrument(PyObject *self, PyObject *args) {
   Py_ssize_t argc;
   PyObject *argv[2] = {
     0
   };
   
-  if (!(argc = SWIG_Python_UnpackTuple(args, "Simulation_getInstrument", 0, 1, argv))) SWIG_fail;
+  if (!(argc = SWIG_Python_UnpackTuple(args, "Simulation_instrument", 0, 1, argv))) SWIG_fail;
   --argc;
   if (argc == 1) {
     int _v;
@@ -37988,7 +37988,7 @@ SWIGINTERN PyObject *_wrap_Simulation_getInstrument(PyObject *self, PyObject *ar
     int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Simulation, 0);
     _v = SWIG_CheckState(res);
     if (_v) {
-      return _wrap_Simulation_getInstrument__SWIG_1(self, argc, argv);
+      return _wrap_Simulation_instrument__SWIG_1(self, argc, argv);
     }
   }
   if (argc == 1) {
@@ -37997,15 +37997,15 @@ SWIGINTERN PyObject *_wrap_Simulation_getInstrument(PyObject *self, PyObject *ar
     int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Simulation, 0);
     _v = SWIG_CheckState(res);
     if (_v) {
-      return _wrap_Simulation_getInstrument__SWIG_0(self, argc, argv);
+      return _wrap_Simulation_instrument__SWIG_0(self, argc, argv);
     }
   }
   
 fail:
-  SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'Simulation_getInstrument'.\n"
+  SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'Simulation_instrument'.\n"
     "  Possible C/C++ prototypes are:\n"
-    "    Simulation::getInstrument() const\n"
-    "    Simulation::getInstrument()\n");
+    "    Simulation::instrument() const\n"
+    "    Simulation::instrument()\n");
   return 0;
 }
 
@@ -40641,7 +40641,7 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_IBackground_addBackGround(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_IBackground_addBackground(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   IBackground *arg1 = (IBackground *) 0 ;
   double arg2 ;
@@ -40652,18 +40652,18 @@ SWIGINTERN PyObject *_wrap_IBackground_addBackGround(PyObject *SWIGUNUSEDPARM(se
   PyObject *swig_obj[2] ;
   double result;
   
-  if (!SWIG_Python_UnpackTuple(args, "IBackground_addBackGround", 2, 2, swig_obj)) SWIG_fail;
+  if (!SWIG_Python_UnpackTuple(args, "IBackground_addBackground", 2, 2, swig_obj)) SWIG_fail;
   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_IBackground, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IBackground_addBackGround" "', argument " "1"" of type '" "IBackground const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IBackground_addBackground" "', argument " "1"" of type '" "IBackground const *""'"); 
   }
   arg1 = reinterpret_cast< IBackground * >(argp1);
   ecode2 = SWIG_AsVal_double(swig_obj[1], &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IBackground_addBackGround" "', argument " "2"" of type '" "double""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IBackground_addBackground" "', argument " "2"" of type '" "double""'");
   } 
   arg2 = static_cast< double >(val2);
-  result = (double)((IBackground const *)arg1)->addBackGround(arg2);
+  result = (double)((IBackground const *)arg1)->addBackground(arg2);
   resultobj = SWIG_From_double(static_cast< double >(result));
   return resultobj;
 fail:
@@ -40833,7 +40833,7 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_ConstantBackground_addBackGround(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_ConstantBackground_addBackground(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   ConstantBackground *arg1 = (ConstantBackground *) 0 ;
   double arg2 ;
@@ -40844,18 +40844,18 @@ SWIGINTERN PyObject *_wrap_ConstantBackground_addBackGround(PyObject *SWIGUNUSED
   PyObject *swig_obj[2] ;
   double result;
   
-  if (!SWIG_Python_UnpackTuple(args, "ConstantBackground_addBackGround", 2, 2, swig_obj)) SWIG_fail;
+  if (!SWIG_Python_UnpackTuple(args, "ConstantBackground_addBackground", 2, 2, swig_obj)) SWIG_fail;
   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ConstantBackground, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ConstantBackground_addBackGround" "', argument " "1"" of type '" "ConstantBackground const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ConstantBackground_addBackground" "', argument " "1"" of type '" "ConstantBackground const *""'"); 
   }
   arg1 = reinterpret_cast< ConstantBackground * >(argp1);
   ecode2 = SWIG_AsVal_double(swig_obj[1], &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ConstantBackground_addBackGround" "', argument " "2"" of type '" "double""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ConstantBackground_addBackground" "', argument " "2"" of type '" "double""'");
   } 
   arg2 = static_cast< double >(val2);
-  result = (double)((ConstantBackground const *)arg1)->addBackGround(arg2);
+  result = (double)((ConstantBackground const *)arg1)->addBackground(arg2);
   resultobj = SWIG_From_double(static_cast< double >(result));
   return resultobj;
 fail:
@@ -40961,7 +40961,7 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_PoissonNoiseBackground_addBackGround(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_PoissonNoiseBackground_addBackground(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   PoissonNoiseBackground *arg1 = (PoissonNoiseBackground *) 0 ;
   double arg2 ;
@@ -40972,18 +40972,18 @@ SWIGINTERN PyObject *_wrap_PoissonNoiseBackground_addBackGround(PyObject *SWIGUN
   PyObject *swig_obj[2] ;
   double result;
   
-  if (!SWIG_Python_UnpackTuple(args, "PoissonNoiseBackground_addBackGround", 2, 2, swig_obj)) SWIG_fail;
+  if (!SWIG_Python_UnpackTuple(args, "PoissonNoiseBackground_addBackground", 2, 2, swig_obj)) SWIG_fail;
   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_PoissonNoiseBackground, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PoissonNoiseBackground_addBackGround" "', argument " "1"" of type '" "PoissonNoiseBackground const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PoissonNoiseBackground_addBackground" "', argument " "1"" of type '" "PoissonNoiseBackground const *""'"); 
   }
   arg1 = reinterpret_cast< PoissonNoiseBackground * >(argp1);
   ecode2 = SWIG_AsVal_double(swig_obj[1], &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "PoissonNoiseBackground_addBackGround" "', argument " "2"" of type '" "double""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "PoissonNoiseBackground_addBackground" "', argument " "2"" of type '" "double""'");
   } 
   arg2 = static_cast< double >(val2);
-  result = (double)((PoissonNoiseBackground const *)arg1)->addBackGround(arg2);
+  result = (double)((PoissonNoiseBackground const *)arg1)->addBackground(arg2);
   resultobj = SWIG_From_double(static_cast< double >(result));
   return resultobj;
 fail:
@@ -42476,14 +42476,14 @@ static PyMethodDef SwigMethods[] = {
 		"\n"
 		""},
 	 { "Simulation_setInstrument", _wrap_Simulation_setInstrument, METH_VARARGS, "\n"
-		"Simulation_setInstrument(Simulation self, Instrument const & instrument)\n"
-		"void Simulation::setInstrument(const Instrument &instrument)\n"
+		"Simulation_setInstrument(Simulation self, Instrument const & instrument_)\n"
+		"void Simulation::setInstrument(const Instrument &instrument_)\n"
 		"\n"
 		""},
-	 { "Simulation_getInstrument", _wrap_Simulation_getInstrument, METH_VARARGS, "\n"
-		"Simulation_getInstrument(Simulation self) -> Instrument const\n"
-		"Simulation_getInstrument(Simulation self) -> Instrument &\n"
-		"Instrument& Simulation::getInstrument()\n"
+	 { "Simulation_instrument", _wrap_Simulation_instrument, METH_VARARGS, "\n"
+		"Simulation_instrument(Simulation self) -> Instrument const\n"
+		"Simulation_instrument(Simulation self) -> Instrument &\n"
+		"Instrument& Simulation::instrument()\n"
 		"\n"
 		""},
 	 { "Simulation_setBeamIntensity", _wrap_Simulation_setBeamIntensity, METH_VARARGS, "\n"
@@ -42943,9 +42943,9 @@ static PyMethodDef SwigMethods[] = {
 		"virtual IBackground* IBackground::clone() const =0\n"
 		"\n"
 		""},
-	 { "IBackground_addBackGround", _wrap_IBackground_addBackGround, METH_VARARGS, "\n"
-		"IBackground_addBackGround(IBackground self, double element) -> double\n"
-		"virtual double IBackground::addBackGround(double element) const =0\n"
+	 { "IBackground_addBackground", _wrap_IBackground_addBackground, METH_VARARGS, "\n"
+		"IBackground_addBackground(IBackground self, double element) -> double\n"
+		"virtual double IBackground::addBackground(double element) const =0\n"
 		"\n"
 		""},
 	 { "IBackground_swigregister", IBackground_swigregister, METH_O, NULL},
@@ -42970,9 +42970,9 @@ static PyMethodDef SwigMethods[] = {
 		"void ConstantBackground::accept(INodeVisitor *visitor) const override\n"
 		"\n"
 		""},
-	 { "ConstantBackground_addBackGround", _wrap_ConstantBackground_addBackGround, METH_VARARGS, "\n"
-		"ConstantBackground_addBackGround(ConstantBackground self, double intensity) -> double\n"
-		"double ConstantBackground::addBackGround(double intensity) const override final\n"
+	 { "ConstantBackground_addBackground", _wrap_ConstantBackground_addBackground, METH_VARARGS, "\n"
+		"ConstantBackground_addBackground(ConstantBackground self, double intensity) -> double\n"
+		"double ConstantBackground::addBackground(double intensity) const override final\n"
 		"\n"
 		""},
 	 { "delete_ConstantBackground", _wrap_delete_ConstantBackground, METH_O, "delete_ConstantBackground(ConstantBackground self)"},
@@ -42993,9 +42993,9 @@ static PyMethodDef SwigMethods[] = {
 		"void PoissonNoiseBackground::accept(INodeVisitor *visitor) const override\n"
 		"\n"
 		""},
-	 { "PoissonNoiseBackground_addBackGround", _wrap_PoissonNoiseBackground_addBackGround, METH_VARARGS, "\n"
-		"PoissonNoiseBackground_addBackGround(PoissonNoiseBackground self, double intensity) -> double\n"
-		"double PoissonNoiseBackground::addBackGround(double intensity) const override final\n"
+	 { "PoissonNoiseBackground_addBackground", _wrap_PoissonNoiseBackground_addBackground, METH_VARARGS, "\n"
+		"PoissonNoiseBackground_addBackground(PoissonNoiseBackground self, double intensity) -> double\n"
+		"double PoissonNoiseBackground::addBackground(double intensity) const override final\n"
 		"\n"
 		""},
 	 { "delete_PoissonNoiseBackground", _wrap_delete_PoissonNoiseBackground, METH_O, "delete_PoissonNoiseBackground(PoissonNoiseBackground self)"},
diff --git a/auto/Wrap/libBornAgainSample.py b/auto/Wrap/libBornAgainSample.py
index 885d83c31b02ef0ffe03b2aa8c0bf095cc522a71..37c5376fad973d2453cf5c7b2b7f0bbeb80b8726 100644
--- a/auto/Wrap/libBornAgainSample.py
+++ b/auto/Wrap/libBornAgainSample.py
@@ -3275,7 +3275,7 @@ class IFormFactor(ISample):
     def setAmbientMaterial(self, arg0):
         r"""
         setAmbientMaterial(IFormFactor self, Material arg0)
-        virtual void IFormFactor::setAmbientMaterial(Material)=0
+        virtual void IFormFactor::setAmbientMaterial(const Material &)=0
 
         Passes the material in which this particle is embedded. 
 
@@ -3397,7 +3397,7 @@ class IFormFactorBorn(IFormFactor):
     def setAmbientMaterial(self, arg0):
         r"""
         setAmbientMaterial(IFormFactorBorn self, Material arg0)
-        void IFormFactorBorn::setAmbientMaterial(Material) override
+        void IFormFactorBorn::setAmbientMaterial(const Material &) override
 
         Passes the material in which this particle is embedded. 
 
@@ -3523,7 +3523,7 @@ class IFormFactorDecorator(IFormFactor):
     def setAmbientMaterial(self, material):
         r"""
         setAmbientMaterial(IFormFactorDecorator self, Material material)
-        void IFormFactorDecorator::setAmbientMaterial(Material material) override
+        void IFormFactorDecorator::setAmbientMaterial(const Material &material) override
 
         Passes the material in which this particle is embedded. 
 
@@ -4093,7 +4093,7 @@ class FormFactorCrystal(IFormFactor):
     def setAmbientMaterial(self, material):
         r"""
         setAmbientMaterial(FormFactorCrystal self, Material material)
-        void FormFactorCrystal::setAmbientMaterial(Material material) override
+        void FormFactorCrystal::setAmbientMaterial(const Material &material) override
 
         Passes the material in which this particle is embedded. 
 
@@ -4236,7 +4236,7 @@ class FormFactorWeighted(IFormFactor):
     def setAmbientMaterial(self, material):
         r"""
         setAmbientMaterial(FormFactorWeighted self, Material material)
-        void FormFactorWeighted::setAmbientMaterial(Material material) override final
+        void FormFactorWeighted::setAmbientMaterial(const Material &material) override final
 
         Passes the material in which this particle is embedded. 
 
diff --git a/auto/Wrap/libBornAgainSample_wrap.cpp b/auto/Wrap/libBornAgainSample_wrap.cpp
index 29fe174fff1f73a4d7818581f4479d30135bc6c1..79ad88f16c36bc7469273ae4da6bf47f95721dd0 100644
--- a/auto/Wrap/libBornAgainSample_wrap.cpp
+++ b/auto/Wrap/libBornAgainSample_wrap.cpp
@@ -8053,9 +8053,9 @@ Material const *SwigDirector_IFormFactor::material() const {
 }
 
 
-void SwigDirector_IFormFactor::setAmbientMaterial(Material arg0) {
+void SwigDirector_IFormFactor::setAmbientMaterial(Material const &arg0) {
   swig::SwigVar_PyObject obj0;
-  obj0 = SWIG_NewPointerObj(SWIG_as_voidptr(new Material((const Material &)arg0)), SWIGTYPE_p_Material, SWIG_POINTER_OWN |  0 );
+  obj0 = SWIG_NewPointerObj(SWIG_as_voidptr(&arg0), SWIGTYPE_p_Material,  0 );
   if (!swig_get_self()) {
     Swig::DirectorException::raise("'self' uninitialized, maybe you forgot to call IFormFactor.__init__.");
   }
@@ -8596,9 +8596,9 @@ Material const *SwigDirector_IFormFactorBorn::material() const {
 }
 
 
-void SwigDirector_IFormFactorBorn::setAmbientMaterial(Material arg0) {
+void SwigDirector_IFormFactorBorn::setAmbientMaterial(Material const &arg0) {
   swig::SwigVar_PyObject obj0;
-  obj0 = SWIG_NewPointerObj(SWIG_as_voidptr(new Material((const Material &)arg0)), SWIGTYPE_p_Material, SWIG_POINTER_OWN |  0 );
+  obj0 = SWIG_NewPointerObj(SWIG_as_voidptr(&arg0), SWIGTYPE_p_Material,  0 );
   if (!swig_get_self()) {
     Swig::DirectorException::raise("'self' uninitialized, maybe you forgot to call IFormFactorBorn.__init__.");
   }
@@ -38895,10 +38895,10 @@ fail:
 SWIGINTERN PyObject *_wrap_IFormFactor_setAmbientMaterial(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   IFormFactor *arg1 = (IFormFactor *) 0 ;
-  SwigValueWrapper< Material > arg2 ;
+  Material *arg2 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  void *argp2 ;
+  void *argp2 = 0 ;
   int res2 = 0 ;
   PyObject *swig_obj[2] ;
   Swig::Director *director = 0;
@@ -38910,26 +38910,21 @@ SWIGINTERN PyObject *_wrap_IFormFactor_setAmbientMaterial(PyObject *SWIGUNUSEDPA
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IFormFactor_setAmbientMaterial" "', argument " "1"" of type '" "IFormFactor *""'"); 
   }
   arg1 = reinterpret_cast< IFormFactor * >(argp1);
-  {
-    res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_Material,  0  | 0);
-    if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "IFormFactor_setAmbientMaterial" "', argument " "2"" of type '" "Material""'"); 
-    }  
-    if (!argp2) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "IFormFactor_setAmbientMaterial" "', argument " "2"" of type '" "Material""'");
-    } else {
-      Material * temp = reinterpret_cast< Material * >(argp2);
-      arg2 = *temp;
-      if (SWIG_IsNewObj(res2)) delete temp;
-    }
+  res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_Material,  0  | 0);
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "IFormFactor_setAmbientMaterial" "', argument " "2"" of type '" "Material const &""'"); 
+  }
+  if (!argp2) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "IFormFactor_setAmbientMaterial" "', argument " "2"" of type '" "Material const &""'"); 
   }
+  arg2 = reinterpret_cast< Material * >(argp2);
   director = SWIG_DIRECTOR_CAST(arg1);
   upcall = (director && (director->swig_get_self()==swig_obj[0]));
   try {
     if (upcall) {
       Swig::DirectorPureVirtualException::raise("IFormFactor::setAmbientMaterial");
     } else {
-      (arg1)->setAmbientMaterial(arg2);
+      (arg1)->setAmbientMaterial((Material const &)*arg2);
     }
   } catch (Swig::DirectorException&) {
     SWIG_fail;
@@ -39557,10 +39552,10 @@ fail:
 SWIGINTERN PyObject *_wrap_IFormFactorBorn_setAmbientMaterial(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   IFormFactorBorn *arg1 = (IFormFactorBorn *) 0 ;
-  SwigValueWrapper< Material > arg2 ;
+  Material *arg2 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  void *argp2 ;
+  void *argp2 = 0 ;
   int res2 = 0 ;
   PyObject *swig_obj[2] ;
   Swig::Director *director = 0;
@@ -39572,26 +39567,21 @@ SWIGINTERN PyObject *_wrap_IFormFactorBorn_setAmbientMaterial(PyObject *SWIGUNUS
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IFormFactorBorn_setAmbientMaterial" "', argument " "1"" of type '" "IFormFactorBorn *""'"); 
   }
   arg1 = reinterpret_cast< IFormFactorBorn * >(argp1);
-  {
-    res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_Material,  0  | 0);
-    if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "IFormFactorBorn_setAmbientMaterial" "', argument " "2"" of type '" "Material""'"); 
-    }  
-    if (!argp2) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "IFormFactorBorn_setAmbientMaterial" "', argument " "2"" of type '" "Material""'");
-    } else {
-      Material * temp = reinterpret_cast< Material * >(argp2);
-      arg2 = *temp;
-      if (SWIG_IsNewObj(res2)) delete temp;
-    }
+  res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_Material,  0  | 0);
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "IFormFactorBorn_setAmbientMaterial" "', argument " "2"" of type '" "Material const &""'"); 
   }
+  if (!argp2) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "IFormFactorBorn_setAmbientMaterial" "', argument " "2"" of type '" "Material const &""'"); 
+  }
+  arg2 = reinterpret_cast< Material * >(argp2);
   director = SWIG_DIRECTOR_CAST(arg1);
   upcall = (director && (director->swig_get_self()==swig_obj[0]));
   try {
     if (upcall) {
-      (arg1)->IFormFactorBorn::setAmbientMaterial(arg2);
+      (arg1)->IFormFactorBorn::setAmbientMaterial((Material const &)*arg2);
     } else {
-      (arg1)->setAmbientMaterial(arg2);
+      (arg1)->setAmbientMaterial((Material const &)*arg2);
     }
   } catch (Swig::DirectorException&) {
     SWIG_fail;
@@ -40218,10 +40208,10 @@ fail:
 SWIGINTERN PyObject *_wrap_IFormFactorDecorator_setAmbientMaterial(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   IFormFactorDecorator *arg1 = (IFormFactorDecorator *) 0 ;
-  SwigValueWrapper< Material > arg2 ;
+  Material *arg2 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  void *argp2 ;
+  void *argp2 = 0 ;
   int res2 = 0 ;
   PyObject *swig_obj[2] ;
   
@@ -40231,20 +40221,15 @@ SWIGINTERN PyObject *_wrap_IFormFactorDecorator_setAmbientMaterial(PyObject *SWI
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IFormFactorDecorator_setAmbientMaterial" "', argument " "1"" of type '" "IFormFactorDecorator *""'"); 
   }
   arg1 = reinterpret_cast< IFormFactorDecorator * >(argp1);
-  {
-    res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_Material,  0  | 0);
-    if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "IFormFactorDecorator_setAmbientMaterial" "', argument " "2"" of type '" "Material""'"); 
-    }  
-    if (!argp2) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "IFormFactorDecorator_setAmbientMaterial" "', argument " "2"" of type '" "Material""'");
-    } else {
-      Material * temp = reinterpret_cast< Material * >(argp2);
-      arg2 = *temp;
-      if (SWIG_IsNewObj(res2)) delete temp;
-    }
+  res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_Material,  0  | 0);
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "IFormFactorDecorator_setAmbientMaterial" "', argument " "2"" of type '" "Material const &""'"); 
+  }
+  if (!argp2) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "IFormFactorDecorator_setAmbientMaterial" "', argument " "2"" of type '" "Material const &""'"); 
   }
-  (arg1)->setAmbientMaterial(arg2);
+  arg2 = reinterpret_cast< Material * >(argp2);
+  (arg1)->setAmbientMaterial((Material const &)*arg2);
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -42063,10 +42048,10 @@ fail:
 SWIGINTERN PyObject *_wrap_FormFactorCrystal_setAmbientMaterial(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   FormFactorCrystal *arg1 = (FormFactorCrystal *) 0 ;
-  SwigValueWrapper< Material > arg2 ;
+  Material *arg2 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  void *argp2 ;
+  void *argp2 = 0 ;
   int res2 = 0 ;
   PyObject *swig_obj[2] ;
   
@@ -42076,20 +42061,15 @@ SWIGINTERN PyObject *_wrap_FormFactorCrystal_setAmbientMaterial(PyObject *SWIGUN
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "FormFactorCrystal_setAmbientMaterial" "', argument " "1"" of type '" "FormFactorCrystal *""'"); 
   }
   arg1 = reinterpret_cast< FormFactorCrystal * >(argp1);
-  {
-    res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_Material,  0  | 0);
-    if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "FormFactorCrystal_setAmbientMaterial" "', argument " "2"" of type '" "Material""'"); 
-    }  
-    if (!argp2) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "FormFactorCrystal_setAmbientMaterial" "', argument " "2"" of type '" "Material""'");
-    } else {
-      Material * temp = reinterpret_cast< Material * >(argp2);
-      arg2 = *temp;
-      if (SWIG_IsNewObj(res2)) delete temp;
-    }
+  res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_Material,  0  | 0);
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "FormFactorCrystal_setAmbientMaterial" "', argument " "2"" of type '" "Material const &""'"); 
   }
-  (arg1)->setAmbientMaterial(arg2);
+  if (!argp2) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "FormFactorCrystal_setAmbientMaterial" "', argument " "2"" of type '" "Material const &""'"); 
+  }
+  arg2 = reinterpret_cast< Material * >(argp2);
+  (arg1)->setAmbientMaterial((Material const &)*arg2);
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -42552,10 +42532,10 @@ fail:
 SWIGINTERN PyObject *_wrap_FormFactorWeighted_setAmbientMaterial(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   FormFactorWeighted *arg1 = (FormFactorWeighted *) 0 ;
-  SwigValueWrapper< Material > arg2 ;
+  Material *arg2 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  void *argp2 ;
+  void *argp2 = 0 ;
   int res2 = 0 ;
   PyObject *swig_obj[2] ;
   
@@ -42565,20 +42545,15 @@ SWIGINTERN PyObject *_wrap_FormFactorWeighted_setAmbientMaterial(PyObject *SWIGU
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "FormFactorWeighted_setAmbientMaterial" "', argument " "1"" of type '" "FormFactorWeighted *""'"); 
   }
   arg1 = reinterpret_cast< FormFactorWeighted * >(argp1);
-  {
-    res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_Material,  0  | 0);
-    if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "FormFactorWeighted_setAmbientMaterial" "', argument " "2"" of type '" "Material""'"); 
-    }  
-    if (!argp2) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "FormFactorWeighted_setAmbientMaterial" "', argument " "2"" of type '" "Material""'");
-    } else {
-      Material * temp = reinterpret_cast< Material * >(argp2);
-      arg2 = *temp;
-      if (SWIG_IsNewObj(res2)) delete temp;
-    }
+  res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_Material,  0  | 0);
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "FormFactorWeighted_setAmbientMaterial" "', argument " "2"" of type '" "Material const &""'"); 
+  }
+  if (!argp2) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "FormFactorWeighted_setAmbientMaterial" "', argument " "2"" of type '" "Material const &""'"); 
   }
-  (arg1)->setAmbientMaterial(arg2);
+  arg2 = reinterpret_cast< Material * >(argp2);
+  (arg1)->setAmbientMaterial((Material const &)*arg2);
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -72311,7 +72286,7 @@ static PyMethodDef SwigMethods[] = {
 		""},
 	 { "IFormFactor_setAmbientMaterial", _wrap_IFormFactor_setAmbientMaterial, METH_VARARGS, "\n"
 		"IFormFactor_setAmbientMaterial(IFormFactor self, Material arg0)\n"
-		"virtual void IFormFactor::setAmbientMaterial(Material)=0\n"
+		"virtual void IFormFactor::setAmbientMaterial(const Material &)=0\n"
 		"\n"
 		"Passes the material in which this particle is embedded. \n"
 		"\n"
@@ -72381,7 +72356,7 @@ static PyMethodDef SwigMethods[] = {
 		""},
 	 { "IFormFactorBorn_setAmbientMaterial", _wrap_IFormFactorBorn_setAmbientMaterial, METH_VARARGS, "\n"
 		"IFormFactorBorn_setAmbientMaterial(IFormFactorBorn self, Material arg0)\n"
-		"void IFormFactorBorn::setAmbientMaterial(Material) override\n"
+		"void IFormFactorBorn::setAmbientMaterial(const Material &) override\n"
 		"\n"
 		"Passes the material in which this particle is embedded. \n"
 		"\n"
@@ -72451,7 +72426,7 @@ static PyMethodDef SwigMethods[] = {
 		""},
 	 { "IFormFactorDecorator_setAmbientMaterial", _wrap_IFormFactorDecorator_setAmbientMaterial, METH_VARARGS, "\n"
 		"IFormFactorDecorator_setAmbientMaterial(IFormFactorDecorator self, Material material)\n"
-		"void IFormFactorDecorator::setAmbientMaterial(Material material) override\n"
+		"void IFormFactorDecorator::setAmbientMaterial(const Material &material) override\n"
 		"\n"
 		"Passes the material in which this particle is embedded. \n"
 		"\n"
@@ -72762,7 +72737,7 @@ static PyMethodDef SwigMethods[] = {
 		""},
 	 { "FormFactorCrystal_setAmbientMaterial", _wrap_FormFactorCrystal_setAmbientMaterial, METH_VARARGS, "\n"
 		"FormFactorCrystal_setAmbientMaterial(FormFactorCrystal self, Material material)\n"
-		"void FormFactorCrystal::setAmbientMaterial(Material material) override\n"
+		"void FormFactorCrystal::setAmbientMaterial(const Material &material) override\n"
 		"\n"
 		"Passes the material in which this particle is embedded. \n"
 		"\n"
@@ -72854,7 +72829,7 @@ static PyMethodDef SwigMethods[] = {
 		""},
 	 { "FormFactorWeighted_setAmbientMaterial", _wrap_FormFactorWeighted_setAmbientMaterial, METH_VARARGS, "\n"
 		"FormFactorWeighted_setAmbientMaterial(FormFactorWeighted self, Material material)\n"
-		"void FormFactorWeighted::setAmbientMaterial(Material material) override final\n"
+		"void FormFactorWeighted::setAmbientMaterial(const Material &material) override final\n"
 		"\n"
 		"Passes the material in which this particle is embedded. \n"
 		"\n"
diff --git a/auto/Wrap/libBornAgainSample_wrap.h b/auto/Wrap/libBornAgainSample_wrap.h
index 3797445491fd76bbd27c0fad2fae15ef12fa4ce3..d62859035558877e8ed7330fdeca246aa477b6c4 100644
--- a/auto/Wrap/libBornAgainSample_wrap.h
+++ b/auto/Wrap/libBornAgainSample_wrap.h
@@ -81,7 +81,7 @@ public:
     virtual std::vector< INode const *, std::allocator< INode const * > > getChildren() const;
     virtual void setParent(INode const *newParent);
     virtual Material const *material() const;
-    virtual void setAmbientMaterial(Material arg0);
+    virtual void setAmbientMaterial(Material const &arg0);
     virtual complex_t evaluate(WavevectorInfo const &wavevectors) const;
     virtual double volume() const;
     virtual double radialExtension() const;
@@ -146,7 +146,7 @@ public:
     virtual std::vector< INode const *, std::allocator< INode const * > > getChildren() const;
     virtual void setParent(INode const *newParent);
     virtual Material const *material() const;
-    virtual void setAmbientMaterial(Material arg0);
+    virtual void setAmbientMaterial(Material const &arg0);
     virtual complex_t evaluate(WavevectorInfo const &wavevectors) const;
     virtual double volume() const;
     virtual double radialExtension() const;