diff --git a/Core/Simulation/DepthProbeSimulation.cpp b/Core/Simulation/DepthProbeSimulation.cpp
index ae64a8e836db893d03e698c360c8bb1a15a7036e..268a6bc15fbbce3dcd0acd40535418f68e3eaa31 100644
--- a/Core/Simulation/DepthProbeSimulation.cpp
+++ b/Core/Simulation/DepthProbeSimulation.cpp
@@ -166,13 +166,14 @@ std::vector<DepthProbeElement> DepthProbeSimulation::generateDiffuseElements(con
     return result;
 }
 
-std::unique_ptr<IComputation> DepthProbeSimulation::createComputation(
-    const ProcessedSample& re_sample, size_t start, size_t n_elements)
+std::unique_ptr<IComputation>
+DepthProbeSimulation::createComputation(const ProcessedSample& re_sample, size_t start,
+                                        size_t n_elements)
 {
     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>(re_sample, options(), progress(),
-                                                   begin, begin + static_cast<long>(n_elements));
+    return std::make_unique<DepthProbeComputation>(re_sample, options(), progress(), begin,
+                                                   begin + static_cast<long>(n_elements));
 }
 
 void DepthProbeSimulation::validityCheck() const
diff --git a/Core/Simulation/DepthProbeSimulation.h b/Core/Simulation/DepthProbeSimulation.h
index e67a69c8d4cae812b8fd721e66a66a30cd25c1c3..2588e70edd9f84dce6bf62c58370e2a158999a6b 100644
--- a/Core/Simulation/DepthProbeSimulation.h
+++ b/Core/Simulation/DepthProbeSimulation.h
@@ -83,9 +83,8 @@ private:
     //! Generate a single threaded computation for a given range of simulation elements
     //! @param start Index of the first element to include into computation
     //! @param n_elements Number of elements to process
-    std::unique_ptr<IComputation>
-    createComputation(const ProcessedSample& re_sample,
-                                      size_t start, size_t n_elements) override;
+    std::unique_ptr<IComputation> createComputation(const ProcessedSample& re_sample, size_t start,
+                                                    size_t n_elements) override;
 
     //! Checks if simulation data is ready for retrieval.
     void validityCheck() const;
diff --git a/Core/Simulation/ISimulation.cpp b/Core/Simulation/ISimulation.cpp
index 6497fa05f0c9ba927fde99b332d92aeb1f378782..3caba8fe8edbf8c50c08c599a83c875169da93a0 100644
--- a/Core/Simulation/ISimulation.cpp
+++ b/Core/Simulation/ISimulation.cpp
@@ -21,8 +21,8 @@
 #include "Sample/Multilayer/MultilayerUtils.h"
 #include "Sample/SampleBuilderEngine/ISampleBuilder.h"
 #include <gsl/gsl_errno.h>
-#include <thread>
 #include <iostream>
+#include <thread>
 
 namespace {
 
@@ -302,8 +302,8 @@ void ISimulation::addParameterDistribution(const ParameterDistribution& par_dist
 
 //! Runs a single simulation with fixed parameter values.
 //! If desired, the simulation is run in several threads.
-void ISimulation::runSingleSimulation(const ProcessedSample& re_sample,
-                                      size_t batch_start, size_t batch_size, double weight)
+void ISimulation::runSingleSimulation(const ProcessedSample& re_sample, size_t batch_start,
+                                      size_t batch_size, double weight)
 {
     initDiffuseElementVector();
 
@@ -318,8 +318,7 @@ void ISimulation::runSingleSimulation(const ProcessedSample& re_sample,
         const size_t thread_size = getNumberOfElements(n_threads, i_thread, batch_size);
         if (thread_size == 0)
             break;
-        computations.emplace_back(
-            createComputation(re_sample, thread_start, thread_size));
+        computations.emplace_back(createComputation(re_sample, thread_start, thread_size));
     }
     runComputations(computations);
 
diff --git a/Core/Simulation/ISimulation.h b/Core/Simulation/ISimulation.h
index 0e412050c372d95c2e963a1eb5f19af14619b962..d3c7f9fafaa48951fdded80657e3c2c8bc5f5931 100644
--- a/Core/Simulation/ISimulation.h
+++ b/Core/Simulation/ISimulation.h
@@ -123,8 +123,8 @@ protected:
 private:
     void initialize();
 
-    void runSingleSimulation(const ProcessedSample& re_sample,
-                             size_t batch_start, size_t batch_size, double weight = 1.0);
+    void runSingleSimulation(const ProcessedSample& re_sample, size_t batch_start,
+                             size_t batch_size, double weight = 1.0);
 
     //! Generate a single threaded computation for a given range of simulation elements
     //! @param start Index of the first element to include into computation
diff --git a/Resample/Fresnel/IFresnelMap.cpp b/Resample/Fresnel/IFresnelMap.cpp
index 587c9c7712fc2204d333fc97f1ca23b50ec2580d..adda1b58c6261c48ffa972a7bc76ef80bc25453b 100644
--- a/Resample/Fresnel/IFresnelMap.cpp
+++ b/Resample/Fresnel/IFresnelMap.cpp
@@ -13,14 +13,11 @@
 //  ************************************************************************************************
 
 #include "Resample/Fresnel/IFresnelMap.h"
-#include "Base/Pixel/DiffuseElement.h"
-#include "Resample/Flux/IFlux.h"
 #include "Resample/Slice/Slice.h"
 #include "Resample/Slice/SliceStack.h"
 #include "Resample/Specular/ISpecularStrategy.h"
 
-IFresnelMap::IFresnelMap(const SliceStack& stack, std::unique_ptr<ISpecularStrategy>&& strategy,
-                         bool /*useCache*/)
+IFresnelMap::IFresnelMap(const SliceStack& stack, std::unique_ptr<ISpecularStrategy>&& strategy)
     : m_slices(stack), m_strategy(std::move(strategy))
 {
 }
diff --git a/Resample/Fresnel/IFresnelMap.h b/Resample/Fresnel/IFresnelMap.h
index 4a728117e0de880071f7f752992e897b1740c006..a7c4bba208e4cbb8ca45bb51a236cb9d9ae91610 100644
--- a/Resample/Fresnel/IFresnelMap.h
+++ b/Resample/Fresnel/IFresnelMap.h
@@ -33,8 +33,7 @@ class DiffuseElement;
 
 class IFresnelMap {
 public:
-    IFresnelMap(const SliceStack& stack, std::unique_ptr<ISpecularStrategy>&& strategy,
-                bool useCache);
+    IFresnelMap(const SliceStack& stack, std::unique_ptr<ISpecularStrategy>&& strategy);
     virtual ~IFresnelMap();
 
     //! Retrieves the amplitude coefficients for given wavevector and layer.
diff --git a/Resample/Fresnel/MatrixFresnelMap.cpp b/Resample/Fresnel/MatrixFresnelMap.cpp
index d52680f2611d537fc4ab6a8ea4ea8c2e23c7e0d3..a29caa02c8572a099b8277b0ae2bca50e4d49f2f 100644
--- a/Resample/Fresnel/MatrixFresnelMap.cpp
+++ b/Resample/Fresnel/MatrixFresnelMap.cpp
@@ -19,8 +19,8 @@
 #include "Resample/Slice/SliceStack.h"
 
 MatrixFresnelMap::MatrixFresnelMap(const SliceStack& stack,
-                                   std::unique_ptr<ISpecularStrategy>&& strategy, bool useCache)
-    : IFresnelMap(stack, std::move(strategy), useCache)
+                                   std::unique_ptr<ISpecularStrategy>&& strategy)
+    : IFresnelMap(stack, std::move(strategy))
 {
     m_inverted_slices.clear();
     for (Slice slice : m_slices) {
diff --git a/Resample/Fresnel/MatrixFresnelMap.h b/Resample/Fresnel/MatrixFresnelMap.h
index 1946b209f30296c62c80dd41a714c6c24d6224df..10865d267075a26b6b3d50fc825a664fda9b796b 100644
--- a/Resample/Fresnel/MatrixFresnelMap.h
+++ b/Resample/Fresnel/MatrixFresnelMap.h
@@ -33,8 +33,7 @@ class DiffuseElement;
 
 class MatrixFresnelMap : public IFresnelMap {
 public:
-    MatrixFresnelMap(const SliceStack& stack, std::unique_ptr<ISpecularStrategy>&& strategy,
-                     bool useCache);
+    MatrixFresnelMap(const SliceStack& stack, std::unique_ptr<ISpecularStrategy>&& strategy);
     ~MatrixFresnelMap() override;
 
     MatrixFresnelMap(const MatrixFresnelMap& other) = delete;
diff --git a/Resample/Fresnel/ScalarFresnelMap.cpp b/Resample/Fresnel/ScalarFresnelMap.cpp
index cada0aa49af205634370927c0e10f9a7195ca05d..934ff7d14eb26b5e5afc5621c19c82a4dcd1a0da 100644
--- a/Resample/Fresnel/ScalarFresnelMap.cpp
+++ b/Resample/Fresnel/ScalarFresnelMap.cpp
@@ -17,8 +17,8 @@
 #include "Resample/Flux/IFlux.h"
 
 ScalarFresnelMap::ScalarFresnelMap(const SliceStack& stack,
-                                   std::unique_ptr<ISpecularStrategy>&& strategy, bool useCache)
-    : IFresnelMap(stack, std::move(strategy), useCache)
+                                   std::unique_ptr<ISpecularStrategy>&& strategy)
+    : IFresnelMap(stack, std::move(strategy))
 {
 }
 
diff --git a/Resample/Fresnel/ScalarFresnelMap.h b/Resample/Fresnel/ScalarFresnelMap.h
index 031b1787cf2a26f92a735c8127345878985cc8f7..2791faaf6e96a1d651beece1aedbc023c7619bd3 100644
--- a/Resample/Fresnel/ScalarFresnelMap.h
+++ b/Resample/Fresnel/ScalarFresnelMap.h
@@ -33,8 +33,7 @@ class DiffuseElement;
 
 class ScalarFresnelMap : public IFresnelMap {
 public:
-    ScalarFresnelMap(const SliceStack& stack, std::unique_ptr<ISpecularStrategy>&& strategy,
-                     bool useCache);
+    ScalarFresnelMap(const SliceStack& stack, std::unique_ptr<ISpecularStrategy>&& strategy);
     ~ScalarFresnelMap() override;
 
     ScalarFresnelMap(const ScalarFresnelMap& other) = delete;
diff --git a/Resample/Processed/ProcessedSample.cpp b/Resample/Processed/ProcessedSample.cpp
index 9f6208d83f483b7cef0c59e0a163bf50be5b8a4e..9045b9229eeeb754158789d24a6cdac09e07cf28 100644
--- a/Resample/Processed/ProcessedSample.cpp
+++ b/Resample/Processed/ProcessedSample.cpp
@@ -101,18 +101,20 @@ void checkVolumeFractions(const Admixtures& admixtures)
                                  "total volumetric fraction of particles exceeds 1!");
 }
 
-void setAvgMatsInStack(SliceStack& stack, const std::vector<ProcessedLayout>& layouts)
+SliceStack refineStack(const SliceStack& stack, const std::vector<ProcessedLayout>& layouts)
 {
+    SliceStack result = stack;
     for (const ProcessedLayout& layout : layouts) {
         for (const auto& entry : layout.regionMap()) {
             const size_t i_slice = entry.first;
-            if (i_slice == 0 || i_slice == stack.size() - 1)
+            if (i_slice == 0 || i_slice == result.size() - 1)
                 continue; // skip semi-infinite layers
-            const auto slice_mat = stack[i_slice].material();
+            const auto slice_mat = result[i_slice].material();
             checkVolumeFractions(entry.second);
-            stack[i_slice].setMaterial(createAveragedMaterial(slice_mat, entry.second));
+            result[i_slice].setMaterial(createAveragedMaterial(slice_mat, entry.second));
         }
     }
+    return result;
 }
 
 //! Returns a SliceStack that refines the layer structure of sample,
@@ -203,18 +205,14 @@ std::unique_ptr<IFresnelMap> fresnelify(const MultiLayer& sample, const SliceSta
                                         const std::vector<ProcessedLayout>& layouts,
                                         const SimulationOptions& options)
 {
-    SliceStack fresnelStack = slices;
-    bool useCache = !options.isIntegrate();
-    if (options.useAvgMaterials()) // modify fresnelStack
-        setAvgMatsInStack(fresnelStack, layouts);
+    SliceStack fresnelStack = options.useAvgMaterials() ? refineStack(slices, layouts) : slices;
 
     if (slices.containsMagneticMaterial())
         return std::make_unique<MatrixFresnelMap>(
             fresnelStack,
-            SampleUtils::SpecularStrategyBuilder::buildMagnetic(sample.roughnessModel()), useCache);
+            SampleUtils::SpecularStrategyBuilder::buildMagnetic(sample.roughnessModel()));
     return std::make_unique<ScalarFresnelMap>(
-        fresnelStack, SampleUtils::SpecularStrategyBuilder::buildScalar(sample.roughnessModel()),
-        useCache);
+        fresnelStack, SampleUtils::SpecularStrategyBuilder::buildScalar(sample.roughnessModel()));
 }
 
 } // namespace
diff --git a/auto/Wrap/doxygenResample.i b/auto/Wrap/doxygenResample.i
index 6b9dab45b4fe2825ee04fd42252125352c6c3e04..cac0f79a4e32575eabf8292d8d852ea3f8443903 100644
--- a/auto/Wrap/doxygenResample.i
+++ b/auto/Wrap/doxygenResample.i
@@ -129,12 +129,6 @@ C++ includes: DecouplingApproximationStrategy.h
 ";
 
 
-// File: classScalarFresnelMap_1_1Hash2Doubles.xml
-
-
-// File: classMatrixFresnelMap_1_1HashKVector.xml
-
-
 // File: classIComputeFF.xml
 %feature("docstring") IComputeFF "
 
@@ -262,7 +256,7 @@ Holds all information that is needed to compute the  IFlux that characterize an
 C++ includes: IFresnelMap.h
 ";
 
-%feature("docstring")  IFresnelMap::IFresnelMap "IFresnelMap::IFresnelMap(const SliceStack &stack, std::unique_ptr< ISpecularStrategy > &&strategy, bool useCache)
+%feature("docstring")  IFresnelMap::IFresnelMap "IFresnelMap::IFresnelMap(const SliceStack &stack, std::unique_ptr< ISpecularStrategy > &&strategy)
 ";
 
 %feature("docstring")  IFresnelMap::~IFresnelMap "IFresnelMap::~IFresnelMap()
@@ -428,7 +422,7 @@ Implementation of  IFresnelMap for matrix valued reflection/transmission coeffic
 C++ includes: MatrixFresnelMap.h
 ";
 
-%feature("docstring")  MatrixFresnelMap::MatrixFresnelMap "MatrixFresnelMap::MatrixFresnelMap(const SliceStack &stack, std::unique_ptr< ISpecularStrategy > &&strategy, bool useCache)
+%feature("docstring")  MatrixFresnelMap::MatrixFresnelMap "MatrixFresnelMap::MatrixFresnelMap(const SliceStack &stack, std::unique_ptr< ISpecularStrategy > &&strategy)
 ";
 
 %feature("docstring")  MatrixFresnelMap::~MatrixFresnelMap "MatrixFresnelMap::~MatrixFresnelMap() override
@@ -619,7 +613,7 @@ Implementation of  IFresnelMap for scalar valued reflection/transmission coeffic
 C++ includes: ScalarFresnelMap.h
 ";
 
-%feature("docstring")  ScalarFresnelMap::ScalarFresnelMap "ScalarFresnelMap::ScalarFresnelMap(const SliceStack &stack, std::unique_ptr< ISpecularStrategy > &&strategy, bool useCache)
+%feature("docstring")  ScalarFresnelMap::ScalarFresnelMap "ScalarFresnelMap::ScalarFresnelMap(const SliceStack &stack, std::unique_ptr< ISpecularStrategy > &&strategy)
 ";
 
 %feature("docstring")  ScalarFresnelMap::~ScalarFresnelMap "ScalarFresnelMap::~ScalarFresnelMap() override