diff --git a/Base/CMakeLists.txt b/Base/CMakeLists.txt
index 9a2792d6913ec2c1fa12bc6ae3b3776fb128f5d9..29c2b65224e753150845f283f210974e2570f2ca 100644
--- a/Base/CMakeLists.txt
+++ b/Base/CMakeLists.txt
@@ -12,7 +12,7 @@ file(GLOB include_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} */*.h)
 
 # --- make the library ---
 
-MakeLib(${name} ${lib} ${CMAKE_CURRENT_BINARY_DIR}/Wrap)
+MakeLib(${name} ${lib} ${CMAKE_CURRENT_BINARY_DIR}/Wrap ${BORNAGAIN_PYTHON})
 
 set(${lib}_LIBRARY ${lib} PARENT_SCOPE)
 
@@ -24,9 +24,9 @@ target_include_directories(${lib}
     PUBLIC ${CMAKE_SOURCE_DIR} ${GSL_INCLUDE_DIR} ${FFTW3_INCLUDE_DIR} ${Boost_INCLUDE_DIRS}
     SYSTEM PUBLIC ${EIGEN3_INCLUDE_DIRS}
     )
-target_link_libraries(${lib} 
+target_link_libraries(${lib}
     PRIVATE
-    ${GSL_LIBRARIES} 
+    ${GSL_LIBRARIES}
     ${FFTW3_LIBRARIES}
     ${Boost_LIBRARIES}
     ${Boost_Additional_Libraries})
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3f5c764962df58ef064313172fb60afafcf90567..c84c74e306bb420d1c9ff673caf372470f313391 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -29,7 +29,7 @@ else()
     message(STATUS "Generator type: Single-configuration generator")
 endif()
 message("    CMAKE_CONFIGURATION_TYPES: ${CMAKE_CONFIGURATION_TYPES}")
-# The following is not correct/does not have any effect for multi-configuration generators. 
+# The following is not correct/does not have any effect for multi-configuration generators.
 # But when correcting this, be aware that CMAKE_BUILD_TYPE is used in more scripts!
 if(NOT CMAKE_BUILD_TYPE)
     set(CMAKE_BUILD_TYPE Release CACHE STRING "" FORCE)
@@ -140,7 +140,7 @@ add_subdirectory(Fit/Test/Minimizer)
 ## recurse into the given subdirectories
 
 # BornAgain components are built as separate shared libraries
-set(CoreComponents "Base;Param;Sample;Device;Core")
+set(CoreComponents "Base;Param;Sample;Resample;Device;Core")
 set(AllComponents "${CoreComponents};GUI")
 
 # code analysis
diff --git a/Core/CMakeLists.txt b/Core/CMakeLists.txt
index 728a3b6fac17fe9c9d67e8f2546095c8a9c540d6..725ce443512ac4b8548f64a3fcb33d5456ada7fb 100644
--- a/Core/CMakeLists.txt
+++ b/Core/CMakeLists.txt
@@ -12,19 +12,19 @@ file(GLOB include_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} */*.h)
 
 # --- make the library ---
 
-MakeLib(${name} ${lib} ${CMAKE_CURRENT_BINARY_DIR}/Wrap)
+MakeLib(${name} ${lib} ${CMAKE_CURRENT_BINARY_DIR}/Wrap ${BORNAGAIN_PYTHON})
 
 set(${lib}_LIBRARY ${lib} PARENT_SCOPE)
 
 # --- external dependencies ---
 
-target_link_libraries(${lib} 
+target_link_libraries(${lib}
     PUBLIC
-    ${BornAgainSample_LIBRARY}
+    ${BornAgainResample_LIBRARY}
     ${BornAgainDevice_LIBRARY}
     PRIVATE
     ${CMAKE_THREAD_LIBS_INIT}
-    ${tspectrum_LIBRARY} 
+    ${tspectrum_LIBRARY}
     ${Cerf_LIBRARIES})
 
 target_include_directories(${lib}
diff --git a/Core/Computation/DWBAComputation.cpp b/Core/Computation/DWBAComputation.cpp
index cedb2a258bb163a9e301138f12dfdbb99bef17b0..648552caac2b43670ba1f28986b805ec38173a6c 100644
--- a/Core/Computation/DWBAComputation.cpp
+++ b/Core/Computation/DWBAComputation.cpp
@@ -20,7 +20,7 @@
 #include "Core/Computation/RoughMultiLayerComputation.h"
 #include "Sample/Fresnel/IFresnelMap.h"
 #include "Sample/Multilayer/MultiLayer.h"
-#include "Sample/Processed/ProcessedSample.h"
+#include "Resample/Processed/ProcessedSample.h"
 
 static_assert(std::is_copy_constructible<DWBAComputation>::value == false,
               "DWBAComputation should not be copy constructable");
diff --git a/Core/Computation/DWBASingleComputation.cpp b/Core/Computation/DWBASingleComputation.cpp
index 3f5e2cc1357b42cb1d2273f912585607e9968a36..219b8c26ef26b3bfcd67ea62422b68cacd1a74c4 100644
--- a/Core/Computation/DWBASingleComputation.cpp
+++ b/Core/Computation/DWBASingleComputation.cpp
@@ -18,8 +18,8 @@
 #include "Core/Computation/GISASSpecularComputation.h"
 #include "Core/Computation/ParticleLayoutComputation.h"
 #include "Core/Computation/RoughMultiLayerComputation.h"
-#include "Sample/Processed/ProcessedLayout.h"
-#include "Sample/Processed/ProcessedSample.h"
+#include "Resample/Processed/ProcessedLayout.h"
+#include "Resample/Processed/ProcessedSample.h"
 #include "Sample/RT/SimulationOptions.h"
 
 DWBASingleComputation::DWBASingleComputation(const ProcessedSample& sample,
diff --git a/Core/Computation/IComputation.cpp b/Core/Computation/IComputation.cpp
index e40141f26e8037f3fd335f50e0b67eacf679b5ab..e91275cc824b524f53ec8b68d77d5461b1d6e84d 100644
--- a/Core/Computation/IComputation.cpp
+++ b/Core/Computation/IComputation.cpp
@@ -16,7 +16,7 @@
 #include "Base/Pixel/SimulationElement.h"
 #include "Base/Progress/ProgressHandler.h"
 #include "Sample/Multilayer/MultiLayer.h"
-#include "Sample/Processed/ProcessedSample.h"
+#include "Resample/Processed/ProcessedSample.h"
 
 IComputation::IComputation(const MultiLayer& sample, const SimulationOptions& options,
                            ProgressHandler& progress, bool forcePolarized)
diff --git a/Core/Computation/ParticleLayoutComputation.cpp b/Core/Computation/ParticleLayoutComputation.cpp
index c50824c60cd83889c43a3785344fb0c5590172a3..d37678b9f8dbabd1e73ce32b5dc0816f6c7fa71f 100644
--- a/Core/Computation/ParticleLayoutComputation.cpp
+++ b/Core/Computation/ParticleLayoutComputation.cpp
@@ -17,7 +17,7 @@
 #include "Sample/Aggregate/InterferenceFunctionRadialParaCrystal.h"
 #include "Sample/Interference/DecouplingApproximationStrategy.h"
 #include "Sample/Interference/SSCApproximationStrategy.h"
-#include "Sample/Processed/ProcessedLayout.h"
+#include "Resample/Processed/ProcessedLayout.h"
 
 namespace {
 
diff --git a/Core/Computation/RoughMultiLayerComputation.cpp b/Core/Computation/RoughMultiLayerComputation.cpp
index e91670edbeed7c25d4fafd83e5153693351919cd..54309675d0a0cd74dc77ab4920a984f22cbc16eb 100644
--- a/Core/Computation/RoughMultiLayerComputation.cpp
+++ b/Core/Computation/RoughMultiLayerComputation.cpp
@@ -20,7 +20,7 @@
 #include "Sample/Interface/LayerRoughness.h"
 #include "Sample/Multilayer/Layer.h"
 #include "Sample/Multilayer/MultiLayer.h"
-#include "Sample/Processed/ProcessedSample.h"
+#include "Resample/Processed/ProcessedSample.h"
 #include "Sample/RT/ILayerRTCoefficients.h"
 #include "Sample/Slice/Slice.h"
 #include "Sample/Slice/SliceStack.h"
diff --git a/Core/Computation/SpecularComputation.cpp b/Core/Computation/SpecularComputation.cpp
index d87c7f0fdced5b98b4e339011349d66b9faeae69..6509021b6c39f1e2b845d9dbed31ff9b80ea6bde 100644
--- a/Core/Computation/SpecularComputation.cpp
+++ b/Core/Computation/SpecularComputation.cpp
@@ -16,7 +16,7 @@
 #include "Base/Progress/ProgressHandler.h"
 #include "Core/Element/SpecularSimulationElement.h"
 #include "Core/Term/SpecularComputationTerm.h"
-#include "Sample/Processed/ProcessedSample.h"
+#include "Resample/Processed/ProcessedSample.h"
 
 static_assert(std::is_copy_constructible<SpecularComputation>::value == false,
               "SpecularComputation should not be copy constructible");
diff --git a/Sample/Processed/MultiLayerFuncs.cpp b/Core/Swig/MultiLayerFuncs.cpp
similarity index 90%
rename from Sample/Processed/MultiLayerFuncs.cpp
rename to Core/Swig/MultiLayerFuncs.cpp
index c00b2a4aa0b629e2baf2cf58345467470f974257..dee72a4fa61da8c6a59e27afd97a89918cb3842b 100644
--- a/Sample/Processed/MultiLayerFuncs.cpp
+++ b/Core/Swig/MultiLayerFuncs.cpp
@@ -2,7 +2,7 @@
 //
 //  BornAgain: simulate and fit reflection and scattering
 //
-//! @file      Sample/Processed/MultiLayerFuncs.cpp
+//! @file      Core/Swig/MultiLayerFuncs.cpp
 //! @brief     Global functions related to MultiLayers.
 //!
 //! @homepage  http://www.bornagainproject.org
@@ -12,9 +12,9 @@
 //
 //  ************************************************************************************************
 
-#include "Sample/Processed/MultiLayerFuncs.h"
-#include "Sample/Processed/ProcessedSample.h"
-#include "Sample/Processed/ProfileHelper.h"
+#include "Core/Swig/MultiLayerFuncs.h"
+#include "Resample/Processed/ProcessedSample.h"
+#include "Resample/Processed/ProfileHelper.h"
 #include "Sample/RT/SimulationOptions.h"
 
 std::vector<double> swigAPI::generateZValues(int n_points, double z_min, double z_max)
diff --git a/Sample/Processed/MultiLayerFuncs.h b/Core/Swig/MultiLayerFuncs.h
similarity index 85%
rename from Sample/Processed/MultiLayerFuncs.h
rename to Core/Swig/MultiLayerFuncs.h
index f247e262c5c7d3e3c6cd8307a8ade4d0e2f749cc..1795f0f6a09a780fda3eb86a3fd7d07c042716ff 100644
--- a/Sample/Processed/MultiLayerFuncs.h
+++ b/Core/Swig/MultiLayerFuncs.h
@@ -2,7 +2,7 @@
 //
 //  BornAgain: simulate and fit reflection and scattering
 //
-//! @file      Sample/Processed/MultiLayerFuncs.h
+//! @file      Core/Swig/MultiLayerFuncs.h
 //! @brief     Global functions related to MultiLayers.
 //!
 //! @homepage  http://www.bornagainproject.org
@@ -13,8 +13,8 @@
 //  ************************************************************************************************
 
 #ifndef USER_API
-#ifndef BORNAGAIN_SAMPLE_PROCESSED_MULTILAYERFUNCS_H
-#define BORNAGAIN_SAMPLE_PROCESSED_MULTILAYERFUNCS_H
+#ifndef BORNAGAIN_CORE_SWIG_MULTILAYERFUNCS_H
+#define BORNAGAIN_CORE_SWIG_MULTILAYERFUNCS_H
 
 #include "Base/Types/Complex.h"
 #include <utility>
@@ -38,5 +38,5 @@ std::pair<double, double> defaultMaterialProfileLimits(const MultiLayer& multila
 
 } // namespace swigAPI
 
-#endif // BORNAGAIN_SAMPLE_PROCESSED_MULTILAYERFUNCS_H
+#endif // BORNAGAIN_CORE_SWIG_MULTILAYERFUNCS_H
 #endif // USER_API
diff --git a/Core/Term/DepthProbeComputationTerm.cpp b/Core/Term/DepthProbeComputationTerm.cpp
index 043896917e6048b0bf609f2b54e0184cb930be50..01acdb56592a5105b544e03ddfd71f38d903c8e6 100644
--- a/Core/Term/DepthProbeComputationTerm.cpp
+++ b/Core/Term/DepthProbeComputationTerm.cpp
@@ -17,7 +17,7 @@
 #include "Base/Progress/DelayedProgressCounter.h"
 #include "Core/Element/DepthProbeElement.h"
 #include "Sample/Fresnel/IFresnelMap.h"
-#include "Sample/Processed/ProcessedSample.h"
+#include "Resample/Processed/ProcessedSample.h"
 #include "Sample/RT/ILayerRTCoefficients.h"
 
 DepthProbeComputationTerm::DepthProbeComputationTerm(const ProcessedSample* p_sample)
diff --git a/Device/CMakeLists.txt b/Device/CMakeLists.txt
index 123d6209a2ef18a6316eb3176098bac7e063a14d..1b6d76e76a4f5e9d2eed04c8c063d62dde10afa0 100644
--- a/Device/CMakeLists.txt
+++ b/Device/CMakeLists.txt
@@ -12,20 +12,23 @@ file(GLOB include_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} */*.h)
 
 # --- make the library ---
 
-MakeLib(${name} ${lib} ${CMAKE_CURRENT_BINARY_DIR}/Wrap)
+MakeLib(${name} ${lib} ${CMAKE_CURRENT_BINARY_DIR}/Wrap ${BORNAGAIN_PYTHON})
 
 set(${lib}_LIBRARY ${lib} PARENT_SCOPE)
 
 # --- external dependencies ---
 
-target_link_libraries(${lib} 
+target_link_libraries(${lib}
     PUBLIC
-    ${BornAgainSample_LIBRARY} # TODO get rid of this dependence
+    ${BornAgainBase_LIBRARY}
+    ${BornAgainFit_LIBRARY}
     ${BornAgainParam_LIBRARY}
+    ${BornAgainSample_LIBRARY}
+    ${BornAgainResample_LIBRARY}
     ${CMAKE_THREAD_LIBS_INIT}
-    PRIVATE 
+    PRIVATE
     ${FFTW3_LIBRARIES})
-    
+
 target_include_directories(${lib}
     PUBLIC ${CMAKE_SOURCE_DIR}
     )
diff --git a/Fit/CMakeLists.txt b/Fit/CMakeLists.txt
index 68708ffb0da5f5bdfb0e33ed65214f2429cc01c6..566fda009b7cc7eb1695a37f6eae8ca44988a893 100644
--- a/Fit/CMakeLists.txt
+++ b/Fit/CMakeLists.txt
@@ -12,7 +12,7 @@ file(GLOB include_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} */*.h)
 
 # --- make the library ---
 
-MakeLib(${name} ${lib} ${CMAKE_CURRENT_BINARY_DIR}/Wrap)
+MakeLib(${name} ${lib} ${CMAKE_CURRENT_BINARY_DIR}/Wrap ${BORNAGAIN_PYTHON})
 
 set(${lib}_LIBRARY ${lib} PARENT_SCOPE)
 
diff --git a/Param/CMakeLists.txt b/Param/CMakeLists.txt
index e1e0d33863ef3b37840b73a5177794a09d91bc0b..6a51206b6823cc8c013ffd49d7174f78e9f4ee91 100644
--- a/Param/CMakeLists.txt
+++ b/Param/CMakeLists.txt
@@ -12,7 +12,7 @@ file(GLOB include_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} */*.h)
 
 # --- make the library ---
 
-MakeLib(${name} ${lib} ${CMAKE_CURRENT_BINARY_DIR}/Wrap)
+MakeLib(${name} ${lib} ${CMAKE_CURRENT_BINARY_DIR}/Wrap ${BORNAGAIN_PYTHON})
 
 set(${lib}_LIBRARY ${lib} PARENT_SCOPE)
 
@@ -21,8 +21,7 @@ set(${lib}_LIBRARY ${lib} PARENT_SCOPE)
 target_link_libraries(${lib}
     PUBLIC
     ${BornAgainBase_LIBRARY}
-    ${BornAgainFit_LIBRARY}
-    ${CMAKE_THREAD_LIBS_INIT})
+    ${BornAgainFit_LIBRARY})
 target_include_directories(${lib}
     PUBLIC ${CMAKE_SOURCE_DIR}
     )
diff --git a/Resample/CMakeLists.txt b/Resample/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..bfa4447edc1de51ec6df61d8dcd3f029f9356ee4
--- /dev/null
+++ b/Resample/CMakeLists.txt
@@ -0,0 +1,26 @@
+############################################################################
+# CMakeLists.txt file for building libBornAgainResample
+############################################################################
+
+set(name Resample)
+set(lib BornAgain${name})
+
+# --- source and include files ---
+
+file(GLOB source_files */*.cpp)
+file(GLOB include_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} */*.h)
+
+# --- make the library ---
+
+MakeLib(${name} ${lib} ${CMAKE_CURRENT_BINARY_DIR}/Wrap FALSE)
+
+set(${lib}_LIBRARY ${lib} PARENT_SCOPE)
+
+# --- external dependencies ---
+
+target_link_libraries(${lib}
+    PUBLIC
+    ${BornAgainSample_LIBRARY})
+target_include_directories(${lib}
+    PUBLIC ${CMAKE_SOURCE_DIR}
+    )
diff --git a/Sample/Processed/MaterialSlicer.cpp b/Resample/Processed/MaterialSlicer.cpp
similarity index 96%
rename from Sample/Processed/MaterialSlicer.cpp
rename to Resample/Processed/MaterialSlicer.cpp
index b38c3b6ba4e13ae0d5f255f9e9d8577ecb7498da..d68869cecbb020f310538087da12bb23af750848 100644
--- a/Sample/Processed/MaterialSlicer.cpp
+++ b/Resample/Processed/MaterialSlicer.cpp
@@ -2,7 +2,7 @@
 //
 //  BornAgain: simulate and fit reflection and scattering
 //
-//! @file      Sample/Processed/MaterialSlicer.cpp
+//! @file      Resample/Processed/MaterialSlicer.cpp
 //! @brief     Implements function SampleUtils::Preprocessor::averageSlices
 //!
 //! @homepage  http://www.bornagainproject.org
@@ -12,13 +12,13 @@
 //
 //  ************************************************************************************************
 
-#include "Sample/Processed/MaterialSlicer.h"
+#include "Resample/Processed/MaterialSlicer.h"
 #include "Base/Utils/Assert.h"
 #include "Sample/Material/HomogeneousRegion.h"
 #include "Sample/Material/MaterialBySLDImpl.h"
 #include "Sample/Material/MaterialUtils.h"
 #include "Sample/Material/RefractiveMaterialImpl.h"
-#include "Sample/Processed/ProcessedLayout.h"
+#include "Resample/Processed/ProcessedLayout.h"
 #include "Sample/Slice/Slice.h"
 #include "Sample/Slice/SliceStack.h"
 
diff --git a/Sample/Processed/MaterialSlicer.h b/Resample/Processed/MaterialSlicer.h
similarity index 81%
rename from Sample/Processed/MaterialSlicer.h
rename to Resample/Processed/MaterialSlicer.h
index dbfbd0d922fc43673f4a96fd0bce679bf0ded761..13486fa5f0011a3cbcfc843db821e265ff092799 100644
--- a/Sample/Processed/MaterialSlicer.h
+++ b/Resample/Processed/MaterialSlicer.h
@@ -2,7 +2,7 @@
 //
 //  BornAgain: simulate and fit reflection and scattering
 //
-//! @file      Sample/Processed/MaterialSlicer.h
+//! @file      Resample/Processed/MaterialSlicer.h
 //! @brief     Defines function SampleUtils::Preprocessor::averageSlices
 //!
 //! @homepage  http://www.bornagainproject.org
@@ -17,8 +17,8 @@
 #endif
 
 #ifndef USER_API
-#ifndef BORNAGAIN_SAMPLE_PROCESSED_MATERIALSLICER_H
-#define BORNAGAIN_SAMPLE_PROCESSED_MATERIALSLICER_H
+#ifndef BORNAGAIN_RESAMPLE_PROCESSED_MATERIALSLICER_H
+#define BORNAGAIN_RESAMPLE_PROCESSED_MATERIALSLICER_H
 
 #include <vector>
 
@@ -31,5 +31,5 @@ void regionalAverage(SliceStack& stack, const std::vector<ProcessedLayout>& layo
 
 } // namespace SampleUtils::Preprocessor
 
-#endif // BORNAGAIN_SAMPLE_PROCESSED_MATERIALSLICER_H
+#endif // BORNAGAIN_RESAMPLE_PROCESSED_MATERIALSLICER_H
 #endif // USER_API
diff --git a/Sample/Processed/ParticleRegions.cpp b/Resample/Processed/ParticleRegions.cpp
similarity index 98%
rename from Sample/Processed/ParticleRegions.cpp
rename to Resample/Processed/ParticleRegions.cpp
index af06b063e29408f2e04d4b8fce0758edc366ecf6..d85e19bf56fc662f6399aef05d6925dff90236eb 100644
--- a/Sample/Processed/ParticleRegions.cpp
+++ b/Resample/Processed/ParticleRegions.cpp
@@ -2,7 +2,7 @@
 //
 //  BornAgain: simulate and fit reflection and scattering
 //
-//! @file      Sample/Processed/ParticleRegions.cpp
+//! @file      Resample/Processed/ParticleRegions.cpp
 //! @brief     Implements function SampleUtils::Preprocessor::particleRegions
 //!
 //! @homepage  http://www.bornagainproject.org
@@ -12,7 +12,7 @@
 //
 //  ************************************************************************************************
 
-#include "Sample/Processed/ParticleRegions.h"
+#include "Resample/Processed/ParticleRegions.h"
 #include "Sample/Aggregate/ParticleLayout.h"
 #include "Sample/Multilayer/Layer.h"
 #include "Sample/Multilayer/MultiLayer.h"
diff --git a/Sample/Processed/ParticleRegions.h b/Resample/Processed/ParticleRegions.h
similarity index 80%
rename from Sample/Processed/ParticleRegions.h
rename to Resample/Processed/ParticleRegions.h
index f5aa18126b3c7e97f21a19f323c0bd80f04cb1a0..0e647c21bd922deaf906c0349fa1e9fe17e69e35 100644
--- a/Sample/Processed/ParticleRegions.h
+++ b/Resample/Processed/ParticleRegions.h
@@ -2,7 +2,7 @@
 //
 //  BornAgain: simulate and fit reflection and scattering
 //
-//! @file      Sample/Processed/ParticleRegions.h
+//! @file      Resample/Processed/ParticleRegions.h
 //! @brief     Defines function SampleUtils::Preprocessor::particleRegions.
 //!
 //! @homepage  http://www.bornagainproject.org
@@ -17,8 +17,8 @@
 #endif
 
 #ifndef USER_API
-#ifndef BORNAGAIN_SAMPLE_PROCESSED_PARTICLEREGIONS_H
-#define BORNAGAIN_SAMPLE_PROCESSED_PARTICLEREGIONS_H
+#ifndef BORNAGAIN_RESAMPLE_PROCESSED_PARTICLEREGIONS_H
+#define BORNAGAIN_RESAMPLE_PROCESSED_PARTICLEREGIONS_H
 
 #include <vector>
 
@@ -32,5 +32,5 @@ std::vector<ZLimits> particleRegions(const MultiLayer& multilayer, bool use_slic
 } // namespace SampleUtils::Preprocessor
 
 
-#endif // BORNAGAIN_SAMPLE_PROCESSED_PARTICLEREGIONS_H
+#endif // BORNAGAIN_RESAMPLE_PROCESSED_PARTICLEREGIONS_H
 #endif // USER_API
diff --git a/Sample/Processed/ProcessedLayout.cpp b/Resample/Processed/ProcessedLayout.cpp
similarity index 97%
rename from Sample/Processed/ProcessedLayout.cpp
rename to Resample/Processed/ProcessedLayout.cpp
index 45deee80b13eef71a5fe086dbc2b4f1113b92a1e..9f05205a6798109d732b93c128857e91cd95a551 100644
--- a/Sample/Processed/ProcessedLayout.cpp
+++ b/Resample/Processed/ProcessedLayout.cpp
@@ -2,7 +2,7 @@
 //
 //  BornAgain: simulate and fit reflection and scattering
 //
-//! @file      Sample/Processed/ProcessedLayout.cpp
+//! @file      Resample/Processed/ProcessedLayout.cpp
 //! @brief     Implements class ProcessedLayout.
 //!
 //! @homepage  http://www.bornagainproject.org
@@ -12,7 +12,7 @@
 //
 //  ************************************************************************************************
 
-#include "Sample/Processed/ProcessedLayout.h"
+#include "Resample/Processed/ProcessedLayout.h"
 #include "Sample/Aggregate/IInterferenceFunction.h"
 #include "Sample/Aggregate/ParticleLayout.h"
 #include "Sample/FFCompute/ComputeBA.h"
diff --git a/Sample/Processed/ProcessedLayout.h b/Resample/Processed/ProcessedLayout.h
similarity index 90%
rename from Sample/Processed/ProcessedLayout.h
rename to Resample/Processed/ProcessedLayout.h
index dd25ac580503c031dc471826dbebefdcaba94a7c..9de1fb017b1b9c33cbbe3dad7db9586272331a4a 100644
--- a/Sample/Processed/ProcessedLayout.h
+++ b/Resample/Processed/ProcessedLayout.h
@@ -2,7 +2,7 @@
 //
 //  BornAgain: simulate and fit reflection and scattering
 //
-//! @file      Sample/Processed/ProcessedLayout.h
+//! @file      Resample/Processed/ProcessedLayout.h
 //! @brief     Defines class ProcessedLayout.
 //!
 //! @homepage  http://www.bornagainproject.org
@@ -17,8 +17,8 @@
 #endif
 
 #ifndef USER_API
-#ifndef BORNAGAIN_SAMPLE_PROCESSED_PROCESSEDLAYOUT_H
-#define BORNAGAIN_SAMPLE_PROCESSED_PROCESSEDLAYOUT_H
+#ifndef BORNAGAIN_RESAMPLE_PROCESSED_PROCESSEDLAYOUT_H
+#define BORNAGAIN_RESAMPLE_PROCESSED_PROCESSEDLAYOUT_H
 
 #include <map>
 #include <memory>
@@ -64,5 +64,5 @@ private:
     std::map<size_t, std::vector<HomogeneousRegion>> m_region_map;
 };
 
-#endif // BORNAGAIN_SAMPLE_PROCESSED_PROCESSEDLAYOUT_H
+#endif // BORNAGAIN_RESAMPLE_PROCESSED_PROCESSEDLAYOUT_H
 #endif // USER_API
diff --git a/Sample/Processed/ProcessedSample.cpp b/Resample/Processed/ProcessedSample.cpp
similarity index 97%
rename from Sample/Processed/ProcessedSample.cpp
rename to Resample/Processed/ProcessedSample.cpp
index 3470c4a41639666de6fe1aaf54f14c30b65f30b0..480d6a54c1c008b99d5509cfdd79d52c830792e0 100644
--- a/Sample/Processed/ProcessedSample.cpp
+++ b/Resample/Processed/ProcessedSample.cpp
@@ -2,7 +2,7 @@
 //
 //  BornAgain: simulate and fit reflection and scattering
 //
-//! @file      Sample/Processed/ProcessedSample.cpp
+//! @file      Resample/Processed/ProcessedSample.cpp
 //! @brief     Implements class ProcessedSample.
 //!
 //! @homepage  http://www.bornagainproject.org
@@ -12,7 +12,7 @@
 //
 //  ************************************************************************************************
 
-#include "Sample/Processed/ProcessedSample.h"
+#include "Resample/Processed/ProcessedSample.h"
 #include "Base/Const/Units.h"
 #include "Base/Utils/Assert.h"
 #include "Sample/Fresnel/MatrixFresnelMap.h"
@@ -21,9 +21,9 @@
 #include "Sample/Multilayer/Layer.h"
 #include "Sample/Multilayer/MultiLayer.h"
 #include "Sample/Multilayer/MultilayerUtils.h"
-#include "Sample/Processed/MaterialSlicer.h"
-#include "Sample/Processed/ParticleRegions.h"
-#include "Sample/Processed/ProcessedLayout.h"
+#include "Resample/Processed/MaterialSlicer.h"
+#include "Resample/Processed/ParticleRegions.h"
+#include "Resample/Processed/ProcessedLayout.h"
 #include "Sample/RT/SimulationOptions.h"
 #include "Sample/Scattering/ZLimits.h"
 #include "Sample/Slice/Slice.h"
diff --git a/Sample/Processed/ProcessedSample.h b/Resample/Processed/ProcessedSample.h
similarity index 91%
rename from Sample/Processed/ProcessedSample.h
rename to Resample/Processed/ProcessedSample.h
index ccfb144e5facca534ed9b05b1d9827ebf7967337..78ec21cfe834bd3c2dd24564e492c1cb6ab7290e 100644
--- a/Sample/Processed/ProcessedSample.h
+++ b/Resample/Processed/ProcessedSample.h
@@ -2,7 +2,7 @@
 //
 //  BornAgain: simulate and fit reflection and scattering
 //
-//! @file      Sample/Processed/ProcessedSample.h
+//! @file      Resample/Processed/ProcessedSample.h
 //! @brief     Defines class ProcessedSample.
 //!
 //! @homepage  http://www.bornagainproject.org
@@ -17,8 +17,8 @@
 #endif
 
 #ifndef USER_API
-#ifndef BORNAGAIN_SAMPLE_PROCESSED_PROCESSEDSAMPLE_H
-#define BORNAGAIN_SAMPLE_PROCESSED_PROCESSEDSAMPLE_H
+#ifndef BORNAGAIN_RESAMPLE_PROCESSED_PROCESSEDSAMPLE_H
+#define BORNAGAIN_RESAMPLE_PROCESSED_PROCESSEDSAMPLE_H
 
 #include "Base/Vector/Vectors3D.h"
 #include "Sample/Slice/SliceStack.h"
@@ -69,5 +69,5 @@ private:
     const std::unique_ptr<const IFresnelMap> m_fresnel_map;
 };
 
-#endif // BORNAGAIN_SAMPLE_PROCESSED_PROCESSEDSAMPLE_H
+#endif // BORNAGAIN_RESAMPLE_PROCESSED_PROCESSEDSAMPLE_H
 #endif // USER_API
diff --git a/Sample/Processed/ProfileHelper.cpp b/Resample/Processed/ProfileHelper.cpp
similarity index 95%
rename from Sample/Processed/ProfileHelper.cpp
rename to Resample/Processed/ProfileHelper.cpp
index a2eb2a131644ecb1dd56587b14946a46bbb097df..55c58afc1c4ef1551a644062d82c95731cfed6f4 100644
--- a/Sample/Processed/ProfileHelper.cpp
+++ b/Resample/Processed/ProfileHelper.cpp
@@ -2,7 +2,7 @@
 //
 //  BornAgain: simulate and fit reflection and scattering
 //
-//! @file      Sample/Processed/ProfileHelper.cpp
+//! @file      Resample/Processed/ProfileHelper.cpp
 //! @brief     Implements class ProfileHelper.
 //!
 //! @homepage  http://www.bornagainproject.org
@@ -12,9 +12,9 @@
 //
 //  ************************************************************************************************
 
-#include "Sample/Processed/ProfileHelper.h"
+#include "Resample/Processed/ProfileHelper.h"
 #include "Sample/Interface/LayerRoughness.h"
-#include "Sample/Processed/ProcessedSample.h"
+#include "Resample/Processed/ProcessedSample.h"
 #include "Sample/Slice/Slice.h"
 #include "Sample/Slice/SliceStack.h"
 
diff --git a/Sample/Processed/ProfileHelper.h b/Resample/Processed/ProfileHelper.h
similarity index 86%
rename from Sample/Processed/ProfileHelper.h
rename to Resample/Processed/ProfileHelper.h
index ae56069e15695f6398856f564fd4b733798d1de4..e9dd6cb1fab5c4f4c7c52ab4056a1c5ee39b6d19 100644
--- a/Sample/Processed/ProfileHelper.h
+++ b/Resample/Processed/ProfileHelper.h
@@ -2,7 +2,7 @@
 //
 //  BornAgain: simulate and fit reflection and scattering
 //
-//! @file      Sample/Processed/ProfileHelper.h
+//! @file      Resample/Processed/ProfileHelper.h
 //! @brief     Defines class ProfileHelper.
 //!
 //! @homepage  http://www.bornagainproject.org
@@ -17,8 +17,8 @@
 #endif
 
 #ifndef USER_API
-#ifndef BORNAGAIN_SAMPLE_PROCESSED_PROFILEHELPER_H
-#define BORNAGAIN_SAMPLE_PROCESSED_PROFILEHELPER_H
+#ifndef BORNAGAIN_RESAMPLE_PROCESSED_PROFILEHELPER_H
+#define BORNAGAIN_RESAMPLE_PROCESSED_PROFILEHELPER_H
 
 #include "Sample/Material/Material.h"
 #include <utility>
@@ -46,5 +46,5 @@ private:
     const SliceStack& m_stack; // from Fresnel map
 };
 
-#endif // BORNAGAIN_SAMPLE_PROCESSED_PROFILEHELPER_H
+#endif // BORNAGAIN_RESAMPLE_PROCESSED_PROFILEHELPER_H
 #endif // USER_API
diff --git a/Sample/CMakeLists.txt b/Sample/CMakeLists.txt
index 0d8f727fadea6542b97b8d49fc170ffda27f3bf0..577b9c03ca9ccba554d94343ace729805609890a 100644
--- a/Sample/CMakeLists.txt
+++ b/Sample/CMakeLists.txt
@@ -12,16 +12,15 @@ file(GLOB include_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} */*.h)
 
 # --- make the library ---
 
-MakeLib(${name} ${lib} ${CMAKE_CURRENT_BINARY_DIR}/Wrap)
+MakeLib(${name} ${lib} ${CMAKE_CURRENT_BINARY_DIR}/Wrap ${BORNAGAIN_PYTHON})
 
 set(${lib}_LIBRARY ${lib} PARENT_SCOPE)
 
 # --- external dependencies ---
 
 target_link_libraries(${lib}
-    PRIVATE
-    ${BornAgainParam_LIBRARY}
-    ${CMAKE_THREAD_LIBS_INIT})
+    PUBLIC
+    ${BornAgainParam_LIBRARY})
 target_include_directories(${lib}
     PUBLIC ${CMAKE_SOURCE_DIR}
     )
diff --git a/Tests/UnitTests/Core/Fresnel/KzComputationTest.cpp b/Tests/UnitTests/Core/Fresnel/KzComputationTest.cpp
index dade51ea62c44b6be0619555d97f95a5a40a67b2..85a3c4340f57d5181e417e8df4b0162b6b7cc54f 100644
--- a/Tests/UnitTests/Core/Fresnel/KzComputationTest.cpp
+++ b/Tests/UnitTests/Core/Fresnel/KzComputationTest.cpp
@@ -4,7 +4,7 @@
 #include "Sample/Material/MaterialFactoryFuncs.h"
 #include "Sample/Multilayer/Layer.h"
 #include "Sample/Multilayer/MultiLayer.h"
-#include "Sample/Processed/ProcessedSample.h"
+#include "Resample/Processed/ProcessedSample.h"
 #include "Sample/RT/SimulationOptions.h"
 #include "Sample/StandardSamples/PlainMultiLayerBySLDBuilder.h"
 #include "Tests/GTestWrapper/google_test.h"
diff --git a/Tests/UnitTests/Core/Fresnel/SpecularMagneticTest.cpp b/Tests/UnitTests/Core/Fresnel/SpecularMagneticTest.cpp
index f815b6b25d7c76de3f4a564f33fb9db9858fc427..2b1540c668ef8f08ee87d59fae649ff3d05a9f70 100644
--- a/Tests/UnitTests/Core/Fresnel/SpecularMagneticTest.cpp
+++ b/Tests/UnitTests/Core/Fresnel/SpecularMagneticTest.cpp
@@ -3,7 +3,7 @@
 #include "Sample/Material/MaterialFactoryFuncs.h"
 #include "Sample/Multilayer/Layer.h"
 #include "Sample/Multilayer/MultiLayer.h"
-#include "Sample/Processed/ProcessedSample.h"
+#include "Resample/Processed/ProcessedSample.h"
 #include "Sample/RT/SimulationOptions.h"
 #include "Sample/Slice/KzComputation.h"
 #include "Sample/Specular/SpecularMagneticTanhStrategy.h"
diff --git a/Tests/UnitTests/Core/Sample/LayerFillLimitsTest.cpp b/Tests/UnitTests/Core/Sample/LayerFillLimitsTest.cpp
index 61bf3e17c2ae0fa2d0bac104a275ae6d4e7e404d..ef0ef33b4e178d687b5c976eb4c4825372fb029e 100644
--- a/Tests/UnitTests/Core/Sample/LayerFillLimitsTest.cpp
+++ b/Tests/UnitTests/Core/Sample/LayerFillLimitsTest.cpp
@@ -2,7 +2,7 @@
 #include <stdexcept>
 
 #define INCLUDED_BY_TEST
-#include "Sample/Processed/ParticleRegions.cpp"
+#include "Resample/Processed/ParticleRegions.cpp"
 
 
 class LayerFillLimitsTest : public ::testing::Test {
diff --git a/Tests/UnitTests/Core/Sample/MaterialTest.cpp b/Tests/UnitTests/Core/Sample/MaterialTest.cpp
index d11d66093ed623978a2b7e9de03e667267092fb5..cdfc1a6614afd3314e830e5c984ab94e1a0827c6 100644
--- a/Tests/UnitTests/Core/Sample/MaterialTest.cpp
+++ b/Tests/UnitTests/Core/Sample/MaterialTest.cpp
@@ -7,7 +7,7 @@
 #include "Sample/Scattering/Rotations.h"
 #include "Tests/GTestWrapper/google_test.h"
 
-#include "Sample/Processed/MaterialSlicer.cpp"
+#include "Resample/Processed/MaterialSlicer.cpp"
 
 class MaterialTest : public ::testing::Test {
 };
diff --git a/Tests/UnitTests/Core/Sample/MultilayerAveragingTest.cpp b/Tests/UnitTests/Core/Sample/MultilayerAveragingTest.cpp
index 77b43ed6b8f23c982e0fa995069aaaab54576e36..f8b9b40684ee5132312855d2ededb7f430d26b13 100644
--- a/Tests/UnitTests/Core/Sample/MultilayerAveragingTest.cpp
+++ b/Tests/UnitTests/Core/Sample/MultilayerAveragingTest.cpp
@@ -5,7 +5,7 @@
 #include "Sample/Multilayer/Layer.h"
 #include "Sample/Multilayer/MultiLayer.h"
 #include "Sample/Particle/Particle.h"
-#include "Sample/Processed/ProcessedSample.h"
+#include "Resample/Processed/ProcessedSample.h"
 #include "Sample/RT/SimulationOptions.h"
 #include "Sample/Slice/Slice.h"
 #include "Sample/Slice/SliceStack.h"
diff --git a/Tests/UnitTests/Core/Sample/RTTest.cpp b/Tests/UnitTests/Core/Sample/RTTest.cpp
index 019041e63d1ff124e290a245693c905e68f68226..915c5af1c6610c14348cd561cb7c01346c643e4b 100644
--- a/Tests/UnitTests/Core/Sample/RTTest.cpp
+++ b/Tests/UnitTests/Core/Sample/RTTest.cpp
@@ -5,7 +5,7 @@
 #include "Sample/Material/MaterialFactoryFuncs.h"
 #include "Sample/Multilayer/Layer.h"
 #include "Sample/Multilayer/MultiLayer.h"
-#include "Sample/Processed/ProcessedSample.h"
+#include "Resample/Processed/ProcessedSample.h"
 #include "Sample/RT/SimulationOptions.h"
 #include "Sample/Specular/SpecularScalarTanhStrategy.h"
 #include "Tests/GTestWrapper/google_test.h"
diff --git a/Wrap/Swig/libBornAgainCore.i b/Wrap/Swig/libBornAgainCore.i
index 9ac97bf441db1e84ba6ef8099e916dfc1df63c97..e91372b239af957db0178957e6c12e9db51b14f0 100644
--- a/Wrap/Swig/libBornAgainCore.i
+++ b/Wrap/Swig/libBornAgainCore.i
@@ -73,6 +73,7 @@
 #include "Core/Simulation/OffSpecularSimulation.h"
 #include "Core/Simulation/SimulationFactory.h"
 #include "Core/Simulation/SpecularSimulation.h"
+#include "Core/Swig/MultiLayerFuncs.h"
 %}
 
 // The following goes verbatim from libBornAgainCore.i to libBornAgainCore_wrap.cxx.
@@ -122,6 +123,8 @@
 %include "Core/Residual/ChiSquaredModule.h"
 %include "Core/Residual/VarianceFunctions.h"
 
+%include "Core/Swig/MultiLayerFuncs.h"
+
 %extend BasicVector3D<double> {
     BasicVector3D<double> __add__(const BasicVector3D<double>& rhs) const {
         return *($self) + rhs; }
@@ -266,3 +269,24 @@ class ObserverCallbackWrapper(PyObserverCallback):
         return None
 %}
 };
+
+
+%pythoncode %{
+    def materialProfile(multilayer, n_points=400, z_min=None, z_max=None):
+        """
+        Creates a material profile from the given multilayer. If no limits are given,
+        it will provide sensible default values, considering the included particles and
+        interface roughnesses.
+        :param multilayer: bornagain.MultiLayer object
+        :param n_points: number of points to generate
+        :param z_min: starting value for z
+        :param z_max: ending value for z
+        :return: numpy arrays containing z positions and the complex material values in those positions
+        """
+        def_z_min, def_z_max = defaultMaterialProfileLimits(multilayer)
+        z_min = def_z_min if z_min is None else z_min
+        z_max = def_z_max if z_max is None else z_max
+        z_points = generateZValues(n_points, z_min, z_max)
+        material_values = materialProfileSLD(multilayer, n_points, z_min, z_max)
+        return (z_points, material_values)
+%}
diff --git a/Wrap/Swig/libBornAgainSample.i b/Wrap/Swig/libBornAgainSample.i
index fcff62cdd6d22e9822646ea496972a76e1bdefbe..9f8d9c7047741dd4b0925524ec2d8f21257d7c93 100644
--- a/Wrap/Swig/libBornAgainSample.i
+++ b/Wrap/Swig/libBornAgainSample.i
@@ -92,7 +92,6 @@
 #include "Sample/Particle/ParticleComposition.h"
 #include "Sample/Particle/ParticleCoreShell.h"
 #include "Sample/Particle/SlicedParticle.h"
-#include "Sample/Processed/MultiLayerFuncs.h"
 #include "Sample/RT/SimulationOptions.h"
 #include "Sample/SampleBuilderEngine/ISampleBuilder.h"
 #include "Sample/Scattering/IFormFactorDecorator.h"
@@ -176,7 +175,6 @@
 %include "Sample/Aggregate/ParticleLayout.h"
 
 %include "Sample/Interface/LayerRoughness.h"
-%include "Sample/Processed/MultiLayerFuncs.h"
 
 %include "Sample/Multilayer/Layer.h"
 %include "Sample/Multilayer/MultiLayer.h"
@@ -245,23 +243,3 @@
     }
 
 };
-
-%pythoncode %{
-    def materialProfile(multilayer, n_points=400, z_min=None, z_max=None):
-        """
-        Creates a material profile from the given multilayer. If no limits are given,
-        it will provide sensible default values, considering the included particles and
-        interface roughnesses.
-        :param multilayer: bornagain.MultiLayer object
-        :param n_points: number of points to generate
-        :param z_min: starting value for z
-        :param z_max: ending value for z
-        :return: numpy arrays containing z positions and the complex material values in those positions
-        """
-        def_z_min, def_z_max = defaultMaterialProfileLimits(multilayer)
-        z_min = def_z_min if z_min is None else z_min
-        z_max = def_z_max if z_max is None else z_max
-        z_points = generateZValues(n_points, z_min, z_max)
-        material_values = materialProfileSLD(multilayer, n_points, z_min, z_max)
-        return (z_points, material_values)
-%}
diff --git a/auto/Wrap/doxygenCore.i b/auto/Wrap/doxygenCore.i
index 024df1a584891c8e007f0c896b627c0fbddc293e..25a02d283ee6eecfc9a5ab2162412c1028d1071a 100644
--- a/auto/Wrap/doxygenCore.i
+++ b/auto/Wrap/doxygenCore.i
@@ -2230,7 +2230,7 @@ C++ includes: VarianceFunctions.h
 // File: namespace_0d90.xml
 
 
-// File: namespace_0d94.xml
+// File: namespace_0d96.xml
 
 
 // File: namespacemumufit.xml
@@ -2519,6 +2519,21 @@ GISAS simulation with an extra long wavelength.
 ";
 
 
+// File: namespaceswigAPI.xml
+%feature("docstring")  swigAPI::generateZValues "std::vector< double > swigAPI::generateZValues(int n_points, double z_min, double z_max)
+";
+
+%feature("docstring")  swigAPI::materialProfileSLD "std::vector< complex_t > swigAPI::materialProfileSLD(const MultiLayer &multilayer, int n_points, double z_min, double z_max)
+
+Calculate average material profile for given multilayer. 
+";
+
+%feature("docstring")  swigAPI::defaultMaterialProfileLimits "std::pair< double, double > swigAPI::defaultMaterialProfileLimits(const MultiLayer &multilayer)
+
+Get default z limits for generating a material profile. 
+";
+
+
 // File: ComputationStatus_8h.xml
 
 
@@ -2795,6 +2810,12 @@ GISAS simulation with an extra long wavelength.
 // File: StandardSimulations_8h.xml
 
 
+// File: MultiLayerFuncs_8cpp.xml
+
+
+// File: MultiLayerFuncs_8h.xml
+
+
 // File: DepthProbeComputationTerm_8cpp.xml
 
 
@@ -2831,5 +2852,8 @@ GISAS simulation with an extra long wavelength.
 // File: dir_d7a24665a95cfc15308ebd7b07b5ebd6.xml
 
 
+// File: dir_6cd4650b9a2b2240067986ed26845b49.xml
+
+
 // File: dir_52128420a621ebf8ad4a4626c50b78b3.xml
 
diff --git a/auto/Wrap/doxygenSample.i b/auto/Wrap/doxygenSample.i
index e3fa4c530dac8fd98880cd1170bb00af5568cad6..a817935cd7f521bcb538dc80d033728d8060bc2e 100644
--- a/auto/Wrap/doxygenSample.i
+++ b/auto/Wrap/doxygenSample.i
@@ -3580,7 +3580,7 @@ Calculates the intensity for scalar particles/interactions.
 // File: classILayerRTCoefficients.xml
 %feature("docstring") ILayerRTCoefficients "
 
-Interface to access reflection/transmission coefficients.
+Interface to access reflection/transmission coefficients. Realized by  ScalarRTCoefficients and  MatrixRTCoefficients.
 
 C++ includes: ILayerRTCoefficients.h
 ";
@@ -4861,28 +4861,6 @@ Returns nullptr, unless overwritten to return a specific material.
 ";
 
 
-// File: classLayerFillLimits.xml
-%feature("docstring") LayerFillLimits "
-
-Helper class for the graded layer approximation. Generates limits for each layer, indicating the region of the layer (along z) that contains particle(s)
-
-The constructor takes the bottom layer z-coordinates as parameter. This means that for N layers, only N-1 coordinates need to be passed (the last layer is assumed to be semi-infinite). 
-";
-
-%feature("docstring")  LayerFillLimits::LayerFillLimits "LayerFillLimits::LayerFillLimits(std::vector< double > layers_bottomz)
-";
-
-%feature("docstring")  LayerFillLimits::update "void LayerFillLimits::update(ZLimits particle_limits, double offset=0.0)
-
-Particle limits are given in global coordinates. 
-";
-
-%feature("docstring")  LayerFillLimits::layerZLimits "std::vector< ZLimits > LayerFillLimits::layerZLimits() const
-
-Returns the filled region limits for each layer (in local layer coordinates) 
-";
-
-
 // File: classLayerInterface.xml
 %feature("docstring") LayerInterface "
 
@@ -6123,122 +6101,6 @@ needed for topZ, bottomZ computation
 ";
 
 
-// File: classProcessedLayout.xml
-%feature("docstring") ProcessedLayout "
-
-Data structure that contains preprocessed data for a single layout.
-
-If particles in the layout crossed the limits of the layer slices, these particles will be sliced themselves.
-
-C++ includes: ProcessedLayout.h
-";
-
-%feature("docstring")  ProcessedLayout::ProcessedLayout "ProcessedLayout::ProcessedLayout(const ParticleLayout &layout, const SliceStack &slices, double z_ref, bool polarized)
-";
-
-%feature("docstring")  ProcessedLayout::ProcessedLayout "ProcessedLayout::ProcessedLayout(ProcessedLayout &&other)
-";
-
-%feature("docstring")  ProcessedLayout::~ProcessedLayout "ProcessedLayout::~ProcessedLayout()
-";
-
-%feature("docstring")  ProcessedLayout::numberOfSlices "size_t ProcessedLayout::numberOfSlices() const
-";
-
-%feature("docstring")  ProcessedLayout::surfaceDensity "double ProcessedLayout::surfaceDensity() const
-";
-
-%feature("docstring")  ProcessedLayout::formFactorList "const std::vector< FormFactorCoherentSum > & ProcessedLayout::formFactorList() const
-";
-
-%feature("docstring")  ProcessedLayout::interferenceFunction "const IInterferenceFunction * ProcessedLayout::interferenceFunction() const
-";
-
-%feature("docstring")  ProcessedLayout::regionMap "const std::map< size_t, std::vector< HomogeneousRegion > > & ProcessedLayout::regionMap() const
-";
-
-
-// File: classProcessedSample.xml
-%feature("docstring") ProcessedSample "
-
-Data structure that contains all the necessary data for scattering calculations.
-
-If the usage of average materials is requested, layers and particles are sliced into multiple slices and the average material is calculated for each slice.
-
-C++ includes: ProcessedSample.h
-";
-
-%feature("docstring")  ProcessedSample::ProcessedSample "ProcessedSample::ProcessedSample(const MultiLayer &sample, const SimulationOptions &options, bool forcePolarized=false)
-";
-
-%feature("docstring")  ProcessedSample::~ProcessedSample "ProcessedSample::~ProcessedSample()
-";
-
-%feature("docstring")  ProcessedSample::numberOfSlices "size_t ProcessedSample::numberOfSlices() const
-";
-
-%feature("docstring")  ProcessedSample::slices "const SliceStack & ProcessedSample::slices() const
-";
-
-%feature("docstring")  ProcessedSample::averageSlices "const SliceStack & ProcessedSample::averageSlices() const
-";
-
-%feature("docstring")  ProcessedSample::avgeSlice "const Slice & ProcessedSample::avgeSlice(size_t i) const
-";
-
-%feature("docstring")  ProcessedSample::layouts "const std::vector< ProcessedLayout > & ProcessedSample::layouts() const
-";
-
-%feature("docstring")  ProcessedSample::fresnelMap "const IFresnelMap * ProcessedSample::fresnelMap() const
-";
-
-%feature("docstring")  ProcessedSample::crossCorrelationLength "double ProcessedSample::crossCorrelationLength() const
-";
-
-%feature("docstring")  ProcessedSample::externalField "const kvector_t & ProcessedSample::externalField() const
-";
-
-%feature("docstring")  ProcessedSample::sliceTopZ "double ProcessedSample::sliceTopZ(size_t i) const
-";
-
-%feature("docstring")  ProcessedSample::sliceBottomZ "double ProcessedSample::sliceBottomZ(size_t i) const
-";
-
-%feature("docstring")  ProcessedSample::containsMagneticMaterial "bool ProcessedSample::containsMagneticMaterial() const
-";
-
-%feature("docstring")  ProcessedSample::hasRoughness "bool ProcessedSample::hasRoughness() const
-";
-
-%feature("docstring")  ProcessedSample::crossCorrSpectralFun "double ProcessedSample::crossCorrSpectralFun(const kvector_t kvec, size_t j, size_t k) const
-
-Fourier transform of the correlation function of roughnesses between the interfaces. 
-";
-
-
-// File: classProfileHelper.xml
-%feature("docstring") ProfileHelper "
-
-Object that can generate the material profile of a sample as a function of depth.
-
-The generated profile contains the complex SLD for SLD materials and the parameters delta and beta for refractive index materials
-
-C++ includes: ProfileHelper.h
-";
-
-%feature("docstring")  ProfileHelper::ProfileHelper "ProfileHelper::ProfileHelper(const ProcessedSample &sample)
-";
-
-%feature("docstring")  ProfileHelper::~ProfileHelper "ProfileHelper::~ProfileHelper()
-";
-
-%feature("docstring")  ProfileHelper::calculateProfile "std::vector< complex_t > ProfileHelper::calculateProfile(const std::vector< double > &z_values) const
-";
-
-%feature("docstring")  ProfileHelper::defaultLimits "std::pair< double, double > ProfileHelper::defaultLimits() const
-";
-
-
 // File: classRadialParaCrystalBuilder.xml
 %feature("docstring") RadialParaCrystalBuilder "
 
@@ -7406,70 +7268,58 @@ C++ includes: ZLimits.h
 // File: namespace_0d172.xml
 
 
-// File: namespace_0d195.xml
-
-
-// File: namespace_0d199.xml
+// File: namespace_0d196.xml
 
 
 // File: namespace_0d2.xml
 
 
-// File: namespace_0d203.xml
-
-
-// File: namespace_0d205.xml
-
-
-// File: namespace_0d208.xml
+// File: namespace_0d210.xml
 
 
 // File: namespace_0d222.xml
 
 
-// File: namespace_0d234.xml
+// File: namespace_0d244.xml
 
 
-// File: namespace_0d256.xml
+// File: namespace_0d248.xml
 
 
-// File: namespace_0d260.xml
+// File: namespace_0d259.xml
 
 
-// File: namespace_0d271.xml
+// File: namespace_0d261.xml
 
 
-// File: namespace_0d273.xml
+// File: namespace_0d263.xml
 
 
-// File: namespace_0d275.xml
+// File: namespace_0d267.xml
 
 
-// File: namespace_0d279.xml
+// File: namespace_0d269.xml
 
 
-// File: namespace_0d281.xml
+// File: namespace_0d273.xml
 
 
 // File: namespace_0d285.xml
 
 
-// File: namespace_0d297.xml
-
-
-// File: namespace_0d303.xml
+// File: namespace_0d291.xml
 
 
-// File: namespace_0d307.xml
+// File: namespace_0d295.xml
 
 
 // File: namespace_0d31.xml
 
 
-// File: namespace_0d325.xml
+// File: namespace_0d313.xml
 
 
-// File: namespace_0d344.xml
+// File: namespace_0d332.xml
 
 
 // File: namespace_0d37.xml
@@ -7635,16 +7485,6 @@ Returns true if the multilayer contains non-default materials of one type only.
 ";
 
 
-// File: namespaceSampleUtils_1_1Preprocessor.xml
-%feature("docstring")  SampleUtils::Preprocessor::regionalAverage "void SampleUtils::Preprocessor::regionalAverage(SliceStack &stack, const std::vector< ProcessedLayout > &layouts)
-";
-
-%feature("docstring")  SampleUtils::Preprocessor::particleRegions "std::vector< ZLimits > SampleUtils::Preprocessor::particleRegions(const MultiLayer &multilayer, bool use_slicing)
-
-Calculate z-regions occupied by particles. 
-";
-
-
 // File: namespaceSampleUtils_1_1someff.xml
 %feature("docstring")  SampleUtils::someff::ffSphere "complex_t SampleUtils::someff::ffSphere(cvector_t q, double R)
 
@@ -8333,42 +8173,6 @@ magnetization (in A/m)
 // File: SlicedParticle_8h.xml
 
 
-// File: MaterialSlicer_8cpp.xml
-
-
-// File: MaterialSlicer_8h.xml
-
-
-// File: MultiLayerFuncs_8cpp.xml
-
-
-// File: MultiLayerFuncs_8h.xml
-
-
-// File: ParticleRegions_8cpp.xml
-
-
-// File: ParticleRegions_8h.xml
-
-
-// File: ProcessedLayout_8cpp.xml
-
-
-// File: ProcessedLayout_8h.xml
-
-
-// File: ProcessedSample_8cpp.xml
-
-
-// File: ProcessedSample_8h.xml
-
-
-// File: ProfileHelper_8cpp.xml
-
-
-// File: ProfileHelper_8h.xml
-
-
 // File: ILayerRTCoefficients_8h.xml
 
 
@@ -8842,6 +8646,12 @@ Generate vertices of centered ellipse with given semi-axes at height z.
 // File: TwoLayerRoughnessBuilder_8h.xml
 
 
+// File: MultiLayerFuncs_8cpp.xml
+
+
+// File: MultiLayerFuncs_8h.xml
+
+
 // File: dir_220e7f16e10b4e45e27e10ed0346ff0c.xml
 
 
@@ -8878,9 +8688,6 @@ Generate vertices of centered ellipse with given semi-axes at height z.
 // File: dir_61bfb933e72dfe3586b97d80db501038.xml
 
 
-// File: dir_ccb77c5fc9fada2051f2fad6bbe3a645.xml
-
-
 // File: dir_52f00155c6a6846eb7173e2ee1c8b0ff.xml
 
 
@@ -8907,3 +8714,6 @@ Generate vertices of centered ellipse with given semi-axes at height z.
 
 // File: dir_d9d42b37b662547974602e66402128ce.xml
 
+
+// File: dir_cd321a87f0b43fa55d7001733dd62244.xml
+
diff --git a/auto/Wrap/libBornAgainCore.py b/auto/Wrap/libBornAgainCore.py
index 8aec86e4e81a148d35ac4ee34b7da3fdfc08041a..21b8f08a8e455520d76810089ddfb7189ec02c89 100644
--- a/auto/Wrap/libBornAgainCore.py
+++ b/auto/Wrap/libBornAgainCore.py
@@ -4720,6 +4720,34 @@ class VarianceSimFunction(IVarianceFunction):
 _libBornAgainCore.VarianceSimFunction_swigregister(VarianceSimFunction)
 
 
+def generateZValues(n_points, z_min, z_max):
+    r"""
+    generateZValues(int n_points, double z_min, double z_max) -> vdouble1d_t
+    std::vector< double > swigAPI::generateZValues(int n_points, double z_min, double z_max)
+
+    """
+    return _libBornAgainCore.generateZValues(n_points, z_min, z_max)
+
+def materialProfileSLD(multilayer, n_points, z_min, z_max):
+    r"""
+    materialProfileSLD(MultiLayer const & multilayer, int n_points, double z_min, double z_max) -> vector_complex_t
+    std::vector< complex_t > swigAPI::materialProfileSLD(const MultiLayer &multilayer, int n_points, double z_min, double z_max)
+
+    Calculate average material profile for given multilayer. 
+
+    """
+    return _libBornAgainCore.materialProfileSLD(multilayer, n_points, z_min, z_max)
+
+def defaultMaterialProfileLimits(multilayer):
+    r"""
+    defaultMaterialProfileLimits(MultiLayer const & multilayer) -> pvacuum_double_t
+    std::pair< double, double > swigAPI::defaultMaterialProfileLimits(const MultiLayer &multilayer)
+
+    Get default z limits for generating a material profile. 
+
+    """
+    return _libBornAgainCore.defaultMaterialProfileLimits(multilayer)
+
 class SimulationBuilderWrapper(PyBuilderCallback):
     def __init__(self, f):
         super(SimulationBuilderWrapper, self).__init__()
@@ -4752,3 +4780,22 @@ class ObserverCallbackWrapper(PyObserverCallback):
 
 
 
+def materialProfile(multilayer, n_points=400, z_min=None, z_max=None):
+    """
+    Creates a material profile from the given multilayer. If no limits are given,
+    it will provide sensible default values, considering the included particles and
+    interface roughnesses.
+    :param multilayer: bornagain.MultiLayer object
+    :param n_points: number of points to generate
+    :param z_min: starting value for z
+    :param z_max: ending value for z
+    :return: numpy arrays containing z positions and the complex material values in those positions
+    """
+    def_z_min, def_z_max = defaultMaterialProfileLimits(multilayer)
+    z_min = def_z_min if z_min is None else z_min
+    z_max = def_z_max if z_max is None else z_max
+    z_points = generateZValues(n_points, z_min, z_max)
+    material_values = materialProfileSLD(multilayer, n_points, z_min, z_max)
+    return (z_points, material_values)
+
+
diff --git a/auto/Wrap/libBornAgainCore_wrap.cpp b/auto/Wrap/libBornAgainCore_wrap.cpp
index 3423cd182753dc38838b0bd700b62ab6a13677f1..8eae9147b9bde2554105155319242ebd38ec2ba7 100644
--- a/auto/Wrap/libBornAgainCore_wrap.cpp
+++ b/auto/Wrap/libBornAgainCore_wrap.cpp
@@ -6714,6 +6714,7 @@ SWIGINTERN void std_vector_Sl_std_pair_Sl_double_Sc_double_Sg__Sg__insert__SWIG_
 #include "Core/Simulation/OffSpecularSimulation.h"
 #include "Core/Simulation/SimulationFactory.h"
 #include "Core/Simulation/SpecularSimulation.h"
+#include "Core/Swig/MultiLayerFuncs.h"
 
 SWIGINTERN BasicVector3D< double > BasicVector3D_Sl_double_Sg____add__(BasicVector3D< double > const *self,BasicVector3D< double > const &rhs){
         return *(self) + rhs; }
@@ -43132,6 +43133,119 @@ SWIGINTERN PyObject *VarianceSimFunction_swiginit(PyObject *SWIGUNUSEDPARM(self)
   return SWIG_Python_InitShadowInstance(args);
 }
 
+SWIGINTERN PyObject *_wrap_generateZValues(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  int arg1 ;
+  double arg2 ;
+  double arg3 ;
+  int val1 ;
+  int ecode1 = 0 ;
+  double val2 ;
+  int ecode2 = 0 ;
+  double val3 ;
+  int ecode3 = 0 ;
+  PyObject *swig_obj[3] ;
+  std::vector< double,std::allocator< double > > result;
+  
+  if (!SWIG_Python_UnpackTuple(args, "generateZValues", 3, 3, swig_obj)) SWIG_fail;
+  ecode1 = SWIG_AsVal_int(swig_obj[0], &val1);
+  if (!SWIG_IsOK(ecode1)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "generateZValues" "', argument " "1"" of type '" "int""'");
+  } 
+  arg1 = static_cast< int >(val1);
+  ecode2 = SWIG_AsVal_double(swig_obj[1], &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "generateZValues" "', argument " "2"" of type '" "double""'");
+  } 
+  arg2 = static_cast< double >(val2);
+  ecode3 = SWIG_AsVal_double(swig_obj[2], &val3);
+  if (!SWIG_IsOK(ecode3)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "generateZValues" "', argument " "3"" of type '" "double""'");
+  } 
+  arg3 = static_cast< double >(val3);
+  result = swigAPI::generateZValues(arg1,arg2,arg3);
+  resultobj = swig::from(static_cast< std::vector< double,std::allocator< double > > >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_materialProfileSLD(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  MultiLayer *arg1 = 0 ;
+  int arg2 ;
+  double arg3 ;
+  double arg4 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  int val2 ;
+  int ecode2 = 0 ;
+  double val3 ;
+  int ecode3 = 0 ;
+  double val4 ;
+  int ecode4 = 0 ;
+  PyObject *swig_obj[4] ;
+  std::vector< complex_t,std::allocator< complex_t > > result;
+  
+  if (!SWIG_Python_UnpackTuple(args, "materialProfileSLD", 4, 4, swig_obj)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1, SWIGTYPE_p_MultiLayer,  0  | 0);
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "materialProfileSLD" "', argument " "1"" of type '" "MultiLayer const &""'"); 
+  }
+  if (!argp1) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "materialProfileSLD" "', argument " "1"" of type '" "MultiLayer const &""'"); 
+  }
+  arg1 = reinterpret_cast< MultiLayer * >(argp1);
+  ecode2 = SWIG_AsVal_int(swig_obj[1], &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "materialProfileSLD" "', argument " "2"" of type '" "int""'");
+  } 
+  arg2 = static_cast< int >(val2);
+  ecode3 = SWIG_AsVal_double(swig_obj[2], &val3);
+  if (!SWIG_IsOK(ecode3)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "materialProfileSLD" "', argument " "3"" of type '" "double""'");
+  } 
+  arg3 = static_cast< double >(val3);
+  ecode4 = SWIG_AsVal_double(swig_obj[3], &val4);
+  if (!SWIG_IsOK(ecode4)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "materialProfileSLD" "', argument " "4"" of type '" "double""'");
+  } 
+  arg4 = static_cast< double >(val4);
+  result = swigAPI::materialProfileSLD((MultiLayer const &)*arg1,arg2,arg3,arg4);
+  resultobj = swig::from(static_cast< std::vector< std::complex< double >,std::allocator< std::complex< double > > > >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_defaultMaterialProfileLimits(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  MultiLayer *arg1 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject *swig_obj[1] ;
+  std::pair< double,double > result;
+  
+  if (!args) SWIG_fail;
+  swig_obj[0] = args;
+  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1, SWIGTYPE_p_MultiLayer,  0  | 0);
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "defaultMaterialProfileLimits" "', argument " "1"" of type '" "MultiLayer const &""'"); 
+  }
+  if (!argp1) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "defaultMaterialProfileLimits" "', argument " "1"" of type '" "MultiLayer const &""'"); 
+  }
+  arg1 = reinterpret_cast< MultiLayer * >(argp1);
+  result = swigAPI::defaultMaterialProfileLimits((MultiLayer const &)*arg1);
+  resultobj = swig::from(static_cast< std::pair< double,double > >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
 static PyMethodDef SwigMethods[] = {
 	 { "SWIG_PyInstanceMethod_New", SWIG_PyInstanceMethod_New, METH_O, NULL},
 	 { "delete_SwigPyIterator", _wrap_delete_SwigPyIterator, METH_O, "delete_SwigPyIterator(SwigPyIterator self)"},
@@ -45198,6 +45312,25 @@ static PyMethodDef SwigMethods[] = {
 	 { "delete_VarianceSimFunction", _wrap_delete_VarianceSimFunction, METH_O, "delete_VarianceSimFunction(VarianceSimFunction self)"},
 	 { "VarianceSimFunction_swigregister", VarianceSimFunction_swigregister, METH_O, NULL},
 	 { "VarianceSimFunction_swiginit", VarianceSimFunction_swiginit, METH_VARARGS, NULL},
+	 { "generateZValues", _wrap_generateZValues, METH_VARARGS, "\n"
+		"generateZValues(int n_points, double z_min, double z_max) -> vdouble1d_t\n"
+		"std::vector< double > swigAPI::generateZValues(int n_points, double z_min, double z_max)\n"
+		"\n"
+		""},
+	 { "materialProfileSLD", _wrap_materialProfileSLD, METH_VARARGS, "\n"
+		"materialProfileSLD(MultiLayer const & multilayer, int n_points, double z_min, double z_max) -> vector_complex_t\n"
+		"std::vector< complex_t > swigAPI::materialProfileSLD(const MultiLayer &multilayer, int n_points, double z_min, double z_max)\n"
+		"\n"
+		"Calculate average material profile for given multilayer. \n"
+		"\n"
+		""},
+	 { "defaultMaterialProfileLimits", _wrap_defaultMaterialProfileLimits, METH_O, "\n"
+		"defaultMaterialProfileLimits(MultiLayer const & multilayer) -> pvacuum_double_t\n"
+		"std::pair< double, double > swigAPI::defaultMaterialProfileLimits(const MultiLayer &multilayer)\n"
+		"\n"
+		"Get default z limits for generating a material profile. \n"
+		"\n"
+		""},
 	 { NULL, NULL, 0, NULL }
 };
 
diff --git a/auto/Wrap/libBornAgainSample.py b/auto/Wrap/libBornAgainSample.py
index 5d0f1f98749459b9894a2dcae8f2e378deb3a0f1..aae99025bfb752f20085b6063d899b1f65e0a6dc 100644
--- a/auto/Wrap/libBornAgainSample.py
+++ b/auto/Wrap/libBornAgainSample.py
@@ -8225,34 +8225,6 @@ class LayerRoughness(ISampleNode):
 # Register LayerRoughness in _libBornAgainSample:
 _libBornAgainSample.LayerRoughness_swigregister(LayerRoughness)
 
-
-def generateZValues(n_points, z_min, z_max):
-    r"""
-    generateZValues(int n_points, double z_min, double z_max) -> vdouble1d_t
-    std::vector< double > swigAPI::generateZValues(int n_points, double z_min, double z_max)
-
-    """
-    return _libBornAgainSample.generateZValues(n_points, z_min, z_max)
-
-def materialProfileSLD(multilayer, n_points, z_min, z_max):
-    r"""
-    materialProfileSLD(MultiLayer multilayer, int n_points, double z_min, double z_max) -> vector_complex_t
-    std::vector< complex_t > swigAPI::materialProfileSLD(const MultiLayer &multilayer, int n_points, double z_min, double z_max)
-
-    Calculate average material profile for given multilayer. 
-
-    """
-    return _libBornAgainSample.materialProfileSLD(multilayer, n_points, z_min, z_max)
-
-def defaultMaterialProfileLimits(multilayer):
-    r"""
-    defaultMaterialProfileLimits(MultiLayer multilayer) -> pvacuum_double_t
-    std::pair< double, double > swigAPI::defaultMaterialProfileLimits(const MultiLayer &multilayer)
-
-    Get default z limits for generating a material profile. 
-
-    """
-    return _libBornAgainSample.defaultMaterialProfileLimits(multilayer)
 class Layer(ISampleNode):
     r"""
 
@@ -11710,22 +11682,3 @@ class SampleBuilderFactory(SampleBuilderFactoryTemp):
 _libBornAgainSample.SampleBuilderFactory_swigregister(SampleBuilderFactory)
 
 
-def materialProfile(multilayer, n_points=400, z_min=None, z_max=None):
-    """
-    Creates a material profile from the given multilayer. If no limits are given,
-    it will provide sensible default values, considering the included particles and
-    interface roughnesses.
-    :param multilayer: bornagain.MultiLayer object
-    :param n_points: number of points to generate
-    :param z_min: starting value for z
-    :param z_max: ending value for z
-    :return: numpy arrays containing z positions and the complex material values in those positions
-    """
-    def_z_min, def_z_max = defaultMaterialProfileLimits(multilayer)
-    z_min = def_z_min if z_min is None else z_min
-    z_max = def_z_max if z_max is None else z_max
-    z_points = generateZValues(n_points, z_min, z_max)
-    material_values = materialProfileSLD(multilayer, n_points, z_min, z_max)
-    return (z_points, material_values)
-
-
diff --git a/auto/Wrap/libBornAgainSample_wrap.cpp b/auto/Wrap/libBornAgainSample_wrap.cpp
index 63419f3fdbde2b6b62041f5464806b749f166aba..3928d0d36a3a40200f5781855c34ffb777c00e87 100644
--- a/auto/Wrap/libBornAgainSample_wrap.cpp
+++ b/auto/Wrap/libBornAgainSample_wrap.cpp
@@ -6841,7 +6841,6 @@ SWIGINTERN void std_vector_Sl_std_pair_Sl_double_Sc_double_Sg__Sg__insert__SWIG_
 #include "Sample/Particle/ParticleComposition.h"
 #include "Sample/Particle/ParticleCoreShell.h"
 #include "Sample/Particle/SlicedParticle.h"
-#include "Sample/Processed/MultiLayerFuncs.h"
 #include "Sample/RT/SimulationOptions.h"
 #include "Sample/SampleBuilderEngine/ISampleBuilder.h"
 #include "Sample/Scattering/IFormFactorDecorator.h"
@@ -56106,119 +56105,6 @@ SWIGINTERN PyObject *LayerRoughness_swiginit(PyObject *SWIGUNUSEDPARM(self), PyO
   return SWIG_Python_InitShadowInstance(args);
 }
 
-SWIGINTERN PyObject *_wrap_generateZValues(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  int arg1 ;
-  double arg2 ;
-  double arg3 ;
-  int val1 ;
-  int ecode1 = 0 ;
-  double val2 ;
-  int ecode2 = 0 ;
-  double val3 ;
-  int ecode3 = 0 ;
-  PyObject *swig_obj[3] ;
-  std::vector< double,std::allocator< double > > result;
-  
-  if (!SWIG_Python_UnpackTuple(args, "generateZValues", 3, 3, swig_obj)) SWIG_fail;
-  ecode1 = SWIG_AsVal_int(swig_obj[0], &val1);
-  if (!SWIG_IsOK(ecode1)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "generateZValues" "', argument " "1"" of type '" "int""'");
-  } 
-  arg1 = static_cast< int >(val1);
-  ecode2 = SWIG_AsVal_double(swig_obj[1], &val2);
-  if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "generateZValues" "', argument " "2"" of type '" "double""'");
-  } 
-  arg2 = static_cast< double >(val2);
-  ecode3 = SWIG_AsVal_double(swig_obj[2], &val3);
-  if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "generateZValues" "', argument " "3"" of type '" "double""'");
-  } 
-  arg3 = static_cast< double >(val3);
-  result = swigAPI::generateZValues(arg1,arg2,arg3);
-  resultobj = swig::from(static_cast< std::vector< double,std::allocator< double > > >(result));
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_materialProfileSLD(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  MultiLayer *arg1 = 0 ;
-  int arg2 ;
-  double arg3 ;
-  double arg4 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  int val2 ;
-  int ecode2 = 0 ;
-  double val3 ;
-  int ecode3 = 0 ;
-  double val4 ;
-  int ecode4 = 0 ;
-  PyObject *swig_obj[4] ;
-  std::vector< complex_t,std::allocator< complex_t > > result;
-  
-  if (!SWIG_Python_UnpackTuple(args, "materialProfileSLD", 4, 4, swig_obj)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1, SWIGTYPE_p_MultiLayer,  0  | 0);
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "materialProfileSLD" "', argument " "1"" of type '" "MultiLayer const &""'"); 
-  }
-  if (!argp1) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "materialProfileSLD" "', argument " "1"" of type '" "MultiLayer const &""'"); 
-  }
-  arg1 = reinterpret_cast< MultiLayer * >(argp1);
-  ecode2 = SWIG_AsVal_int(swig_obj[1], &val2);
-  if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "materialProfileSLD" "', argument " "2"" of type '" "int""'");
-  } 
-  arg2 = static_cast< int >(val2);
-  ecode3 = SWIG_AsVal_double(swig_obj[2], &val3);
-  if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "materialProfileSLD" "', argument " "3"" of type '" "double""'");
-  } 
-  arg3 = static_cast< double >(val3);
-  ecode4 = SWIG_AsVal_double(swig_obj[3], &val4);
-  if (!SWIG_IsOK(ecode4)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "materialProfileSLD" "', argument " "4"" of type '" "double""'");
-  } 
-  arg4 = static_cast< double >(val4);
-  result = swigAPI::materialProfileSLD((MultiLayer const &)*arg1,arg2,arg3,arg4);
-  resultobj = swig::from(static_cast< std::vector< std::complex< double >,std::allocator< std::complex< double > > > >(result));
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_defaultMaterialProfileLimits(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  MultiLayer *arg1 = 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject *swig_obj[1] ;
-  std::pair< double,double > result;
-  
-  if (!args) SWIG_fail;
-  swig_obj[0] = args;
-  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1, SWIGTYPE_p_MultiLayer,  0  | 0);
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "defaultMaterialProfileLimits" "', argument " "1"" of type '" "MultiLayer const &""'"); 
-  }
-  if (!argp1) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "defaultMaterialProfileLimits" "', argument " "1"" of type '" "MultiLayer const &""'"); 
-  }
-  arg1 = reinterpret_cast< MultiLayer * >(argp1);
-  result = swigAPI::defaultMaterialProfileLimits((MultiLayer const &)*arg1);
-  resultobj = swig::from(static_cast< std::pair< double,double > >(result));
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
 SWIGINTERN PyObject *_wrap_new_Layer__SWIG_0(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) {
   PyObject *resultobj = 0;
   SwigValueWrapper< Material > arg1 ;
@@ -72571,25 +72457,6 @@ static PyMethodDef SwigMethods[] = {
 	 { "delete_LayerRoughness", _wrap_delete_LayerRoughness, METH_O, "delete_LayerRoughness(LayerRoughness self)"},
 	 { "LayerRoughness_swigregister", LayerRoughness_swigregister, METH_O, NULL},
 	 { "LayerRoughness_swiginit", LayerRoughness_swiginit, METH_VARARGS, NULL},
-	 { "generateZValues", _wrap_generateZValues, METH_VARARGS, "\n"
-		"generateZValues(int n_points, double z_min, double z_max) -> vdouble1d_t\n"
-		"std::vector< double > swigAPI::generateZValues(int n_points, double z_min, double z_max)\n"
-		"\n"
-		""},
-	 { "materialProfileSLD", _wrap_materialProfileSLD, METH_VARARGS, "\n"
-		"materialProfileSLD(MultiLayer multilayer, int n_points, double z_min, double z_max) -> vector_complex_t\n"
-		"std::vector< complex_t > swigAPI::materialProfileSLD(const MultiLayer &multilayer, int n_points, double z_min, double z_max)\n"
-		"\n"
-		"Calculate average material profile for given multilayer. \n"
-		"\n"
-		""},
-	 { "defaultMaterialProfileLimits", _wrap_defaultMaterialProfileLimits, METH_O, "\n"
-		"defaultMaterialProfileLimits(MultiLayer multilayer) -> pvacuum_double_t\n"
-		"std::pair< double, double > swigAPI::defaultMaterialProfileLimits(const MultiLayer &multilayer)\n"
-		"\n"
-		"Get default z limits for generating a material profile. \n"
-		"\n"
-		""},
 	 { "new_Layer", _wrap_new_Layer, METH_VARARGS, "\n"
 		"Layer(Material material, double thickness=0)\n"
 		"Layer::Layer(Material material, double thickness=0)\n"
diff --git a/cmake/BornAgain/MakeLib.cmake b/cmake/BornAgain/MakeLib.cmake
index 3e2d6ea84ae001c04cd531fe5d5e03ea6b34e0fe..192c648da29988d59279bd4124fe554007fb05d6 100644
--- a/cmake/BornAgain/MakeLib.cmake
+++ b/cmake/BornAgain/MakeLib.cmake
@@ -1,8 +1,8 @@
 # Configure one component library.
 
-function(MakeLib name lib tmpdir)
+function(MakeLib name lib tmpdir withPython)
 
-    if(BORNAGAIN_PYTHON)
+    if(withPython)
         list(APPEND source_files ${AUTO_DIR}/lib${lib}_wrap.cpp)
     endif()
 
@@ -15,9 +15,9 @@ function(MakeLib name lib tmpdir)
 
     set(${lib}_LIBRARY_TYPE SHARED)
 
-    if(BORNAGAIN_PYTHON)
+    if(withPython)
         SwigLib(${name} ${lib} ${tmpdir})
-    endif(BORNAGAIN_PYTHON)
+    endif()
 
     install(TARGETS ${lib} DESTINATION ${destination_lib} COMPONENT Libraries)
     foreach(file ${include_files})