From a9820203c55181f62d540b4f2af72ea26837683a Mon Sep 17 00:00:00 2001
From: Gennady Pospelov <g.pospelov@fz-juelich.de>
Date: Wed, 29 Apr 2020 16:43:42 +0200
Subject: [PATCH] Beautify Core directory

---
 Core/Aggregate/FTDecayFunctions.cpp           |  27 +-
 Core/Aggregate/FTDecayFunctions.h             |  33 +-
 Core/Aggregate/FTDistributions1D.cpp          |  67 ++-
 Core/Aggregate/FTDistributions1D.h            |  18 +-
 Core/Aggregate/FTDistributions2D.cpp          |   8 +-
 Core/Aggregate/FTDistributions2D.h            |  13 +-
 Core/Aggregate/FormFactorCoherentPart.h       |   1 +
 Core/Aggregate/FormFactorCoherentSum.h        |   4 +-
 Core/Aggregate/IDistribution1DSampler.h       |   2 +-
 Core/Aggregate/IDistribution2DSampler.cpp     |   6 +-
 Core/Aggregate/IDistribution2DSampler.h       |  26 +-
 Core/Aggregate/IInterferenceFunction.cpp      |  17 +-
 Core/Aggregate/IInterferenceFunction.h        |   9 +-
 Core/Aggregate/IPeakShape.cpp                 |  28 +-
 Core/Aggregate/IPeakShape.h                   |  12 +-
 .../InterferenceFunction1DLattice.cpp         |  14 +-
 .../InterferenceFunction2DLattice.cpp         |  46 +-
 .../Aggregate/InterferenceFunction2DLattice.h |  10 +-
 .../InterferenceFunction2DParaCrystal.cpp     |  43 +-
 .../InterferenceFunction2DParaCrystal.h       |  17 +-
 .../InterferenceFunction2DSuperLattice.cpp    |  59 +--
 .../InterferenceFunction2DSuperLattice.h      |  18 +-
 .../InterferenceFunction3DLattice.cpp         |  19 +-
 .../Aggregate/InterferenceFunction3DLattice.h |   3 +-
 .../InterferenceFunctionFinite2DLattice.cpp   |  61 ++-
 .../InterferenceFunctionFinite2DLattice.h     |  14 +-
 .../InterferenceFunctionFinite3DLattice.cpp   |   5 +-
 .../InterferenceFunctionFinite3DLattice.h     |   3 +-
 .../InterferenceFunctionHardDisk.cpp          |  71 +--
 Core/Aggregate/InterferenceFunctionHardDisk.h |   1 +
 .../InterferenceFunctionRadialParaCrystal.cpp |  86 ++--
 .../InterferenceFunctionRadialParaCrystal.h   |   8 +-
 Core/Aggregate/InterferenceFunctionTwin.cpp   |  10 +-
 Core/Aggregate/ParticleLayout.cpp             |  44 +-
 Core/Aggregate/ParticleLayout.h               |   8 +-
 Core/Basics/BornAgainNamespace.h              |   2 +-
 Core/Basics/Complex.h                         |  10 +-
 Core/Basics/Exceptions.cpp                    |  31 +-
 Core/Basics/Exceptions.h                      |   7 +-
 Core/Basics/ICloneable.cpp                    |   4 +-
 Core/Basics/ICloneable.h                      |   6 +-
 Core/Basics/INamed.cpp                        |   2 -
 Core/Basics/INamed.h                          |   2 +-
 Core/Basics/ISingleton.h                      |  27 +-
 Core/Basics/Macros.h                          |  31 +-
 Core/Basics/MathConstants.h                   |  28 +-
 Core/Basics/PhysicalConstants.h               |  19 +-
 Core/Beam/Beam.cpp                            |  25 +-
 Core/Beam/Beam.h                              |   8 +-
 Core/Beam/IFootprintFactor.cpp                |   3 +-
 Core/Beam/IFootprintFactor.h                  |   2 +-
 Core/Binning/Bin.cpp                          |  19 +-
 Core/Binning/Bin.h                            |  32 +-
 Core/Binning/ConstKBinAxis.cpp                |  48 +-
 Core/Binning/CustomBinAxis.cpp                |  49 +-
 Core/Binning/CustomBinAxis.h                  |   2 +-
 Core/Binning/FixedBinAxis.cpp                 |  68 +--
 Core/Binning/FixedBinAxis.h                   |  10 +-
 Core/Binning/IAxis.cpp                        |   2 +-
 Core/Binning/IAxis.h                          |  29 +-
 Core/Binning/IPixel.h                         |  12 +-
 Core/Binning/PointwiseAxis.cpp                |  13 +-
 Core/Binning/PointwiseAxis.h                  |  11 +-
 Core/Binning/VariableBinAxis.cpp              |  97 ++--
 Core/Binning/VariableBinAxis.h                |   4 +-
 Core/Computation/ComputationStatus.h          |   4 +-
 Core/Computation/ConstantBackground.cpp       |   3 +-
 Core/Computation/ConstantBackground.h         |   1 +
 Core/Computation/DWBAComputation.h            |   5 +-
 Core/Computation/DWBASingleComputation.cpp    |   7 +-
 Core/Computation/DelayedProgressCounter.cpp   |  11 +-
 Core/Computation/DelayedProgressCounter.h     |   1 +
 Core/Computation/DepthProbeComputation.cpp    |   7 +-
 Core/Computation/DepthProbeComputation.h      |   3 +-
 .../Computation/DepthProbeComputationTerm.cpp |   8 +-
 Core/Computation/GISASSpecularComputation.h   |   1 +
 Core/Computation/IBackground.h                |   2 +-
 Core/Computation/IComputation.cpp             |   6 +-
 Core/Computation/MultiLayerUtils.cpp          |   5 +-
 .../Computation/ParticleLayoutComputation.cpp |  10 +-
 Core/Computation/ParticleLayoutComputation.h  |   4 +-
 Core/Computation/PoissonNoiseBackground.cpp   |   4 +-
 Core/Computation/ProcessedLayout.h            |   3 +-
 Core/Computation/ProcessedSample.cpp          |   2 +-
 Core/Computation/ProfileHelper.cpp            |  13 +-
 Core/Computation/ProfileHelper.h              |   1 +
 Core/Computation/ProgressHandler.cpp          |   8 +-
 Core/Computation/ProgressHandler.h            |  15 +-
 .../RoughMultiLayerComputation.cpp            | 118 ++---
 Core/Computation/Slice.h                      |   3 +-
 Core/Computation/SpecularComputation.cpp      |  10 +-
 .../FormFactorDecoratorMaterial.cpp           |  20 +-
 .../FormFactorDecoratorPositionFactor.cpp     |  17 +-
 .../FormFactorDecoratorPositionFactor.h       |   6 +-
 .../FormFactorDecoratorRotation.cpp           |  15 +-
 .../IFormFactorDecorator.h                    |  28 +-
 Core/Export/ExportToPython.cpp                |   9 +-
 Core/Export/ExportToPython.h                  |   7 +-
 Core/Export/INodeUtils.h                      |  18 +-
 Core/Export/PythonFormatting.cpp              |  18 +-
 Core/Export/PythonFormatting.h                |   2 +-
 Core/Export/SampleLabelHandler.cpp            |  45 +-
 Core/Export/SampleLabelHandler.h              |   4 +-
 Core/Export/SampleToPython.cpp                |   3 +-
 Core/Export/SimulationToPython.cpp            |  24 +-
 Core/Fitting/FitObjective.cpp                 |  30 +-
 Core/Fitting/FitObjective.h                   |   4 +-
 Core/Fitting/FitObserver.h                    |  36 +-
 Core/Fitting/FitPrintService.cpp              |  25 +-
 Core/Fitting/FitPrintService.h                |   2 +-
 Core/Fitting/FitStatus.cpp                    |   8 +-
 Core/Fitting/FitStatus.h                      |  11 +-
 Core/Fitting/FitTypes.h                       |   5 +-
 Core/Fitting/IterationInfo.cpp                |  11 +-
 Core/Fitting/IterationInfo.h                  |   3 +-
 Core/Fitting/ObjectiveMetric.cpp              |  50 +-
 Core/Fitting/ObjectiveMetricUtils.cpp         |  15 +-
 Core/Fitting/PyFittingCallbacks.h             |   4 +-
 Core/Fitting/SimDataPair.cpp                  |  36 +-
 Core/Fitting/SimDataPair.h                    |   2 +-
 Core/HardParticle/FormFactorAnisoPyramid.cpp  |  74 ++-
 Core/HardParticle/FormFactorAnisoPyramid.h    |  10 +-
 Core/HardParticle/FormFactorBox.cpp           |  12 +-
 Core/HardParticle/FormFactorBox.h             |  10 +-
 Core/HardParticle/FormFactorCone.cpp          |  35 +-
 Core/HardParticle/FormFactorCone.h            |  10 +-
 Core/HardParticle/FormFactorCone6.cpp         |  90 ++--
 Core/HardParticle/FormFactorCone6.h           |  10 +-
 Core/HardParticle/FormFactorCuboctahedron.cpp | 125 +++--
 Core/HardParticle/FormFactorCuboctahedron.h   |   8 +-
 Core/HardParticle/FormFactorCylinder.cpp      |   2 +-
 Core/HardParticle/FormFactorCylinder.h        |   6 +-
 Core/HardParticle/FormFactorDodecahedron.cpp  |  83 ++-
 Core/HardParticle/FormFactorDodecahedron.h    |   8 +-
 Core/HardParticle/FormFactorDot.cpp           |   6 +-
 .../FormFactorEllipsoidalCylinder.cpp         |  27 +-
 .../FormFactorEllipsoidalCylinder.h           |   6 +-
 Core/HardParticle/FormFactorFullSphere.cpp    |  28 +-
 Core/HardParticle/FormFactorFullSphere.h      |   8 +-
 Core/HardParticle/FormFactorFullSpheroid.cpp  |  28 +-
 Core/HardParticle/FormFactorFullSpheroid.h    |   6 +-
 Core/HardParticle/FormFactorHemiEllipsoid.cpp |  39 +-
 Core/HardParticle/FormFactorHemiEllipsoid.h   |  10 +-
 Core/HardParticle/FormFactorIcosahedron.cpp   |  87 ++--
 Core/HardParticle/FormFactorIcosahedron.h     |   8 +-
 Core/HardParticle/FormFactorLongBox.cpp       |   7 +-
 Core/HardParticle/FormFactorLongBox.h         |  12 +-
 Core/HardParticle/FormFactorLongBoxGauss.cpp  |   2 +-
 Core/HardParticle/FormFactorLongBoxGauss.h    |  12 +-
 .../HardParticle/FormFactorLongBoxLorentz.cpp |   4 +-
 Core/HardParticle/FormFactorLongBoxLorentz.h  |  12 +-
 .../FormFactorLongRipple1Gauss.cpp            |  33 +-
 .../HardParticle/FormFactorLongRipple1Gauss.h |   6 +-
 .../FormFactorLongRipple1Lorentz.cpp          |  37 +-
 .../FormFactorLongRipple1Lorentz.h            |   6 +-
 .../FormFactorLongRipple2Gauss.cpp            |  23 +-
 .../HardParticle/FormFactorLongRipple2Gauss.h |   7 +-
 .../FormFactorLongRipple2Lorentz.cpp          |  20 +-
 .../FormFactorLongRipple2Lorentz.h            |   8 +-
 Core/HardParticle/FormFactorPolyhedron.cpp    | 473 +++++++++---------
 Core/HardParticle/FormFactorPolyhedron.h      |  44 +-
 Core/HardParticle/FormFactorPrism3.cpp        |  22 +-
 Core/HardParticle/FormFactorPrism3.h          |   8 +-
 Core/HardParticle/FormFactorPrism6.cpp        |  24 +-
 Core/HardParticle/FormFactorPrism6.h          |   8 +-
 Core/HardParticle/FormFactorPyramid.cpp       |  67 ++-
 Core/HardParticle/FormFactorPyramid.h         |   8 +-
 Core/HardParticle/FormFactorRipple1.cpp       |  33 +-
 Core/HardParticle/FormFactorRipple1.h         |   6 +-
 Core/HardParticle/FormFactorRipple2.cpp       |  22 +-
 Core/HardParticle/FormFactorRipple2.h         |   8 +-
 Core/HardParticle/FormFactorTetrahedron.cpp   |  73 ++-
 Core/HardParticle/FormFactorTetrahedron.h     |   8 +-
 Core/HardParticle/FormFactorTriangle.cpp      |  20 +-
 Core/HardParticle/FormFactorTruncatedCube.cpp |  77 ++-
 Core/HardParticle/FormFactorTruncatedCube.h   |   8 +-
 .../FormFactorTruncatedSphere.cpp             |  27 +-
 Core/HardParticle/FormFactorTruncatedSphere.h |  10 +-
 .../FormFactorTruncatedSpheroid.cpp           |  34 +-
 .../FormFactorTruncatedSpheroid.h             |   8 +-
 Core/InputOutput/DataFormatUtils.cpp          |  60 +--
 Core/InputOutput/DataFormatUtils.h            |   5 +-
 Core/InputOutput/IntensityDataIOFactory.cpp   |   7 +-
 Core/InputOutput/IntensityDataIOFactory.h     |   4 +-
 Core/InputOutput/OutputDataReadFactory.cpp    |  14 +-
 Core/InputOutput/OutputDataReadFactory.h      |   3 +-
 Core/InputOutput/OutputDataReadStrategy.cpp   |  84 ++--
 Core/InputOutput/OutputDataReadStrategy.h     |   7 +-
 Core/InputOutput/OutputDataReader.cpp         |  29 +-
 Core/InputOutput/OutputDataWriteFactory.cpp   |  19 +-
 Core/InputOutput/OutputDataWriteFactory.h     |   2 +-
 Core/InputOutput/OutputDataWriteStrategy.h    |   3 +-
 Core/InputOutput/OutputDataWriter.cpp         |  29 +-
 Core/InputOutput/TiffHandler.cpp              | 124 +++--
 Core/InputOutput/TiffHandler.h                |   2 +-
 Core/InputOutput/boost_streams.h              |  11 +-
 Core/Instrument/AngularSpecScan.cpp           |  42 +-
 Core/Instrument/AngularSpecScan.h             |   2 +-
 Core/Instrument/ArrayUtils.cpp                |  12 +-
 Core/Instrument/ArrayUtils.h                  |  68 +--
 Core/Instrument/AxisNames.cpp                 |   2 +-
 Core/Instrument/AxisNames.h                   |   2 +-
 Core/Instrument/ChiSquaredModule.cpp          |   8 +-
 Core/Instrument/ChiSquaredModule.h            |   5 +-
 .../ConvolutionDetectorResolution.cpp         | 106 ++--
 .../ConvolutionDetectorResolution.h           |  14 +-
 Core/Instrument/Convolve.cpp                  | 215 ++++----
 Core/Instrument/Convolve.h                    |  38 +-
 Core/Instrument/CumulativeValue.cpp           |  12 +-
 Core/Instrument/CumulativeValue.h             |   8 +-
 Core/Instrument/DetectionProperties.cpp       |  41 +-
 Core/Instrument/DetectionProperties.h         |  11 +-
 Core/Instrument/DetectorContext.cpp           |   4 +-
 Core/Instrument/DetectorFunctions.cpp         |  14 +-
 Core/Instrument/DetectorFunctions.h           |  15 +-
 Core/Instrument/DetectorMask.cpp              |  44 +-
 Core/Instrument/FourierTransform.cpp          |   8 +-
 Core/Instrument/Histogram1D.cpp               |  13 +-
 Core/Instrument/Histogram1D.h                 |   4 +-
 Core/Instrument/Histogram2D.cpp               |  61 ++-
 Core/Instrument/Histogram2D.h                 |  17 +-
 Core/Instrument/IChiSquaredModule.cpp         |  12 +-
 Core/Instrument/IDetector.cpp                 |  36 +-
 Core/Instrument/IDetector.h                   |  22 +-
 Core/Instrument/IDetectorResolution.h         |   5 +-
 Core/Instrument/IHistogram.cpp                |  69 ++-
 Core/Instrument/IHistogram.h                  |  14 +-
 Core/Instrument/IIntensityFunction.cpp        |  11 +-
 Core/Instrument/IIntensityFunction.h          |  10 +-
 Core/Instrument/IIntensityNormalizer.cpp      |  18 +-
 Core/Instrument/IIntensityNormalizer.h        |  31 +-
 Core/Instrument/IResolutionFunction2D.h       |   4 +-
 Core/Instrument/ISpecularScan.cpp             |   4 +-
 Core/Instrument/ISpecularScan.h               |   8 +-
 Core/Instrument/IUnitConverter.cpp            |  15 +-
 Core/Instrument/IUnitConverter.h              |  20 +-
 Core/Instrument/Instrument.cpp                |  24 +-
 Core/Instrument/Instrument.h                  |   8 +-
 Core/Instrument/IntensityDataFunctions.cpp    |   7 +-
 Core/Instrument/IsGISAXSDetector.cpp          |   9 +-
 Core/Instrument/IsGISAXSDetector.h            |  10 +-
 Core/Instrument/LLData.cpp                    |   4 +-
 Core/Instrument/LLData.h                      | 116 ++---
 Core/Instrument/OutputData.cpp                |  32 +-
 Core/Instrument/OutputData.h                  | 265 +++++-----
 Core/Instrument/OutputDataIterator.h          |  68 ++-
 Core/Instrument/PyArrayImportUtils.h          |  14 +-
 Core/Instrument/QSpecScan.cpp                 |  27 +-
 Core/Instrument/QSpecScan.h                   |   4 +-
 Core/Instrument/RectangularDetector.cpp       |  90 ++--
 Core/Instrument/RectangularDetector.h         |   6 +-
 Core/Instrument/RegionOfInterest.cpp          |  77 ++-
 Core/Instrument/RegionOfInterest.h            |  29 +-
 .../ResolutionFunction2DGaussian.cpp          |   2 +-
 .../Instrument/ResolutionFunction2DGaussian.h |   6 +-
 Core/Instrument/SampleBuilderNode.cpp         |   8 +-
 Core/Instrument/SampleProvider.cpp            |  22 +-
 Core/Instrument/SampleProvider.h              |   2 +-
 Core/Instrument/ScanResolution.cpp            |  84 ++--
 Core/Instrument/ScanResolution.h              |   6 +-
 Core/Instrument/SimpleUnitConverters.cpp      |  96 ++--
 Core/Instrument/SimpleUnitConverters.h        |   6 +-
 Core/Instrument/SimulationArea.cpp            |  20 +-
 Core/Instrument/SimulationArea.h              |   4 +-
 Core/Instrument/SimulationAreaIterator.cpp    |  23 +-
 Core/Instrument/SimulationAreaIterator.h      |  22 +-
 Core/Instrument/SimulationResult.cpp          |  33 +-
 Core/Instrument/SimulationResult.h            |   9 +-
 Core/Instrument/SpecularDetector1D.cpp        |   6 +-
 Core/Instrument/SpecularDetector1D.h          |   3 +-
 Core/Instrument/SphericalDetector.cpp         |  31 +-
 Core/Instrument/SphericalDetector.h           |   7 +-
 Core/Instrument/UnitConverter1D.cpp           |  26 +-
 Core/Instrument/UnitConverter1D.h             |   5 +-
 Core/Instrument/UnitConverterUtils.cpp        |  13 +-
 Core/Instrument/UnitConverterUtils.h          |  10 +-
 Core/Instrument/VarianceFunctions.cpp         |   4 +-
 Core/Lattice/ILatticeOrientation.cpp          |  58 +--
 Core/Lattice/ILatticeOrientation.h            |  10 +-
 Core/Lattice/ISelectionRule.h                 |  11 +-
 Core/Lattice/Lattice.cpp                      | 102 ++--
 Core/Lattice/Lattice.h                        |  20 +-
 Core/Lattice/Lattice2D.cpp                    |  70 ++-
 Core/Lattice/Lattice2D.h                      |   8 +-
 Core/Lattice/LatticeUtils.cpp                 |   8 +-
 Core/Lattice/LatticeUtils.h                   |   8 +-
 Core/Mask/Ellipse.cpp                         |  18 +-
 Core/Mask/Ellipse.h                           |   5 +-
 Core/Mask/IShape2D.h                          |  10 +-
 Core/Mask/InfinitePlane.h                     |   3 +-
 Core/Mask/Line.cpp                            |  29 +-
 Core/Mask/Line.h                              |  15 +-
 Core/Mask/Polygon.cpp                         |  43 +-
 Core/Mask/Polygon.h                           |   3 +-
 Core/Mask/Rectangle.cpp                       |   9 +-
 Core/Mask/Rectangle.h                         |   7 +-
 Core/Material/BaseMaterialImpl.h              |  12 +-
 Core/Material/MagneticMaterialImpl.cpp        |  30 +-
 Core/Material/MagneticMaterialImpl.h          |   9 +-
 Core/Material/Material.cpp                    |  32 +-
 Core/Material/Material.h                      |  18 +-
 Core/Material/MaterialBySLDImpl.cpp           |  20 +-
 Core/Material/MaterialBySLDImpl.h             |  11 +-
 Core/Material/MaterialFactoryFuncs.cpp        |  29 +-
 Core/Material/MaterialUtils.cpp               |  43 +-
 Core/Material/MaterialUtils.h                 |   5 +-
 Core/Material/RefractiveMaterialImpl.cpp      |  19 +-
 Core/Material/RefractiveMaterialImpl.h        |  17 +-
 .../DecouplingApproximationStrategy.cpp       |  20 +-
 Core/Multilayer/FormFactorBAPol.cpp           |  11 +-
 Core/Multilayer/FormFactorBAPol.h             |   3 +-
 Core/Multilayer/FormFactorDWBA.cpp            |  23 +-
 Core/Multilayer/FormFactorDWBA.h              |   3 +-
 Core/Multilayer/FormFactorDWBAPol.cpp         | 171 +++----
 Core/Multilayer/FormFactorDWBAPol.h           |   3 +-
 Core/Multilayer/IFresnelMap.cpp               |   6 +-
 .../IInterferenceFunctionStrategy.cpp         |  38 +-
 .../IInterferenceFunctionStrategy.h           |   4 +-
 Core/Multilayer/ILayerRTCoefficients.h        |  36 +-
 Core/Multilayer/IMultiLayerBuilder.cpp        |   1 -
 Core/Multilayer/IMultiLayerBuilder.h          |  10 +-
 Core/Multilayer/ISpecularStrategy.h           |  10 +-
 Core/Multilayer/InterferenceFunctionUtils.cpp |  18 +-
 Core/Multilayer/InterferenceFunctionUtils.h   |  17 +-
 Core/Multilayer/Layer.cpp                     |  15 +-
 Core/Multilayer/Layer.h                       |   2 +-
 Core/Multilayer/LayerFillLimits.cpp           |  39 +-
 Core/Multilayer/LayerFillLimits.h             |   5 +-
 Core/Multilayer/LayerInterface.cpp            |   4 +-
 Core/Multilayer/LayerRoughness.cpp            |  27 +-
 Core/Multilayer/LayerRoughness.h              |  18 +-
 Core/Multilayer/LayoutStrategyBuilder.cpp     |  18 +-
 Core/Multilayer/LayoutStrategyBuilder.h       |   6 +-
 Core/Multilayer/MatrixFresnelMap.h            |   6 +-
 Core/Multilayer/MatrixRTCoefficients.cpp      | 288 ++++++-----
 Core/Multilayer/MatrixRTCoefficients.h        |  34 +-
 Core/Multilayer/MatrixRTCoefficients_v2.cpp   |  16 +-
 Core/Multilayer/MatrixRTCoefficients_v2.h     |   2 +-
 Core/Multilayer/MultiLayer.cpp                |   1 -
 Core/Multilayer/MultiLayer.h                  |   2 +-
 Core/Multilayer/MultiLayerFuncs.cpp           |   2 +-
 Core/Multilayer/MultiLayerFuncs.h             |   1 -
 Core/Multilayer/RoughnessModels.cpp           |   7 +-
 Core/Multilayer/RoughnessModels.h             |   3 -
 Core/Multilayer/SSCAHelper.h                  |   7 +-
 Core/Multilayer/SSCApproximationStrategy.cpp  |  21 +-
 Core/Multilayer/ScalarFresnelMap.cpp          |   3 +-
 Core/Multilayer/ScalarFresnelMap.h            |   6 +-
 Core/Multilayer/ScalarRTCoefficients.h        |   7 +-
 .../SpecularMagneticOldStrategy.cpp           |  27 +-
 Core/Multilayer/SpecularMagneticOldStrategy.h |  10 +-
 Core/Multilayer/SpecularMagneticStrategy.cpp  |  67 ++-
 Core/Multilayer/SpecularMagneticStrategy.h    |   9 +-
 Core/Multilayer/SpecularScalarNCStrategy.cpp  |  22 +-
 Core/Multilayer/SpecularScalarNCStrategy.h    |  10 +-
 Core/Multilayer/SpecularScalarStrategy.cpp    |  47 +-
 Core/Multilayer/SpecularScalarStrategy.h      |  12 +-
 .../Multilayer/SpecularScalarTanhStrategy.cpp |   7 +-
 Core/Multilayer/SpecularScalarTanhStrategy.h  |   6 +-
 Core/Multilayer/SpecularStrategyBuilder.cpp   |   2 +-
 Core/Multilayer/SpecularStrategyBuilder.h     |   2 +-
 Core/Parametrization/DistributionHandler.cpp  |  32 +-
 Core/Parametrization/DistributionHandler.h    |  14 +-
 Core/Parametrization/Distributions.cpp        |  17 +-
 Core/Parametrization/Distributions.h          |  92 ++--
 Core/Parametrization/INode.cpp                |  20 +-
 Core/Parametrization/INode.h                  |  14 +-
 Core/Parametrization/INodeVisitor.cpp         |   4 +-
 Core/Parametrization/INodeVisitor.h           |   2 +-
 Core/Parametrization/IParameter.h             |  30 +-
 Core/Parametrization/IParameterized.cpp       |  25 +-
 Core/Parametrization/IParameterized.h         |   7 +-
 Core/Parametrization/NodeIterator.cpp         |  10 +-
 Core/Parametrization/NodeIterator.h           |  46 +-
 Core/Parametrization/NodeUtils.cpp            |  76 +--
 Core/Parametrization/NodeUtils.h              |  15 +-
 .../Parametrization/ParameterDistribution.cpp |  73 ++-
 Core/Parametrization/ParameterDistribution.h  |  10 +-
 Core/Parametrization/ParameterPattern.h       |   2 +-
 Core/Parametrization/ParameterPool.cpp        |  54 +-
 Core/Parametrization/ParameterPool.h          |   9 +-
 Core/Parametrization/ParameterSample.h        |   2 +-
 Core/Parametrization/ParameterUtils.cpp       |  24 +-
 Core/Parametrization/ParameterUtils.h         |   2 +-
 Core/Parametrization/RangedDistributions.cpp  |  50 +-
 Core/Parametrization/RangedDistributions.h    |  11 +-
 Core/Parametrization/RealParameter.cpp        |  17 +-
 Core/Parametrization/RealParameter.h          |  13 +-
 Core/Parametrization/SimulationOptions.cpp    |   7 +-
 Core/Parametrization/SimulationOptions.h      |   3 +-
 Core/Parametrization/ThreadInfo.h             |  10 +-
 Core/Parametrization/Unit.h                   |   2 +-
 Core/Parametrization/Units.h                  |  37 +-
 Core/Particle/Crystal.h                       |   1 +
 Core/Particle/FormFactorCoreShell.cpp         |   9 +-
 Core/Particle/FormFactorCoreShell.h           |   2 +-
 Core/Particle/FormFactorCrystal.cpp           |  20 +-
 Core/Particle/FormFactorCrystal.h             |  14 +-
 Core/Particle/FormFactorWeighted.cpp          |  25 +-
 Core/Particle/FormFactorWeighted.h            |   4 +-
 Core/Particle/HomogeneousRegion.h             |   3 +-
 Core/Particle/IAbstractParticle.cpp           |   1 -
 Core/Particle/IAbstractParticle.h             |   6 +-
 Core/Particle/IClusteredParticles.h           |  12 +-
 Core/Particle/IParticle.cpp                   |  16 +-
 Core/Particle/IParticle.h                     |   5 +-
 Core/Particle/MesoCrystal.cpp                 |  17 +-
 Core/Particle/MesoCrystal.h                   |   2 +-
 Core/Particle/Particle.cpp                    |  22 +-
 Core/Particle/Particle.h                      |   6 +-
 Core/Particle/ParticleComposition.cpp         |  27 +-
 Core/Particle/ParticleComposition.h           |   7 +-
 Core/Particle/ParticleCoreShell.cpp           |  16 +-
 Core/Particle/ParticleCoreShell.h             |   2 +-
 Core/Particle/ParticleDistribution.cpp        |  21 +-
 Core/Particle/SlicedParticle.cpp              |   1 -
 Core/Particle/SlicedParticle.h                |   5 +-
 Core/Particle/TRange.h                        |  10 +-
 Core/Particle/ZLimits.cpp                     |  41 +-
 Core/Particle/ZLimits.h                       |   5 +-
 Core/Scattering/IFormFactor.cpp               |  42 +-
 Core/Scattering/IFormFactor.h                 |  12 +-
 Core/Scattering/IFormFactorBorn.cpp           |  40 +-
 Core/Scattering/IFormFactorBorn.h             |  20 +-
 Core/Scattering/ISample.cpp                   |  13 +-
 Core/Scattering/ISample.h                     |   2 +-
 Core/Scattering/Rotations.cpp                 |  25 +-
 Core/Scattering/Rotations.h                   |   8 +-
 Core/Shapes/AnisoPyramid.cpp                  |   9 +-
 Core/Shapes/BiPyramid.cpp                     |  17 +-
 Core/Shapes/Box.cpp                           |   5 +-
 Core/Shapes/Dodecahedron.cpp                  |  44 +-
 Core/Shapes/Dot.cpp                           |   4 +-
 Core/Shapes/DoubleEllipse.cpp                 |   5 +-
 Core/Shapes/IShape.cpp                        |  39 +-
 Core/Shapes/IShape.h                          |   1 +
 Core/Shapes/Icosahedron.cpp                   |  27 +-
 Core/Shapes/Pyramid3.cpp                      |   9 +-
 Core/Shapes/Pyramid3.h                        |   1 +
 Core/Shapes/Pyramid6.cpp                      |   9 +-
 Core/Shapes/Pyramid6.h                        |   1 +
 Core/Shapes/RippleCosine.cpp                  |  18 +-
 Core/Shapes/RippleSawtooth.cpp                |  20 +-
 Core/Shapes/Triangle.cpp                      |   4 +-
 Core/Shapes/TruncatedCube.cpp                 |  39 +-
 Core/Shapes/TruncatedEllipsoid.cpp            |  21 +-
 Core/Simulation/DepthProbeSimulation.cpp      |  33 +-
 Core/Simulation/DepthProbeSimulation.h        |   4 +-
 Core/Simulation/MPISimulation.cpp             |  16 +-
 Core/Simulation/MPISimulation.h               |   2 +-
 Core/Simulation/Simulation.h                  |  26 +-
 Core/Simulation/SpecularSimulation.cpp        |  30 +-
 Core/Simulation/SpecularSimulation.h          |   6 +-
 Core/SimulationElement/DepthProbeElement.cpp  |  27 +-
 Core/SimulationElement/DepthProbeElement.h    |  14 +-
 .../SimulationElement/PolarizationHandler.cpp |  13 +-
 Core/SimulationElement/PolarizationHandler.h  |   7 +-
 Core/SimulationElement/SimulationElement.cpp  |  64 +--
 Core/SimulationElement/SimulationElement.h    |  30 +-
 .../SpecularSimulationElement.cpp             |   9 +-
 .../SpecularSimulationElement.h               |   8 +-
 Core/SoftParticle/FormFactorDebyeBueche.cpp   |   5 +-
 Core/SoftParticle/FormFactorDebyeBueche.h     |   6 +-
 Core/SoftParticle/FormFactorGauss.cpp         |   7 +-
 Core/SoftParticle/FormFactorGauss.h           |   3 +-
 Core/SoftParticle/FormFactorLorentz.cpp       |  17 +-
 Core/SoftParticle/FormFactorLorentz.h         |   6 +-
 .../FormFactorOrnsteinZernike.cpp             |   5 +-
 Core/SoftParticle/FormFactorOrnsteinZernike.h |   6 +-
 .../FormFactorSphereGaussianRadius.cpp        |  18 +-
 .../FormFactorSphereGaussianRadius.h          |   6 +-
 .../FormFactorSphereLogNormalRadius.cpp       |  19 +-
 .../FormFactorSphereLogNormalRadius.h         |   8 +-
 .../FormFactorSphereUniformRadius.cpp         |  41 +-
 .../FormFactorSphereUniformRadius.h           |   8 +-
 .../StandardSamples/BoxCompositionBuilder.cpp |  54 +-
 Core/StandardSamples/BoxCompositionBuilder.h  |  10 +-
 .../BoxesSquareLatticeBuilder.cpp             |  12 +-
 .../CoreShellParticleBuilder.cpp              |  33 +-
 .../CoreShellParticleBuilder.h                |   5 +-
 .../CustomMorphologyBuilder.cpp               |  60 +--
 .../CylindersAndPrismsBuilder.cpp             |   5 +-
 Core/StandardSamples/CylindersBuilder.cpp     |  25 +-
 Core/StandardSamples/CylindersBuilder.h       |   1 -
 .../HomogeneousMultilayerBuilder.cpp          |  20 +-
 Core/StandardSamples/IFactory.h               |  39 +-
 Core/StandardSamples/IRegistry.h              |  20 +-
 Core/StandardSamples/LatticeBuilder.cpp       |  13 +-
 .../LayersWithAbsorptionBuilder.cpp           |  22 +-
 .../LayersWithAbsorptionBuilder.h             |   2 +-
 .../StandardSamples/MagneticLayersBuilder.cpp |  24 +-
 .../MagneticParticlesBuilder.cpp              |  20 +-
 Core/StandardSamples/MesoCrystalBuilder.cpp   |   7 +-
 Core/StandardSamples/MesoCrystalBuilder.h     |   2 +-
 .../MultiLayerWithNCRoughnessBuilder.cpp      |   7 +-
 .../MultiLayerWithRoughnessBuilder.cpp        |  18 +-
 .../StandardSamples/MultipleLayoutBuilder.cpp |  15 +-
 Core/StandardSamples/ParaCrystalBuilder.cpp   |  56 +--
 Core/StandardSamples/ParaCrystalBuilder.h     |   4 +-
 .../ParticleCompositionBuilder.cpp            |   8 +-
 .../ParticleCompositionBuilder.h              |   2 +-
 .../ParticleDistributionsBuilder.cpp          |  76 ++-
 .../ParticleDistributionsBuilder.h            |   6 +-
 .../ParticleInTheAirBuilder.cpp               |  11 +-
 .../StandardSamples/ParticleInTheAirBuilder.h |   2 +-
 Core/StandardSamples/PercusYevickBuilder.cpp  |  11 +-
 .../PlainMultiLayerBySLDBuilder.cpp           |  12 +-
 Core/StandardSamples/ResonatorBuilder.cpp     |   4 +-
 Core/StandardSamples/ResonatorBuilder.h       |   2 +-
 Core/StandardSamples/RipplesBuilder.cpp       |  14 +-
 Core/StandardSamples/RipplesBuilder.h         |   1 -
 .../RotatedPyramidsBuilder.cpp                |  13 +-
 Core/StandardSamples/SampleBuilderFactory.cpp |   4 +-
 Core/StandardSamples/SampleComponents.cpp     |  63 +--
 Core/StandardSamples/SampleComponents.h       |   2 +-
 Core/StandardSamples/SimulationFactory.cpp    |  88 ++--
 Core/StandardSamples/SimulationFactory.h      |   2 +-
 .../SizeDistributionModelsBuilder.cpp         | 120 ++---
 .../SizeDistributionModelsBuilder.h           |   8 +-
 .../SlicedCylindersBuilder.cpp                |  32 +-
 .../StandardSamples/SlicedParticleBuilder.cpp |  17 +-
 Core/StandardSamples/SlicedParticleBuilder.h  |   2 +-
 Core/StandardSamples/StandardSimulations.cpp  | 163 +++---
 Core/StandardSamples/StandardSimulations.h    |   3 +-
 .../ThickAbsorptiveSampleBuilder.cpp          |   4 +-
 .../TransformationsBuilder.cpp                |   8 +-
 Core/StandardSamples/TransformationsBuilder.h |   2 +-
 Core/StandardSamples/TwoDimLatticeBuilder.cpp |  64 ++-
 Core/StandardSamples/TwoDimLatticeBuilder.h   |  15 +-
 .../TwoLayerRoughnessBuilder.cpp              |  11 +-
 Core/Tools/FileSystemUtils.cpp                |  11 +-
 Core/Tools/FileSystemUtils.h                  |   3 +-
 Core/Tools/IntegratorComplex.h                |  36 +-
 Core/Tools/IntegratorMCMiser.h                |  60 ++-
 Core/Tools/IntegratorReal.h                   |  38 +-
 Core/Tools/MathFunctions.cpp                  | 158 +++---
 Core/Tools/MathFunctions.h                    |  66 ++-
 Core/Tools/Numeric.cpp                        |  21 +-
 Core/Tools/Numeric.h                          |   7 +-
 Core/Tools/OrderedMap.h                       |   6 +-
 Core/Tools/Precomputed.h                      |  18 +-
 Core/Tools/PyEmbeddedUtils.cpp                |  40 +-
 Core/Tools/PyEmbeddedUtils.h                  |  10 +-
 Core/Tools/PyImport.cpp                       |  74 +--
 Core/Tools/PyImport.h                         |  10 +-
 Core/Tools/PyObject.h                         |   1 -
 Core/Tools/PythonCore.h                       |   2 -
 Core/Tools/SpectrumUtils.cpp                  |  17 +-
 Core/Tools/SysUtils.cpp                       |   8 +-
 Core/Tools/SysUtils.h                         |   3 +-
 Core/Tools/fp_exception_glibc_extension.c     | 248 ++++-----
 Core/Tools/fp_exception_glibc_extension.h     |  67 ++-
 Core/Tools/w32pragma.h                        |  48 +-
 Core/Vector/BasicVector3D.cpp                 |  78 ++-
 Core/Vector/BasicVector3D.h                   | 191 ++++---
 Core/Vector/Transform3D.cpp                   | 124 ++---
 Core/Vector/Transform3D.h                     |  25 +-
 Core/Vector/WavevectorInfo.cpp                |   7 +-
 Core/Vector/WavevectorInfo.h                  |  12 +-
 Core/includeIncludes/SoftParticles.h          |   6 +-
 560 files changed, 6337 insertions(+), 6754 deletions(-)

diff --git a/Core/Aggregate/FTDecayFunctions.cpp b/Core/Aggregate/FTDecayFunctions.cpp
index b12f3057c4c..819de342c62 100644
--- a/Core/Aggregate/FTDecayFunctions.cpp
+++ b/Core/Aggregate/FTDecayFunctions.cpp
@@ -14,17 +14,15 @@
 
 #include "FTDecayFunctions.h"
 #include "BornAgainNamespace.h"
+#include "MathConstants.h"
 #include "MathFunctions.h"
 #include "ParameterPool.h"
-#include "MathConstants.h"
 #include "RealParameter.h"
 #include <algorithm>
 
 //===============1D======================
 
-IFTDecayFunction1D::IFTDecayFunction1D(double decay_length)
-    : m_decay_length(decay_length)
-{}
+IFTDecayFunction1D::IFTDecayFunction1D(double decay_length) : m_decay_length(decay_length) {}
 
 void IFTDecayFunction1D::register_decay_length()
 {
@@ -146,13 +144,14 @@ double FTDecayFunction1DCosine::evaluate(double q) const
 //! in radians
 IFTDecayFunction2D::IFTDecayFunction2D(double decay_length_x, double decay_length_y, double gamma)
     : m_decay_length_x(decay_length_x), m_decay_length_y(decay_length_y), m_gamma(gamma)
-{}
+{
+}
 
 //! Calculates bounding values of reciprocal lattice coordinates that contain the centered
 //! rectangle with a corner defined by qX and qY
 std::pair<double, double>
-IFTDecayFunction2D::boundingReciprocalLatticeCoordinates(
-        double qX, double qY, double a, double b, double alpha) const
+IFTDecayFunction2D::boundingReciprocalLatticeCoordinates(double qX, double qY, double a, double b,
+                                                         double alpha) const
 {
     auto q_bounds_1 = transformToRecLatticeCoordinates(qX, qY, a, b, alpha);
     auto q_bounds_2 = transformToRecLatticeCoordinates(qX, -qY, a, b, alpha);
@@ -163,15 +162,18 @@ IFTDecayFunction2D::boundingReciprocalLatticeCoordinates(
 
 void IFTDecayFunction2D::register_decay_lengths()
 {
-    registerParameter(BornAgain::DecayLengthX, &m_decay_length_x).setUnit(BornAgain::UnitsNm)
+    registerParameter(BornAgain::DecayLengthX, &m_decay_length_x)
+        .setUnit(BornAgain::UnitsNm)
         .setNonnegative();
-    registerParameter(BornAgain::DecayLengthY, &m_decay_length_y).setUnit(BornAgain::UnitsNm)
+    registerParameter(BornAgain::DecayLengthY, &m_decay_length_y)
+        .setUnit(BornAgain::UnitsNm)
         .setNonnegative();
 }
 
 void IFTDecayFunction2D::register_gamma()
 {
-    registerParameter(BornAgain::Gamma, &m_gamma).setUnit(BornAgain::UnitsRad)
+    registerParameter(BornAgain::Gamma, &m_gamma)
+        .setUnit(BornAgain::UnitsRad)
         .setLimited(-M_PI_2, M_PI_2);
 }
 
@@ -181,8 +183,9 @@ void IFTDecayFunction2D::init_parameters()
     register_gamma();
 }
 
-std::pair<double, double> IFTDecayFunction2D::transformToRecLatticeCoordinates(
-        double qX, double qY, double a, double b, double alpha) const
+std::pair<double, double> IFTDecayFunction2D::transformToRecLatticeCoordinates(double qX, double qY,
+                                                                               double a, double b,
+                                                                               double alpha) const
 {
     double qa = (a * qX * std::cos(m_gamma) - a * qY * std::sin(m_gamma)) / M_TWOPI;
     double qb = (b * qX * std::cos(alpha - m_gamma) + b * qY * std::sin(alpha - m_gamma)) / M_TWOPI;
diff --git a/Core/Aggregate/FTDecayFunctions.h b/Core/Aggregate/FTDecayFunctions.h
index cde5480bd34..ff115757f1d 100644
--- a/Core/Aggregate/FTDecayFunctions.h
+++ b/Core/Aggregate/FTDecayFunctions.h
@@ -31,8 +31,8 @@ public:
     //! @param decay_length: half-width of the distribution in nanometers
     IFTDecayFunction1D(double decay_length);
 
-    virtual IFTDecayFunction1D* clone() const=0;
-    virtual double evaluate(double q) const=0;
+    virtual IFTDecayFunction1D* clone() const = 0;
+    virtual double evaluate(double q) const = 0;
     double decayLength() const { return m_decay_length; }
 
 protected:
@@ -40,7 +40,6 @@ protected:
     double m_decay_length;
 };
 
-
 //! One-dimensional Cauchy decay function in reciprocal space;
 //! corresponds to exp(-|x|/decay_length) in real space.
 //! @ingroup decayFT
@@ -54,7 +53,6 @@ public:
     double evaluate(double q) const final;
 };
 
-
 //! One-dimensional Gauss decay function in reciprocal space;
 //! corresponds to exp[-x^2/(2*decay_length^2)] in real space.
 //! @ingroup decayFT
@@ -68,7 +66,6 @@ public:
     double evaluate(double q) const final;
 };
 
-
 //! One-dimensional triangle decay function in reciprocal space;
 //! corresponds to 1-|x|/decay_length if |x|<decay_length (and 0 otherwise) in real space.
 //! @ingroup decayFT
@@ -82,7 +79,6 @@ public:
     double evaluate(double q) const final;
 };
 
-
 //! One-dimensional pseudo-Voigt decay function in reciprocal space;
 //! corresponds to eta*Gauss + (1-eta)*Cauchy.
 //! @ingroup decayFT
@@ -97,20 +93,19 @@ public:
     FTDecayFunction1DVoigt* clone() const;
     void accept(INodeVisitor* visitor) const final { visitor->visit(this); }
     double evaluate(double q) const final;
-    double eEta() const { return m_eta;}
+    double eEta() const { return m_eta; }
 
 private:
     double m_eta;
 };
 
-
 //! Interface for two-dimensional decay function in reciprocal space.
 //! @ingroup decayFT_internal
 class BA_CORE_API_ IFTDecayFunction2D : public ICloneable, public INode
 {
 public:
-    IFTDecayFunction2D(double decay_length_x, double decay_length_y, double gamma=0);
-    virtual IFTDecayFunction2D* clone() const=0;
+    IFTDecayFunction2D(double decay_length_x, double decay_length_y, double gamma = 0);
+    virtual IFTDecayFunction2D* clone() const = 0;
 
     //! set angle between first lattice vector and X-axis of distribution (both in direct space)
     void setGamma(double gamma) { m_gamma = gamma; }
@@ -125,11 +120,11 @@ public:
     double decayLengthY() const { return m_decay_length_y; }
 
     //! evaluate Fourier transformed decay function for q in X,Y coordinates
-    virtual double evaluate(double qx, double qy) const=0;
+    virtual double evaluate(double qx, double qy) const = 0;
 
     //! transform back to a*, b* basis:
-    std::pair<double, double>  boundingReciprocalLatticeCoordinates(
-            double qX, double qY, double a, double b, double alpha) const;
+    std::pair<double, double> boundingReciprocalLatticeCoordinates(double qX, double qY, double a,
+                                                                   double b, double alpha) const;
 
 protected:
     void register_decay_lengths();
@@ -142,11 +137,10 @@ protected:
 private:
     //! transform reciprocal coordinate system of this decay function to the reciprocal
     //! lattice system
-    std::pair<double, double> transformToRecLatticeCoordinates(
-            double qX, double qY, double a, double b, double alpha) const;
+    std::pair<double, double> transformToRecLatticeCoordinates(double qX, double qY, double a,
+                                                               double b, double alpha) const;
 };
 
-
 //! Two-dimensional Cauchy decay function in reciprocal space;
 //! corresponds to exp(-r) in real space,
 //! with \f$r=\sqrt{(\frac{x}{\omega_x})^2 + (\frac{y}{\omega_y})^2}\f$.
@@ -154,14 +148,13 @@ private:
 class BA_CORE_API_ FTDecayFunction2DCauchy : public IFTDecayFunction2D
 {
 public:
-    FTDecayFunction2DCauchy(double decay_length_x, double decay_length_y, double gamma=0);
+    FTDecayFunction2DCauchy(double decay_length_x, double decay_length_y, double gamma = 0);
 
     FTDecayFunction2DCauchy* clone() const;
     void accept(INodeVisitor* visitor) const final { visitor->visit(this); }
     double evaluate(double qx, double qy) const final;
 };
 
-
 //! Two-dimensional Gauss decay function in reciprocal space;
 //! corresponds to exp(-r^2/2) in real space,
 //! with \f$r=\sqrt{(\frac{x}{\omega_x})^2 + (\frac{y}{\omega_y})^2}\f$.
@@ -169,7 +162,7 @@ public:
 class BA_CORE_API_ FTDecayFunction2DGauss : public IFTDecayFunction2D
 {
 public:
-    FTDecayFunction2DGauss(double decay_length_x, double decay_length_y, double gamma=0);
+    FTDecayFunction2DGauss(double decay_length_x, double decay_length_y, double gamma = 0);
 
     FTDecayFunction2DGauss* clone() const;
     void accept(INodeVisitor* visitor) const final { visitor->visit(this); }
@@ -183,7 +176,7 @@ class BA_CORE_API_ FTDecayFunction2DVoigt : public IFTDecayFunction2D
 {
 public:
     FTDecayFunction2DVoigt(double decay_length_x, double decay_length_y, double eta,
-                           double gamma=0);
+                           double gamma = 0);
 
     FTDecayFunction2DVoigt* clone() const;
     void accept(INodeVisitor* visitor) const final { visitor->visit(this); }
diff --git a/Core/Aggregate/FTDistributions1D.cpp b/Core/Aggregate/FTDistributions1D.cpp
index f1447674da0..c8a428e35f9 100644
--- a/Core/Aggregate/FTDistributions1D.cpp
+++ b/Core/Aggregate/FTDistributions1D.cpp
@@ -14,26 +14,26 @@
 
 #include "FTDistributions1D.h"
 #include "BornAgainNamespace.h"
+#include "Exceptions.h"
+#include "MathConstants.h"
 #include "MathFunctions.h"
 #include "ParameterPool.h"
-#include "MathConstants.h"
 #include "RealParameter.h"
 #include <limits>
-#include "Exceptions.h"
 
-namespace {
-const double CosineDistributionFactor = 1.0/3.0 - 2.0/M_PI/M_PI;
+namespace
+{
+const double CosineDistributionFactor = 1.0 / 3.0 - 2.0 / M_PI / M_PI;
 }
 
-IFTDistribution1D::~IFTDistribution1D() =default;
+IFTDistribution1D::~IFTDistribution1D() = default;
 
 void IFTDistribution1D::init_parameters()
 {
     registerParameter(BornAgain::Omega, &m_omega);
 }
 
-FTDistribution1DCauchy::FTDistribution1DCauchy(double omega)
-: IFTDistribution1D(omega)
+FTDistribution1DCauchy::FTDistribution1DCauchy(double omega) : IFTDistribution1D(omega)
 {
     setName(BornAgain::FTDistribution1DCauchyType);
     init_parameters();
@@ -46,22 +46,21 @@ FTDistribution1DCauchy* FTDistribution1DCauchy::clone() const
 
 double FTDistribution1DCauchy::evaluate(double q) const
 {
-    double sum_sq = q*q*m_omega*m_omega;
-    return 1.0/(1.0 + sum_sq);
+    double sum_sq = q * q * m_omega * m_omega;
+    return 1.0 / (1.0 + sum_sq);
 }
 
 double FTDistribution1DCauchy::qSecondDerivative() const
 {
-    return 2.0*m_omega*m_omega;
+    return 2.0 * m_omega * m_omega;
 }
 
 std::unique_ptr<IDistribution1DSampler> FTDistribution1DCauchy::createSampler() const
 {
-    return std::make_unique<Distribution1DCauchySampler>(1/m_omega);
+    return std::make_unique<Distribution1DCauchySampler>(1 / m_omega);
 }
 
-FTDistribution1DGauss::FTDistribution1DGauss(double omega)
-: IFTDistribution1D(omega)
+FTDistribution1DGauss::FTDistribution1DGauss(double omega) : IFTDistribution1D(omega)
 {
     setName(BornAgain::FTDistribution1DGaussType);
     init_parameters();
@@ -74,13 +73,13 @@ FTDistribution1DGauss* FTDistribution1DGauss::clone() const
 
 double FTDistribution1DGauss::evaluate(double q) const
 {
-    double sum_sq = q*q*m_omega*m_omega;
-    return std::exp(-sum_sq/2.0);
+    double sum_sq = q * q * m_omega * m_omega;
+    return std::exp(-sum_sq / 2.0);
 }
 
 double FTDistribution1DGauss::qSecondDerivative() const
 {
-    return m_omega*m_omega;
+    return m_omega * m_omega;
 }
 
 std::unique_ptr<IDistribution1DSampler> FTDistribution1DGauss::createSampler() const
@@ -88,8 +87,7 @@ std::unique_ptr<IDistribution1DSampler> FTDistribution1DGauss::createSampler() c
     return std::make_unique<Distribution1DGaussSampler>(0.0, m_omega);
 }
 
-FTDistribution1DGate::FTDistribution1DGate(double omega)
-    : IFTDistribution1D(omega)
+FTDistribution1DGate::FTDistribution1DGate(double omega) : IFTDistribution1D(omega)
 {
     setName(BornAgain::FTDistribution1DGateType);
     init_parameters();
@@ -102,12 +100,12 @@ FTDistribution1DGate* FTDistribution1DGate::clone() const
 
 double FTDistribution1DGate::evaluate(double q) const
 {
-    return MathFunctions::sinc(q*m_omega);
+    return MathFunctions::sinc(q * m_omega);
 }
 
 double FTDistribution1DGate::qSecondDerivative() const
 {
-    return m_omega*m_omega/3.0;
+    return m_omega * m_omega / 3.0;
 }
 
 std::unique_ptr<IDistribution1DSampler> FTDistribution1DGate::createSampler() const
@@ -115,8 +113,7 @@ std::unique_ptr<IDistribution1DSampler> FTDistribution1DGate::createSampler() co
     return std::make_unique<Distribution1DGateSampler>(-m_omega, m_omega);
 }
 
-FTDistribution1DTriangle::FTDistribution1DTriangle(double omega)
-    : IFTDistribution1D(omega)
+FTDistribution1DTriangle::FTDistribution1DTriangle(double omega) : IFTDistribution1D(omega)
 {
     setName(BornAgain::FTDistribution1DTriangleType);
     init_parameters();
@@ -129,13 +126,13 @@ FTDistribution1DTriangle* FTDistribution1DTriangle::clone() const
 
 double FTDistribution1DTriangle::evaluate(double q) const
 {
-    double sincqw2 = MathFunctions::sinc(q*m_omega/2.0);
-    return sincqw2*sincqw2;
+    double sincqw2 = MathFunctions::sinc(q * m_omega / 2.0);
+    return sincqw2 * sincqw2;
 }
 
 double FTDistribution1DTriangle::qSecondDerivative() const
 {
-    return m_omega*m_omega/6.0;
+    return m_omega * m_omega / 6.0;
 }
 
 std::unique_ptr<IDistribution1DSampler> FTDistribution1DTriangle::createSampler() const
@@ -143,8 +140,7 @@ std::unique_ptr<IDistribution1DSampler> FTDistribution1DTriangle::createSampler(
     return std::make_unique<Distribution1DTriangleSampler>(m_omega);
 }
 
-FTDistribution1DCosine::FTDistribution1DCosine(double omega)
-    : IFTDistribution1D(omega)
+FTDistribution1DCosine::FTDistribution1DCosine(double omega) : IFTDistribution1D(omega)
 {
     setName(BornAgain::FTDistribution1DCosineType);
     init_parameters();
@@ -157,15 +153,15 @@ FTDistribution1DCosine* FTDistribution1DCosine::clone() const
 
 double FTDistribution1DCosine::evaluate(double q) const
 {
-    double qw = std::abs(q*m_omega);
-    if (std::abs(1.0-qw*qw/M_PI/M_PI) < std::numeric_limits<double>::epsilon())
+    double qw = std::abs(q * m_omega);
+    if (std::abs(1.0 - qw * qw / M_PI / M_PI) < std::numeric_limits<double>::epsilon())
         return 0.5;
-    return MathFunctions::sinc(qw)/(1.0-qw*qw/M_PI/M_PI);
+    return MathFunctions::sinc(qw) / (1.0 - qw * qw / M_PI / M_PI);
 }
 
 double FTDistribution1DCosine::qSecondDerivative() const
 {
-    return CosineDistributionFactor*m_omega*m_omega;
+    return CosineDistributionFactor * m_omega * m_omega;
 }
 
 std::unique_ptr<IDistribution1DSampler> FTDistribution1DCosine::createSampler() const
@@ -174,8 +170,7 @@ std::unique_ptr<IDistribution1DSampler> FTDistribution1DCosine::createSampler()
 }
 
 FTDistribution1DVoigt::FTDistribution1DVoigt(double omega, double eta)
-    : IFTDistribution1D(omega)
-    , m_eta(eta)
+    : IFTDistribution1D(omega), m_eta(eta)
 {
     setName(BornAgain::FTDistribution1DVoigtType);
     init_parameters();
@@ -189,13 +184,13 @@ FTDistribution1DVoigt* FTDistribution1DVoigt::clone() const
 
 double FTDistribution1DVoigt::evaluate(double q) const
 {
-    double sum_sq = q*q*m_omega*m_omega;
-    return m_eta*std::exp(-sum_sq/2.0) + (1.0 - m_eta)*1.0/(1.0 + sum_sq);
+    double sum_sq = q * q * m_omega * m_omega;
+    return m_eta * std::exp(-sum_sq / 2.0) + (1.0 - m_eta) * 1.0 / (1.0 + sum_sq);
 }
 
 double FTDistribution1DVoigt::qSecondDerivative() const
 {
- return (2.0 - m_eta)*m_omega*m_omega;
+    return (2.0 - m_eta) * m_omega * m_omega;
 }
 
 std::unique_ptr<IDistribution1DSampler> FTDistribution1DVoigt::createSampler() const
diff --git a/Core/Aggregate/FTDistributions1D.h b/Core/Aggregate/FTDistributions1D.h
index d1dcce96f69..136dd651909 100644
--- a/Core/Aggregate/FTDistributions1D.h
+++ b/Core/Aggregate/FTDistributions1D.h
@@ -16,8 +16,8 @@
 #define FTDISTRIBUTIONS1D_H
 
 #include "ICloneable.h"
-#include "INode.h"
 #include "IDistribution1DSampler.h"
+#include "INode.h"
 
 //! Interface for a one-dimensional distribution, with normalization adjusted so that
 //! the Fourier transform evaluate(q) is a decay function that starts at evaluate(0)=1.
@@ -31,20 +31,20 @@ public:
     IFTDistribution1D(double omega) : m_omega(omega) {}
     virtual ~IFTDistribution1D();
 
-    virtual IFTDistribution1D* clone() const=0;
+    virtual IFTDistribution1D* clone() const = 0;
 
     //! Returns Fourier transform of this distribution;
     //! is a decay function starting at evaluate(0)=1.
-    virtual double evaluate(double q) const=0;
+    virtual double evaluate(double q) const = 0;
 
     void setOmega(double omega) { m_omega = omega; }
     double omega() const { return m_omega; }
 
     //! Returns the negative of the second order derivative in q space around q=0
-    virtual double qSecondDerivative() const=0;
+    virtual double qSecondDerivative() const = 0;
 
 #ifndef SWIG
-    virtual std::unique_ptr<IDistribution1DSampler> createSampler() const=0;
+    virtual std::unique_ptr<IDistribution1DSampler> createSampler() const = 0;
 #endif
 
 protected:
@@ -52,7 +52,6 @@ protected:
     double m_omega;
 };
 
-
 //! Exponential IFTDistribution1D exp(-|omega*x|);
 //! its Fourier transform evaluate(q) is a Cauchy-Lorentzian starting at evaluate(0)=1.
 //! @ingroup distributionFT
@@ -72,7 +71,6 @@ public:
 #endif
 };
 
-
 //! Gaussian IFTDistribution1D;
 //! its Fourier transform evaluate(q) is a Gaussian starting at evaluate(0)=1.
 //! @ingroup distributionFT
@@ -92,7 +90,6 @@ public:
 #endif
 };
 
-
 //! Square gate IFTDistribution1D;
 //! its Fourier transform evaluate(q) is a sinc function starting at evaluate(0)=1.
 //! @ingroup distributionFT
@@ -112,7 +109,6 @@ public:
 #endif
 };
 
-
 //! Triangle IFTDistribution1D [1-|x|/omega if |x|<omega, and 0 otherwise];
 //! its Fourier transform evaluate(q) is a squared sinc function starting at evaluate(0)=1.
 //! @ingroup distributionFT
@@ -132,7 +128,6 @@ public:
 #endif
 };
 
-
 //! IFTDistribution1D consisting of one cosine wave
 //! [1+cos(pi*x/omega) if |x|<omega, and 0 otherwise];
 //! its Fourier transform evaluate(q) starts at evaluate(0)=1.
@@ -153,7 +148,6 @@ public:
 #endif
 };
 
-
 //! IFTDistribution1D that provides a Fourier transform evaluate(q) in form
 //! of a pseudo-Voigt decay function eta*Gauss + (1-eta)*Cauchy, with both components
 //! starting at 1 for q=0.
@@ -170,7 +164,7 @@ public:
     FTDistribution1DVoigt* clone() const override final;
     void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
     double evaluate(double q) const override final;
-    double eta() const { return m_eta;}    
+    double eta() const { return m_eta; }
 
     double qSecondDerivative() const override final;
 #ifndef SWIG
diff --git a/Core/Aggregate/FTDistributions2D.cpp b/Core/Aggregate/FTDistributions2D.cpp
index 795c515434e..e6c9c20fbeb 100644
--- a/Core/Aggregate/FTDistributions2D.cpp
+++ b/Core/Aggregate/FTDistributions2D.cpp
@@ -14,13 +14,13 @@
 
 #include "FTDistributions2D.h"
 #include "BornAgainNamespace.h"
+#include "Exceptions.h"
 #include "IntegratorReal.h"
+#include "MathConstants.h"
 #include "MathFunctions.h"
 #include "ParameterPool.h"
-#include "MathConstants.h"
 #include "RealParameter.h"
 #include <limits>
-#include "Exceptions.h"
 
 //! Constructor of two-dimensional probability distribution.
 //! @param omega_x: half-width of the distribution along its x-axis in nanometers
@@ -45,7 +45,8 @@ void IFTDistribution2D::register_omega()
 
 void IFTDistribution2D::register_gamma()
 {
-    registerParameter(BornAgain::Gamma, &m_gamma).setUnit(BornAgain::UnitsRad)
+    registerParameter(BornAgain::Gamma, &m_gamma)
+        .setUnit(BornAgain::UnitsRad)
         .setLimited(-M_PI_2, M_PI_2);
 }
 
@@ -154,7 +155,6 @@ double FTDistribution2DCone::coneIntegrand2(double value) const
     return value * value * MathFunctions::Bessel_J0(value);
 }
 
-
 //! Constructor of two-dimensional pseudo-Voigt probability distribution.
 //! @param omega_x: half-width of the distribution along its x-axis in nanometers
 //! @param omega_y: half-width of the distribution along its y-axis in nanometers
diff --git a/Core/Aggregate/FTDistributions2D.h b/Core/Aggregate/FTDistributions2D.h
index 40c9342d2a7..071ac412f19 100644
--- a/Core/Aggregate/FTDistributions2D.h
+++ b/Core/Aggregate/FTDistributions2D.h
@@ -16,9 +16,9 @@
 #define FTDISTRIBUTIONS2D_H
 
 #include "ICloneable.h"
+#include "IDistribution2DSampler.h"
 #include "INode.h"
 #include "MathConstants.h"
-#include "IDistribution2DSampler.h"
 
 //! Interface for two-dimensional distributions in Fourier space.
 //! @ingroup distribution_internal
@@ -26,8 +26,8 @@
 class BA_CORE_API_ IFTDistribution2D : public ICloneable, public INode
 {
 public:
-    IFTDistribution2D(double omega_x, double omega_y, double gamma=0);
-    IFTDistribution2D* clone() const =0;
+    IFTDistribution2D(double omega_x, double omega_y, double gamma = 0);
+    IFTDistribution2D* clone() const = 0;
 
     void setGamma(double gamma) { m_gamma = gamma; }
     double gamma() const { return m_gamma; }
@@ -40,14 +40,14 @@ public:
     //! evaluate Fourier transformed distribution for q in X,Y coordinates
     //! the original distribution (in real space) is assumed to be normalized:
     //! total integral is equal to 1
-    virtual double evaluate(double qx, double qy) const=0;
+    virtual double evaluate(double qx, double qy) const = 0;
 
 #ifndef SWIG
-    virtual std::unique_ptr<IDistribution2DSampler> createSampler() const=0;
+    virtual std::unique_ptr<IDistribution2DSampler> createSampler() const = 0;
 #endif
 
 protected:
-    double sumsq( double qx, double qy) const;
+    double sumsq(double qx, double qy) const;
 
     void register_omega();
     void register_gamma();
@@ -61,7 +61,6 @@ protected:
     double m_delta;
 };
 
-
 //! Two-dimensional Cauchy distribution in Fourier space;
 //! corresponds to a normalized exp(-r) in real space,
 //! with \f$r=\sqrt{(\frac{x}{\omega_x})^2 + (\frac{y}{\omega_y})^2}\f$.
diff --git a/Core/Aggregate/FormFactorCoherentPart.h b/Core/Aggregate/FormFactorCoherentPart.h
index 9dae33acaa8..cff52c2c06d 100644
--- a/Core/Aggregate/FormFactorCoherentPart.h
+++ b/Core/Aggregate/FormFactorCoherentPart.h
@@ -44,6 +44,7 @@ public:
 
     void setSpecularInfo(const IFresnelMap* p_fresnel_map, size_t layer_index);
     double radialExtension() const;
+
 private:
     std::unique_ptr<IFormFactor> mP_ff;
     const IFresnelMap* mp_fresnel_map;
diff --git a/Core/Aggregate/FormFactorCoherentSum.h b/Core/Aggregate/FormFactorCoherentSum.h
index 9e404678638..4814de4003a 100644
--- a/Core/Aggregate/FormFactorCoherentSum.h
+++ b/Core/Aggregate/FormFactorCoherentSum.h
@@ -41,9 +41,9 @@ public:
     double relativeAbundance() const { return m_abundance; }
     void scaleRelativeAbundance(double total_abundance);
     double radialExtension() const;
+
 private:
-    FormFactorCoherentSum(const std::vector<FormFactorCoherentPart>& parts,
-                          double abundance);
+    FormFactorCoherentSum(const std::vector<FormFactorCoherentPart>& parts, double abundance);
     std::vector<FormFactorCoherentPart> m_parts;
     double m_abundance;
 };
diff --git a/Core/Aggregate/IDistribution1DSampler.h b/Core/Aggregate/IDistribution1DSampler.h
index 979d4d48c28..d6565a7cdff 100644
--- a/Core/Aggregate/IDistribution1DSampler.h
+++ b/Core/Aggregate/IDistribution1DSampler.h
@@ -23,7 +23,7 @@ public:
     IDistribution1DSampler() {}
     virtual ~IDistribution1DSampler();
 
-    virtual double randomSample() const=0;
+    virtual double randomSample() const = 0;
 };
 
 class BA_CORE_API_ Distribution1DCauchySampler : public IDistribution1DSampler
diff --git a/Core/Aggregate/IDistribution2DSampler.cpp b/Core/Aggregate/IDistribution2DSampler.cpp
index 72ddc3826d7..c3f7a7d7ea4 100644
--- a/Core/Aggregate/IDistribution2DSampler.cpp
+++ b/Core/Aggregate/IDistribution2DSampler.cpp
@@ -22,7 +22,9 @@ size_t n_boxes = 256; // number of boxes for Ziggurat sampling
 
 struct BA_CORE_API_ ZigguratBox {
     ZigguratBox(double x_min, double x_max, double y_max, double y_lower)
-        : m_x_min(x_min), m_x_max(x_max), m_y_max(y_max), m_y_lower(y_lower) {}
+        : m_x_min(x_min), m_x_max(x_max), m_y_max(y_max), m_y_lower(y_lower)
+    {
+    }
 
     double m_x_min; // left edge of the box
     double m_x_max; // right edge of the box
@@ -120,7 +122,7 @@ double func_phi_Cone(double phi)
     // The independent "phi" density function of the 2D Cone distribution
     return 6 * (1 - phi) * phi;
 }
-}
+} // namespace
 
 IDistribution2DSampler::~IDistribution2DSampler() = default;
 
diff --git a/Core/Aggregate/IDistribution2DSampler.h b/Core/Aggregate/IDistribution2DSampler.h
index d163091e4cb..132d6d4021e 100644
--- a/Core/Aggregate/IDistribution2DSampler.h
+++ b/Core/Aggregate/IDistribution2DSampler.h
@@ -24,14 +24,16 @@ public:
     IDistribution2DSampler() {}
     virtual ~IDistribution2DSampler();
 
-    virtual std::pair<double, double> randomSample() const=0;
+    virtual std::pair<double, double> randomSample() const = 0;
 };
 
 class BA_CORE_API_ Distribution2DCauchySampler : public IDistribution2DSampler
 {
 public:
-    Distribution2DCauchySampler(double omega_x, double omega_y) :
-        m_omega_x(omega_x), m_omega_y(omega_y) {}
+    Distribution2DCauchySampler(double omega_x, double omega_y)
+        : m_omega_x(omega_x), m_omega_y(omega_y)
+    {
+    }
     std::pair<double, double> randomSample() const final;
 
 private:
@@ -41,8 +43,10 @@ private:
 class BA_CORE_API_ Distribution2DGaussSampler : public IDistribution2DSampler
 {
 public:
-    Distribution2DGaussSampler(double omega_x, double omega_y) :
-        m_omega_x(omega_x), m_omega_y(omega_y) {}
+    Distribution2DGaussSampler(double omega_x, double omega_y)
+        : m_omega_x(omega_x), m_omega_y(omega_y)
+    {
+    }
     std::pair<double, double> randomSample() const final;
 
 private:
@@ -52,8 +56,10 @@ private:
 class BA_CORE_API_ Distribution2DGateSampler : public IDistribution2DSampler
 {
 public:
-    Distribution2DGateSampler(double omega_x, double omega_y) :
-        m_omega_x(omega_x), m_omega_y(omega_y) {}
+    Distribution2DGateSampler(double omega_x, double omega_y)
+        : m_omega_x(omega_x), m_omega_y(omega_y)
+    {
+    }
     std::pair<double, double> randomSample() const final;
 
 private:
@@ -63,8 +69,10 @@ private:
 class BA_CORE_API_ Distribution2DConeSampler : public IDistribution2DSampler
 {
 public:
-    Distribution2DConeSampler(double omega_x, double omega_y) :
-        m_omega_x(omega_x), m_omega_y(omega_y) {}
+    Distribution2DConeSampler(double omega_x, double omega_y)
+        : m_omega_x(omega_x), m_omega_y(omega_y)
+    {
+    }
     std::pair<double, double> randomSample() const final;
 
 private:
diff --git a/Core/Aggregate/IInterferenceFunction.cpp b/Core/Aggregate/IInterferenceFunction.cpp
index 7ade0152abe..5dd3fbc4c63 100644
--- a/Core/Aggregate/IInterferenceFunction.cpp
+++ b/Core/Aggregate/IInterferenceFunction.cpp
@@ -18,19 +18,18 @@
 #include <algorithm>
 #include <stdexcept>
 
-IInterferenceFunction::IInterferenceFunction()
-    : m_position_var{0.0}
+IInterferenceFunction::IInterferenceFunction() : m_position_var{0.0}
 {
     init_parameters();
 }
 
-IInterferenceFunction::IInterferenceFunction(const IInterferenceFunction &other)
+IInterferenceFunction::IInterferenceFunction(const IInterferenceFunction& other)
     : m_position_var(other.m_position_var)
 {
     init_parameters();
 }
 
-IInterferenceFunction::~IInterferenceFunction() =default;
+IInterferenceFunction::~IInterferenceFunction() = default;
 
 // Default implementation of evaluate assumes no inner structure
 // It is only to be overriden in case of the presence of such inner structure. See for example
@@ -51,17 +50,19 @@ void IInterferenceFunction::setPositionVariance(double var)
 double IInterferenceFunction::DWfactor(kvector_t q) const
 {
     // remove z component for two dimensional interference functions:
-    if (supportsMultilayer()) q.setZ(0.0);
-    return std::exp(-q.mag2()*m_position_var);
+    if (supportsMultilayer())
+        q.setZ(0.0);
+    return std::exp(-q.mag2() * m_position_var);
 }
 
 double IInterferenceFunction::iff_no_inner(const kvector_t q, double outer_iff) const
 {
-    return DWfactor(q)*(iff_without_dw(q)*outer_iff - 1.0) + 1.0;
+    return DWfactor(q) * (iff_without_dw(q) * outer_iff - 1.0) + 1.0;
 }
 
 void IInterferenceFunction::init_parameters()
 {
-    registerParameter(BornAgain::PositionVariance, &m_position_var).setUnit(BornAgain::UnitsNm2)
+    registerParameter(BornAgain::PositionVariance, &m_position_var)
+        .setUnit(BornAgain::UnitsNm2)
         .setNonnegative();
 }
diff --git a/Core/Aggregate/IInterferenceFunction.h b/Core/Aggregate/IInterferenceFunction.h
index 7fee248ff12..cede31ab3a3 100644
--- a/Core/Aggregate/IInterferenceFunction.h
+++ b/Core/Aggregate/IInterferenceFunction.h
@@ -28,11 +28,11 @@ public:
     IInterferenceFunction(const IInterferenceFunction& other);
     virtual ~IInterferenceFunction();
 
-    virtual IInterferenceFunction* clone() const=0;
-    virtual void accept(INodeVisitor* visitor) const =0;
+    virtual IInterferenceFunction* clone() const = 0;
+    virtual void accept(INodeVisitor* visitor) const = 0;
 
     //! Evaluates the interference function for a given wavevector transfer
-    virtual double evaluate(const kvector_t q, double outer_iff=1.0) const;
+    virtual double evaluate(const kvector_t q, double outer_iff = 1.0) const;
 
     //! Sets the variance of the position for the calculation of the DW factor
     //! It is defined as the variance in each relevant dimension
@@ -56,7 +56,8 @@ protected:
     double iff_no_inner(const kvector_t q, double outer_iff) const;
 
     //! Calculates the structure factor without Debye-Waller factor
-    virtual double iff_without_dw(const kvector_t q) const=0;
+    virtual double iff_without_dw(const kvector_t q) const = 0;
+
 private:
     void init_parameters();
     double m_position_var;
diff --git a/Core/Aggregate/IPeakShape.cpp b/Core/Aggregate/IPeakShape.cpp
index dd793f22105..768b205d568 100644
--- a/Core/Aggregate/IPeakShape.cpp
+++ b/Core/Aggregate/IPeakShape.cpp
@@ -142,8 +142,7 @@ VonMisesFisherGaussPeakShape::VonMisesFisherGaussPeakShape(double max_intensity,
     : m_max_intensity(max_intensity), m_radial_size(radial_size), m_zenith(zenith.unit()),
       m_kappa_1(kappa_1), m_kappa_2(kappa_2)
 {
-    mP_integrator
-        = make_integrator_real(this, &VonMisesFisherGaussPeakShape::integrand);
+    mP_integrator = make_integrator_real(this, &VonMisesFisherGaussPeakShape::integrand);
 }
 
 VonMisesFisherGaussPeakShape::~VonMisesFisherGaussPeakShape() = default;
@@ -188,24 +187,23 @@ double VonMisesFisherGaussPeakShape::evaluate(const kvector_t q,
 double VonMisesFisherGaussPeakShape::integrand(double phi) const
 {
     kvector_t u_q = std::sin(m_theta) * std::cos(phi) * m_ux
-                  + std::sin(m_theta) * std::sin(phi) * m_uy
-                  + std::cos(m_theta) * m_zenith;
-    double fisher = std::exp(m_kappa_1*(u_q.dot(m_up) - 1.0));
-    double vonmises = std::exp(m_kappa_2*(std::cos(m_phi - phi) - 1.0));
+                    + std::sin(m_theta) * std::sin(phi) * m_uy + std::cos(m_theta) * m_zenith;
+    double fisher = std::exp(m_kappa_1 * (u_q.dot(m_up) - 1.0));
+    double vonmises = std::exp(m_kappa_2 * (std::cos(m_phi - phi) - 1.0));
     return fisher * vonmises;
 }
 
 VonMisesGaussPeakShape::VonMisesGaussPeakShape(double max_intensity, double radial_size,
                                                kvector_t zenith, double kappa)
-    : m_max_intensity(max_intensity), m_radial_size(radial_size), m_zenith(zenith.unit())
-    , m_kappa(kappa)
+    : m_max_intensity(max_intensity), m_radial_size(radial_size), m_zenith(zenith.unit()),
+      m_kappa(kappa)
 {
     mP_integrator = make_integrator_real(this, &VonMisesGaussPeakShape::integrand);
 }
 
 VonMisesGaussPeakShape::~VonMisesGaussPeakShape() = default;
 
-VonMisesGaussPeakShape *VonMisesGaussPeakShape::clone() const
+VonMisesGaussPeakShape* VonMisesGaussPeakShape::clone() const
 {
     return new VonMisesGaussPeakShape(m_max_intensity, m_radial_size, m_zenith, m_kappa);
 }
@@ -232,16 +230,15 @@ double VonMisesGaussPeakShape::evaluate(const kvector_t q, const kvector_t q_lat
 
 double VonMisesGaussPeakShape::integrand(double phi) const
 {
-    kvector_t q_rot = m_qr * (std::sin(m_theta) * std::cos(phi) * m_ux
-                            + std::sin(m_theta) * std::sin(phi) * m_uy
-                            + std::cos(m_theta) * m_zenith);
+    kvector_t q_rot = m_qr
+                      * (std::sin(m_theta) * std::cos(phi) * m_ux
+                         + std::sin(m_theta) * std::sin(phi) * m_uy + std::cos(m_theta) * m_zenith);
     double dq2 = (q_rot - m_p).mag2();
     double gauss = Gauss3D(dq2, m_radial_size);
-    double vonmises = std::exp(m_kappa*(std::cos(m_phi - phi) - 1.0));
+    double vonmises = std::exp(m_kappa * (std::cos(m_phi - phi) - 1.0));
     return gauss * vonmises;
 }
 
-
 namespace
 {
 double FisherDistribution(double x, double kappa)
@@ -272,7 +269,7 @@ double VonMisesPrefactor(double kappa)
         return 1.0 / (2.0 * M_PI);
     }
     if (kappa > maxkappa2) {
-        return std::sqrt(kappa / 2.0 / M_PI) / (1.0 + 1.0/(8.0*kappa));
+        return std::sqrt(kappa / 2.0 / M_PI) / (1.0 + 1.0 / (8.0 * kappa));
     } else {
         return std::exp(kappa) / (2.0 * M_PI * MathFunctions::Bessel_I0(kappa));
     }
@@ -290,4 +287,3 @@ double Cauchy3D(double q2, double domainsize)
     return domainsize * lorentz1 * lorentz1;
 }
 } // namespace
-
diff --git a/Core/Aggregate/IPeakShape.h b/Core/Aggregate/IPeakShape.h
index e8dd2e9b595..b14693898e5 100644
--- a/Core/Aggregate/IPeakShape.h
+++ b/Core/Aggregate/IPeakShape.h
@@ -29,17 +29,16 @@ class BA_CORE_API_ IPeakShape : public ISample
 public:
     virtual ~IPeakShape();
 
-    virtual IPeakShape* clone() const=0;
+    virtual IPeakShape* clone() const = 0;
 
     //! Evaluates the peak shape at q from a reciprocal lattice point at q_lattice_point
-    virtual double evaluate(const kvector_t q, const kvector_t q_lattice_point) const=0;
+    virtual double evaluate(const kvector_t q, const kvector_t q_lattice_point) const = 0;
 
     //! Indicates if the peak shape encodes angular disorder, in which case all peaks in a
     //! spherical shell are needed
     virtual bool angularDisorder() const { return false; }
 };
 
-
 //! Class that implements an isotropic Gaussian peak shape of a Bragg peak.
 //!
 //! @ingroup samples_internal
@@ -55,6 +54,7 @@ public:
     void accept(INodeVisitor* visitor) const override { visitor->visit(this); }
 
     double evaluate(const kvector_t q, const kvector_t q_lattice_point) const override;
+
 private:
     double evaluate(const kvector_t q) const;
     double m_max_intensity;
@@ -76,6 +76,7 @@ public:
     void accept(INodeVisitor* visitor) const override { visitor->visit(this); }
 
     double evaluate(const kvector_t q, const kvector_t q_lattice_point) const override;
+
 private:
     double evaluate(const kvector_t q) const;
     double m_max_intensity;
@@ -100,6 +101,7 @@ public:
     double evaluate(const kvector_t q, const kvector_t q_lattice_point) const override;
 
     bool angularDisorder() const override { return true; }
+
 private:
     double m_max_intensity;
     double m_radial_size;
@@ -124,6 +126,7 @@ public:
     double evaluate(const kvector_t q, const kvector_t q_lattice_point) const override;
 
     bool angularDisorder() const override { return true; }
+
 private:
     double m_max_intensity;
     double m_radial_size;
@@ -150,6 +153,7 @@ public:
     double evaluate(const kvector_t q, const kvector_t q_lattice_point) const override;
 
     bool angularDisorder() const override { return true; }
+
 private:
     double integrand(double phi) const;
     double m_max_intensity;
@@ -182,6 +186,7 @@ public:
     double evaluate(const kvector_t q, const kvector_t q_lattice_point) const override;
 
     bool angularDisorder() const override { return true; }
+
 private:
     double integrand(double phi) const;
     double m_max_intensity;
@@ -195,5 +200,4 @@ private:
 #endif
 };
 
-
 #endif // IPEAKSHAPE_H
diff --git a/Core/Aggregate/InterferenceFunction1DLattice.cpp b/Core/Aggregate/InterferenceFunction1DLattice.cpp
index f79083a570e..bd7e0af673f 100644
--- a/Core/Aggregate/InterferenceFunction1DLattice.cpp
+++ b/Core/Aggregate/InterferenceFunction1DLattice.cpp
@@ -20,19 +20,19 @@
 #include "RealParameter.h"
 #include <algorithm>
 
-namespace {
+namespace
+{
 // maximum value for qx*Lambdax
 static const int nmax = 20;
 // minimum number of neighboring reciprocal lattice points to use
 static const int min_points = 4;
-}
+} // namespace
 
 //! Constructor of interference function of one-dimensional lattice.
 //! @param length: lattice constant in nanometers
 //! @param xi: rotation of lattice with respect to x-axis in radians
 InterferenceFunction1DLattice::InterferenceFunction1DLattice(double length, double xi)
-    : m_lattice_params(length, xi)
-    , m_na {0}
+    : m_lattice_params(length, xi), m_na{0}
 {
     setName(BornAgain::InterferenceFunction1DLatticeType);
     init_parameters();
@@ -92,10 +92,8 @@ double InterferenceFunction1DLattice::iff_without_dw(const kvector_t q) const
 }
 
 InterferenceFunction1DLattice::InterferenceFunction1DLattice(
-        const InterferenceFunction1DLattice& other)
-    : IInterferenceFunction(other)
-    , m_lattice_params(other.m_lattice_params)
-    , m_na(other.m_na)
+    const InterferenceFunction1DLattice& other)
+    : IInterferenceFunction(other), m_lattice_params(other.m_lattice_params), m_na(other.m_na)
 {
     setName(other.getName());
     init_parameters();
diff --git a/Core/Aggregate/InterferenceFunction2DLattice.cpp b/Core/Aggregate/InterferenceFunction2DLattice.cpp
index a33da2a2f2e..3cef206ad5e 100644
--- a/Core/Aggregate/InterferenceFunction2DLattice.cpp
+++ b/Core/Aggregate/InterferenceFunction2DLattice.cpp
@@ -21,13 +21,13 @@
 #include "RealParameter.h"
 #include <algorithm>
 
-
-namespace {
+namespace
+{
 // maximum value for qx*Lambdax and qy*lambday
 static const int nmax = 20;
 // minimum number of neighboring reciprocal lattice points to use
 static const int min_points = 4;
-}
+} // namespace
 
 InterferenceFunction2DLattice::InterferenceFunction2DLattice(const Lattice2D& lattice)
     : m_integrate_xi(false)
@@ -44,17 +44,14 @@ InterferenceFunction2DLattice::InterferenceFunction2DLattice(const Lattice2D& la
 //! @param xi: rotation of the lattice with respect to the x-axis (beam direction) in radians
 InterferenceFunction2DLattice::InterferenceFunction2DLattice(double length_1, double length_2,
                                                              double alpha, double xi)
-    : m_integrate_xi(false)
-    , m_na(0), m_nb(0)
+    : m_integrate_xi(false), m_na(0), m_nb(0)
 {
     setName(BornAgain::InterferenceFunction2DLatticeType);
     setLattice(BasicLattice(length_1, length_2, alpha, xi));
     init_parameters();
 }
 
-InterferenceFunction2DLattice::~InterferenceFunction2DLattice()
-{
-}
+InterferenceFunction2DLattice::~InterferenceFunction2DLattice() {}
 
 InterferenceFunction2DLattice* InterferenceFunction2DLattice::clone() const
 {
@@ -64,8 +61,8 @@ InterferenceFunction2DLattice* InterferenceFunction2DLattice::clone() const
 //! Creates square lattice.
 //! @param lattice_length: length of the first and second basis vectors in nanometers
 //! @param xi: rotation of the lattice with respect to the x-axis in radians
-InterferenceFunction2DLattice* InterferenceFunction2DLattice::createSquare(
-double lattice_length, double xi)
+InterferenceFunction2DLattice* InterferenceFunction2DLattice::createSquare(double lattice_length,
+                                                                           double xi)
 {
     return new InterferenceFunction2DLattice(SquareLattice(lattice_length, xi));
 }
@@ -73,8 +70,8 @@ double lattice_length, double xi)
 //! Creates hexagonal lattice.
 //! @param lattice_length: length of the first and second basis vectors in nanometers
 //! @param xi: rotation of the lattice with respect to the x-axis in radians
-InterferenceFunction2DLattice* InterferenceFunction2DLattice::createHexagonal(
-    double lattice_length, double xi)
+InterferenceFunction2DLattice* InterferenceFunction2DLattice::createHexagonal(double lattice_length,
+                                                                              double xi)
 {
     return new InterferenceFunction2DLattice(HexagonalLattice(lattice_length, xi));
 }
@@ -96,7 +93,7 @@ void InterferenceFunction2DLattice::setIntegrationOverXi(bool integrate_xi)
 
 const Lattice2D& InterferenceFunction2DLattice::lattice() const
 {
-    if(!m_lattice)
+    if (!m_lattice)
         throw std::runtime_error("InterferenceFunction2DLattice::lattice() -> Error. "
                                  "No lattice defined.");
     return *m_lattice;
@@ -105,7 +102,7 @@ const Lattice2D& InterferenceFunction2DLattice::lattice() const
 double InterferenceFunction2DLattice::getParticleDensity() const
 {
     double area = m_lattice->unitCellArea();
-    return area == 0.0 ? 0.0 : 1.0/area;
+    return area == 0.0 ? 0.0 : 1.0 / area;
 }
 
 std::vector<const INode*> InterferenceFunction2DLattice::getChildren() const
@@ -132,13 +129,13 @@ double InterferenceFunction2DLattice::iff_without_dw(const kvector_t q) const
 }
 
 InterferenceFunction2DLattice::InterferenceFunction2DLattice(
-        const InterferenceFunction2DLattice& other)
+    const InterferenceFunction2DLattice& other)
     : IInterferenceFunction(other)
 {
     setName(other.getName());
-    if(other.m_lattice)
+    if (other.m_lattice)
         setLattice(*other.m_lattice);
-    if(other.m_decay)
+    if (other.m_decay)
         setDecayFunction(*other.m_decay);
     setIntegrationOverXi(other.integrationOverXi());
     init_parameters();
@@ -153,8 +150,7 @@ void InterferenceFunction2DLattice::setLattice(const Lattice2D& lattice)
 
 void InterferenceFunction2DLattice::init_parameters()
 {
-    mP_integrator
-        = make_integrator_real(this, &InterferenceFunction2DLattice::interferenceForXi);
+    mP_integrator = make_integrator_real(this, &InterferenceFunction2DLattice::interferenceForXi);
 }
 
 double InterferenceFunction2DLattice::interferenceForXi(double xi) const
@@ -169,7 +165,7 @@ double InterferenceFunction2DLattice::interferenceForXi(double xi) const
             result += interferenceAtOneRecLatticePoint(qx, qy);
         }
     }
-    return getParticleDensity()*result;
+    return getParticleDensity() * result;
 }
 
 double InterferenceFunction2DLattice::interferenceAtOneRecLatticePoint(double qx, double qy) const
@@ -184,8 +180,8 @@ double InterferenceFunction2DLattice::interferenceAtOneRecLatticePoint(double qx
 }
 
 // Rotate by angle gamma between orthonormal systems
-std::pair<double, double>
-InterferenceFunction2DLattice::rotateOrthonormal(double qx, double qy, double gamma) const
+std::pair<double, double> InterferenceFunction2DLattice::rotateOrthonormal(double qx, double qy,
+                                                                           double gamma) const
 {
     double q_X = qx * std::cos(gamma) + qy * std::sin(gamma);
     double q_Y = -qx * std::sin(gamma) + qy * std::cos(gamma);
@@ -219,7 +215,7 @@ InterferenceFunction2DLattice::calculateReciprocalVectorFraction(double qx, doub
 // Do not store xi in the reciprocal lattice
 void InterferenceFunction2DLattice::initialize_rec_vectors()
 {
-    if(!m_lattice)
+    if (!m_lattice)
         throw std::runtime_error("InterferenceFunction2DLattice::initialize_rec_vectors() -> "
                                  "Error. No lattice defined yet");
 
@@ -237,8 +233,8 @@ void InterferenceFunction2DLattice::initialize_calc_factors()
 
     // number of reciprocal lattice points to use
     auto q_bounds = m_decay->boundingReciprocalLatticeCoordinates(
-                nmax / m_decay->decayLengthX(), nmax / m_decay->decayLengthY(),
-                m_lattice->length1(), m_lattice->length2(), m_lattice->latticeAngle());
+        nmax / m_decay->decayLengthX(), nmax / m_decay->decayLengthY(), m_lattice->length1(),
+        m_lattice->length2(), m_lattice->latticeAngle());
     m_na = static_cast<int>(std::lround(q_bounds.first + 0.5));
     m_nb = static_cast<int>(std::lround(q_bounds.second + 0.5));
     m_na = std::max(m_na, min_points);
diff --git a/Core/Aggregate/InterferenceFunction2DLattice.h b/Core/Aggregate/InterferenceFunction2DLattice.h
index ac2672eab0e..79a93f5859e 100644
--- a/Core/Aggregate/InterferenceFunction2DLattice.h
+++ b/Core/Aggregate/InterferenceFunction2DLattice.h
@@ -15,8 +15,8 @@
 #ifndef INTERFERENCEFUNCTION2DLATTICE_H
 #define INTERFERENCEFUNCTION2DLATTICE_H
 
-#include "IInterferenceFunction.h"
 #include "FTDecayFunctions.h"
+#include "IInterferenceFunction.h"
 #include "Lattice2D.h"
 
 template <class T> class IntegratorReal;
@@ -28,7 +28,7 @@ class BA_CORE_API_ InterferenceFunction2DLattice : public IInterferenceFunction
 {
 public:
     InterferenceFunction2DLattice(const Lattice2D& lattice);
-    InterferenceFunction2DLattice(double length_1, double length_2, double alpha, double xi=0.0);
+    InterferenceFunction2DLattice(double length_1, double length_2, double alpha, double xi = 0.0);
     ~InterferenceFunction2DLattice() final;
 
     InterferenceFunction2DLattice* clone() const override final;
@@ -68,8 +68,8 @@ private:
 
     //! Returns qx,qy coordinates of q - qint, where qint is a reciprocal lattice vector
     //! bounding the reciprocal unit cell to which q belongs
-    std::pair<double, double> calculateReciprocalVectorFraction(
-            double qx, double qy, double xi) const;
+    std::pair<double, double> calculateReciprocalVectorFraction(double qx, double qy,
+                                                                double xi) const;
 
     //! Initializes the x,y coordinates of the a*,b* reciprocal bases
     void initialize_rec_vectors();
@@ -80,7 +80,7 @@ private:
     bool m_integrate_xi; //!< Integrate over the orientation xi
     std::unique_ptr<IFTDecayFunction2D> m_decay;
     std::unique_ptr<Lattice2D> m_lattice;
-    Lattice2D::ReciprocalBases m_sbase;  //!< reciprocal lattice is stored without xi
+    Lattice2D::ReciprocalBases m_sbase; //!< reciprocal lattice is stored without xi
     int m_na, m_nb; //!< determines the number of reciprocal lattice points to use
     mutable double m_qx;
     mutable double m_qy;
diff --git a/Core/Aggregate/InterferenceFunction2DParaCrystal.cpp b/Core/Aggregate/InterferenceFunction2DParaCrystal.cpp
index dd505d8a81d..e6914bd2a6c 100644
--- a/Core/Aggregate/InterferenceFunction2DParaCrystal.cpp
+++ b/Core/Aggregate/InterferenceFunction2DParaCrystal.cpp
@@ -16,15 +16,16 @@
 #include "BornAgainNamespace.h"
 #include "Exceptions.h"
 #include "IntegratorReal.h"
-#include "ParameterPool.h"
 #include "MathConstants.h"
+#include "ParameterPool.h"
 #include "RealParameter.h"
 #include <limits>
 
 InterferenceFunction2DParaCrystal::InterferenceFunction2DParaCrystal(const Lattice2D& lattice,
-    double damping_length, double domain_size_1, double domain_size_2)
-    : m_integrate_xi(false)
-    , m_damping_length(damping_length)
+                                                                     double damping_length,
+                                                                     double domain_size_1,
+                                                                     double domain_size_2)
+    : m_integrate_xi(false), m_damping_length(damping_length)
 {
     setName(BornAgain::InterferenceFunction2DParaCrystalType);
     setLattice(lattice);
@@ -40,9 +41,10 @@ InterferenceFunction2DParaCrystal::InterferenceFunction2DParaCrystal(const Latti
 //! @param damping_length: the damping (coherence) length of the paracrystal in nanometers
 
 InterferenceFunction2DParaCrystal::InterferenceFunction2DParaCrystal(double length_1,
-    double length_2, double alpha, double xi, double damping_length)
-    : m_integrate_xi(false)
-    , m_damping_length(damping_length)
+                                                                     double length_2, double alpha,
+                                                                     double xi,
+                                                                     double damping_length)
+    : m_integrate_xi(false), m_damping_length(damping_length)
 {
     setName(BornAgain::InterferenceFunction2DParaCrystalType);
     setLattice(BasicLattice(length_1, length_2, alpha, xi));
@@ -50,9 +52,7 @@ InterferenceFunction2DParaCrystal::InterferenceFunction2DParaCrystal(double leng
     init_parameters();
 }
 
-InterferenceFunction2DParaCrystal::~InterferenceFunction2DParaCrystal()
-{
-}
+InterferenceFunction2DParaCrystal::~InterferenceFunction2DParaCrystal() {}
 
 InterferenceFunction2DParaCrystal* InterferenceFunction2DParaCrystal::clone() const
 {
@@ -173,14 +173,17 @@ void InterferenceFunction2DParaCrystal::transformToPrincipalAxes(double qx, doub
 
 void InterferenceFunction2DParaCrystal::init_parameters()
 {
-    mP_integrator
-        = make_integrator_real(this, &InterferenceFunction2DParaCrystal::interferenceForXi);
+    mP_integrator =
+        make_integrator_real(this, &InterferenceFunction2DParaCrystal::interferenceForXi);
 
-    registerParameter(BornAgain::DampingLength, &m_damping_length).setUnit(BornAgain::UnitsNm)
+    registerParameter(BornAgain::DampingLength, &m_damping_length)
+        .setUnit(BornAgain::UnitsNm)
         .setNonnegative();
-    registerParameter(BornAgain::DomainSize1, &m_domain_sizes[0]).setUnit(BornAgain::UnitsNm)
+    registerParameter(BornAgain::DomainSize1, &m_domain_sizes[0])
+        .setUnit(BornAgain::UnitsNm)
         .setNonnegative();
-    registerParameter(BornAgain::DomainSize2, &m_domain_sizes[1]).setUnit(BornAgain::UnitsNm)
+    registerParameter(BornAgain::DomainSize2, &m_domain_sizes[1])
+        .setUnit(BornAgain::UnitsNm)
         .setNonnegative();
 }
 
@@ -219,9 +222,9 @@ double InterferenceFunction2DParaCrystal::interference1D(double qx, double qy, d
             result = nd;
         // for (1-fp)*nd small, take the series expansion to second order in nd*(1-fp)
         else if (std::abs(1.0 - fp) * nd < 2e-4) {
-            complex_t intermediate
-                = (nd - 1.0) / 2.0 + (nd * nd - 1.0) * (fp - 1.0) / 6.0
-                  + (nd * nd * nd - 2.0 * nd * nd - nd + 2.0) * (fp - 1.0) * (fp - 1.0) / 24.0;
+            complex_t intermediate =
+                (nd - 1.0) / 2.0 + (nd * nd - 1.0) * (fp - 1.0) / 6.0
+                + (nd * nd * nd - 2.0 * nd * nd - nd + 2.0) * (fp - 1.0) * (fp - 1.0) / 24.0;
             result = 1.0 + 2.0 * intermediate.real();
         } else {
             complex_t tmp;
@@ -230,8 +233,8 @@ double InterferenceFunction2DParaCrystal::interference1D(double qx, double qy, d
                 tmp = 0.0;
             else
                 tmp = std::pow(fp, n);
-            complex_t intermediate
-                = fp / (1.0 - fp) - fp * (1.0 - tmp) / nd / (1.0 - fp) / (1.0 - fp);
+            complex_t intermediate =
+                fp / (1.0 - fp) - fp * (1.0 - tmp) / nd / (1.0 - fp) / (1.0 - fp);
             result = 1.0 + 2.0 * intermediate.real();
         }
     }
diff --git a/Core/Aggregate/InterferenceFunction2DParaCrystal.h b/Core/Aggregate/InterferenceFunction2DParaCrystal.h
index 6f2acb9e021..48de91b3aab 100644
--- a/Core/Aggregate/InterferenceFunction2DParaCrystal.h
+++ b/Core/Aggregate/InterferenceFunction2DParaCrystal.h
@@ -15,9 +15,9 @@
 #ifndef INTERFERENCEFUNCTION2DPARACRYSTAL_H
 #define INTERFERENCEFUNCTION2DPARACRYSTAL_H
 
-#include "IInterferenceFunction.h"
 #include "Complex.h"
 #include "FTDistributions2D.h"
+#include "IInterferenceFunction.h"
 #include "Lattice2D.h"
 #include <memory>
 
@@ -31,8 +31,7 @@ class BA_CORE_API_ InterferenceFunction2DParaCrystal : public IInterferenceFunct
 {
 public:
     InterferenceFunction2DParaCrystal(const Lattice2D& lattice, double damping_length = 0.0,
-                                      double domain_size_1 = 0.0,
-                                      double domain_size_2 = 0.0);
+                                      double domain_size_1 = 0.0, double domain_size_2 = 0.0);
 
     InterferenceFunction2DParaCrystal(double length_1, double length_2, double alpha,
                                       double xi = 0.0, double damping_length = 0.0);
@@ -71,15 +70,9 @@ public:
 
     std::vector<const INode*> getChildren() const override final;
 
-    const IFTDistribution2D* pdf1() const
-    {
-        return m_pdf1.get();
-    }
+    const IFTDistribution2D* pdf1() const { return m_pdf1.get(); }
 
-    const IFTDistribution2D* pdf2() const
-    {
-        return m_pdf2.get();
-    }
+    const IFTDistribution2D* pdf2() const { return m_pdf2.get(); }
 
 private:
     double iff_without_dw(const kvector_t q) const override final;
@@ -96,7 +89,7 @@ private:
     bool m_integrate_xi; //!< Integrate over the orientation xi
     std::unique_ptr<IFTDistribution2D> m_pdf1, m_pdf2;
     std::unique_ptr<Lattice2D> m_lattice;
-    double m_damping_length; //!< Damping length for removing delta function singularity at q=0.
+    double m_damping_length;  //!< Damping length for removing delta function singularity at q=0.
     double m_domain_sizes[2]; //!< Coherence domain sizes
     mutable double m_qx;
     mutable double m_qy;
diff --git a/Core/Aggregate/InterferenceFunction2DSuperLattice.cpp b/Core/Aggregate/InterferenceFunction2DSuperLattice.cpp
index f1cff37230e..08b8a6c24eb 100644
--- a/Core/Aggregate/InterferenceFunction2DSuperLattice.cpp
+++ b/Core/Aggregate/InterferenceFunction2DSuperLattice.cpp
@@ -26,12 +26,10 @@
 
 using MathFunctions::Laue;
 
-InterferenceFunction2DSuperLattice::InterferenceFunction2DSuperLattice(
-        const Lattice2D& lattice, unsigned size_1, unsigned size_2)
-    : m_integrate_xi(false)
-    , mP_substructure(nullptr)
-    , m_size_1(size_1)
-    , m_size_2(size_2)
+InterferenceFunction2DSuperLattice::InterferenceFunction2DSuperLattice(const Lattice2D& lattice,
+                                                                       unsigned size_1,
+                                                                       unsigned size_2)
+    : m_integrate_xi(false), mP_substructure(nullptr), m_size_1(size_1), m_size_2(size_2)
 {
     setName(BornAgain::InterferenceFunction2DSuperLattice);
     setLattice(lattice);
@@ -45,11 +43,8 @@ InterferenceFunction2DSuperLattice::InterferenceFunction2DSuperLattice(
 //! @param alpha: angle between lattice vectors in radians
 //! @param xi: rotation of lattice with respect to x-axis (beam direction) in radians
 InterferenceFunction2DSuperLattice::InterferenceFunction2DSuperLattice(
-        double length_1, double length_2, double alpha, double xi, unsigned size_1, unsigned size_2)
-    : m_integrate_xi(false)
-    , mP_substructure(nullptr)
-    , m_size_1(size_1)
-    , m_size_2(size_2)
+    double length_1, double length_2, double alpha, double xi, unsigned size_1, unsigned size_2)
+    : m_integrate_xi(false), mP_substructure(nullptr), m_size_1(size_1), m_size_2(size_2)
 {
     setName(BornAgain::InterferenceFunction2DSuperLattice);
     setLattice(BasicLattice(length_1, length_2, alpha, xi));
@@ -57,7 +52,7 @@ InterferenceFunction2DSuperLattice::InterferenceFunction2DSuperLattice(
     init_parameters();
 }
 
-InterferenceFunction2DSuperLattice::~InterferenceFunction2DSuperLattice() =default;
+InterferenceFunction2DSuperLattice::~InterferenceFunction2DSuperLattice() = default;
 
 InterferenceFunction2DSuperLattice* InterferenceFunction2DSuperLattice::clone() const
 {
@@ -78,21 +73,23 @@ const IInterferenceFunction& InterferenceFunction2DSuperLattice::substructureIFF
 //! Creates square lattice.
 //! @param lattice_length: length of first and second lattice vectors in nanometers
 //! @param xi: rotation of lattice with respect to x-axis in radians
-InterferenceFunction2DSuperLattice* InterferenceFunction2DSuperLattice::createSquare(
-    double lattice_length, double xi, unsigned size_1, unsigned size_2)
+InterferenceFunction2DSuperLattice*
+InterferenceFunction2DSuperLattice::createSquare(double lattice_length, double xi, unsigned size_1,
+                                                 unsigned size_2)
 {
-    return new InterferenceFunction2DSuperLattice(SquareLattice(lattice_length, xi),
-                                                   size_1, size_2);
+    return new InterferenceFunction2DSuperLattice(SquareLattice(lattice_length, xi), size_1,
+                                                  size_2);
 }
 
 //! Creates hexagonal lattice.
 //! @param lattice_length: length of first and second lattice vectors in nanometers
 //! @param xi: rotation of lattice with respect to x-axis in radians
-InterferenceFunction2DSuperLattice* InterferenceFunction2DSuperLattice::createHexagonal(
-    double lattice_length, double xi, unsigned size_1, unsigned size_2)
+InterferenceFunction2DSuperLattice*
+InterferenceFunction2DSuperLattice::createHexagonal(double lattice_length, double xi,
+                                                    unsigned size_1, unsigned size_2)
 {
-    return new InterferenceFunction2DSuperLattice(HexagonalLattice(lattice_length, xi),
-                                                  size_1, size_2);
+    return new InterferenceFunction2DSuperLattice(HexagonalLattice(lattice_length, xi), size_1,
+                                                  size_2);
 }
 
 double InterferenceFunction2DSuperLattice::evaluate(const kvector_t q, double outer_iff) const
@@ -113,7 +110,7 @@ void InterferenceFunction2DSuperLattice::setIntegrationOverXi(bool integrate_xi)
 
 const Lattice2D& InterferenceFunction2DSuperLattice::lattice() const
 {
-    if(!mP_lattice)
+    if (!mP_lattice)
         throw std::runtime_error("InterferenceFunctionFinite2DLattice::lattice() -> Error. "
                                  "No lattice defined.");
     return *mP_lattice;
@@ -130,20 +127,18 @@ double InterferenceFunction2DSuperLattice::iff_without_dw(const kvector_t q) con
     double b = mP_lattice->length2();
     double xialpha = m_xi + mP_lattice->latticeAngle();
 
-    double qadiv2 = (q.x()*a*std::cos(m_xi) + q.y()*a*std::sin(m_xi)) / 2.0;
-    double qbdiv2 = (q.x()*b*std::cos(xialpha) + q.y()*b*std::sin(xialpha)) / 2.0;
-    double ampl = Laue(qadiv2, m_size_1)*Laue(qbdiv2, m_size_2);
-    return ampl*ampl / (m_size_1*m_size_2);
+    double qadiv2 = (q.x() * a * std::cos(m_xi) + q.y() * a * std::sin(m_xi)) / 2.0;
+    double qbdiv2 = (q.x() * b * std::cos(xialpha) + q.y() * b * std::sin(xialpha)) / 2.0;
+    double ampl = Laue(qadiv2, m_size_1) * Laue(qbdiv2, m_size_2);
+    return ampl * ampl / (m_size_1 * m_size_2);
 }
 
 InterferenceFunction2DSuperLattice::InterferenceFunction2DSuperLattice(
-        const InterferenceFunction2DSuperLattice& other)
-    : IInterferenceFunction(other)
-    , m_size_1(other.m_size_1)
-    , m_size_2(other.m_size_2)
+    const InterferenceFunction2DSuperLattice& other)
+    : IInterferenceFunction(other), m_size_1(other.m_size_1), m_size_2(other.m_size_2)
 {
     setName(other.getName());
-    if(other.mP_lattice)
+    if (other.mP_lattice)
         setLattice(*other.mP_lattice);
     setSubstructureIFF(*other.mP_substructure);
     setIntegrationOverXi(other.integrationOverXi());
@@ -158,8 +153,8 @@ void InterferenceFunction2DSuperLattice::setLattice(const Lattice2D& lattice)
 
 void InterferenceFunction2DSuperLattice::init_parameters()
 {
-    mP_integrator
-        = make_integrator_real(this, &InterferenceFunction2DSuperLattice::interferenceForXi);
+    mP_integrator =
+        make_integrator_real(this, &InterferenceFunction2DSuperLattice::interferenceForXi);
 }
 
 double InterferenceFunction2DSuperLattice::interferenceForXi(double xi) const
diff --git a/Core/Aggregate/InterferenceFunction2DSuperLattice.h b/Core/Aggregate/InterferenceFunction2DSuperLattice.h
index a6f42ffd46f..721061d5ee3 100644
--- a/Core/Aggregate/InterferenceFunction2DSuperLattice.h
+++ b/Core/Aggregate/InterferenceFunction2DSuperLattice.h
@@ -28,8 +28,8 @@ class BA_CORE_API_ InterferenceFunction2DSuperLattice : public IInterferenceFunc
 {
 public:
     InterferenceFunction2DSuperLattice(const Lattice2D& lattice, unsigned size_1, unsigned size_2);
-    InterferenceFunction2DSuperLattice(double length_1, double length_2, double alpha,
-                                        double xi, unsigned size_1, unsigned size_2);
+    InterferenceFunction2DSuperLattice(double length_1, double length_2, double alpha, double xi,
+                                       unsigned size_1, unsigned size_2);
     ~InterferenceFunction2DSuperLattice() final;
 
     InterferenceFunction2DSuperLattice* clone() const override final;
@@ -39,12 +39,12 @@ public:
     void setSubstructureIFF(const IInterferenceFunction& sub_iff);
     const IInterferenceFunction& substructureIFF() const;
 
-    static InterferenceFunction2DSuperLattice* createSquare(
-            double lattice_length, double xi, unsigned size_1, unsigned size_2);
-    static InterferenceFunction2DSuperLattice* createHexagonal(
-            double lattice_length, double xi, unsigned size_1, unsigned size_2);
+    static InterferenceFunction2DSuperLattice* createSquare(double lattice_length, double xi,
+                                                            unsigned size_1, unsigned size_2);
+    static InterferenceFunction2DSuperLattice* createHexagonal(double lattice_length, double xi,
+                                                               unsigned size_1, unsigned size_2);
 
-    double evaluate(const kvector_t q, double outer_iff=1.0) const override final;
+    double evaluate(const kvector_t q, double outer_iff = 1.0) const override final;
     unsigned domainSize1() const { return m_size_1; }
     unsigned domainSize2() const { return m_size_2; }
 
@@ -65,8 +65,8 @@ private:
 
     bool m_integrate_xi; //!< Integrate over the orientation xi
     std::unique_ptr<Lattice2D> mP_lattice;
-    std::unique_ptr<IInterferenceFunction> mP_substructure;  //!< IFF of substructure
-    unsigned m_size_1, m_size_2;  //!< Size of the finite lattice in lattice units
+    std::unique_ptr<IInterferenceFunction> mP_substructure; //!< IFF of substructure
+    unsigned m_size_1, m_size_2; //!< Size of the finite lattice in lattice units
     mutable double m_outer_iff;
     mutable double m_qx;
     mutable double m_qy;
diff --git a/Core/Aggregate/InterferenceFunction3DLattice.cpp b/Core/Aggregate/InterferenceFunction3DLattice.cpp
index db341c303eb..5f8c51dd4b8 100644
--- a/Core/Aggregate/InterferenceFunction3DLattice.cpp
+++ b/Core/Aggregate/InterferenceFunction3DLattice.cpp
@@ -19,16 +19,13 @@
 #include <algorithm>
 
 InterferenceFunction3DLattice::InterferenceFunction3DLattice(const Lattice& lattice)
-    : m_lattice(lattice)
-    , mP_peak_shape(nullptr)
-    , m_rec_radius(0.0)
+    : m_lattice(lattice), mP_peak_shape(nullptr), m_rec_radius(0.0)
 {
     setName(BornAgain::InterferenceFunction3DLatticeType);
     initRecRadius();
 }
 
-InterferenceFunction3DLattice::~InterferenceFunction3DLattice() =default;
-
+InterferenceFunction3DLattice::~InterferenceFunction3DLattice() = default;
 
 InterferenceFunction3DLattice* InterferenceFunction3DLattice::clone() const
 {
@@ -65,13 +62,13 @@ double InterferenceFunction3DLattice::iff_without_dw(const kvector_t q) const
     double inner_radius = 0.0;
     if (mP_peak_shape->angularDisorder()) {
         center = kvector_t(0.0, 0.0, 0.0);
-        inner_radius = std::max(0.0, q.mag()-radius);
+        inner_radius = std::max(0.0, q.mag() - radius);
         radius += q.mag();
     }
     auto rec_vectors = m_lattice.reciprocalLatticeVectorsWithinRadius(center, radius);
     double result = 0.0;
     for (const auto& q_rec : rec_vectors) {
-        if (!(q_rec.mag()<inner_radius)) {
+        if (!(q_rec.mag() < inner_radius)) {
             result += mP_peak_shape->evaluate(q, q_rec);
         }
     }
@@ -79,11 +76,9 @@ double InterferenceFunction3DLattice::iff_without_dw(const kvector_t q) const
 }
 
 InterferenceFunction3DLattice::InterferenceFunction3DLattice(
-        const InterferenceFunction3DLattice& other)
-    : IInterferenceFunction(other)
-    , m_lattice(other.m_lattice)
-    , mP_peak_shape(nullptr)
-    , m_rec_radius(0.0)
+    const InterferenceFunction3DLattice& other)
+    : IInterferenceFunction(other), m_lattice(other.m_lattice), mP_peak_shape(nullptr),
+      m_rec_radius(0.0)
 {
     setName(other.getName());
     initRecRadius();
diff --git a/Core/Aggregate/InterferenceFunction3DLattice.h b/Core/Aggregate/InterferenceFunction3DLattice.h
index bca3d2f5b3d..7c60d5faa0b 100644
--- a/Core/Aggregate/InterferenceFunction3DLattice.h
+++ b/Core/Aggregate/InterferenceFunction3DLattice.h
@@ -42,13 +42,14 @@ public:
     std::vector<const INode*> getChildren() const override final;
 
     void onChange() override final;
+
 private:
     double iff_without_dw(const kvector_t q) const override final;
     InterferenceFunction3DLattice(const InterferenceFunction3DLattice& other);
     void initRecRadius();
     Lattice m_lattice;
     std::unique_ptr<IPeakShape> mP_peak_shape;
-    double m_rec_radius;  //!< radius in reciprocal space defining the nearest q vectors to use
+    double m_rec_radius; //!< radius in reciprocal space defining the nearest q vectors to use
 };
 
 #endif // INTERFERENCEFUNCTION3DLATTICE_H
diff --git a/Core/Aggregate/InterferenceFunctionFinite2DLattice.cpp b/Core/Aggregate/InterferenceFunctionFinite2DLattice.cpp
index b81f1dc015e..1ce2cadc155 100644
--- a/Core/Aggregate/InterferenceFunctionFinite2DLattice.cpp
+++ b/Core/Aggregate/InterferenceFunctionFinite2DLattice.cpp
@@ -25,16 +25,13 @@
 
 using MathFunctions::Laue;
 
-
 //! Constructor of two-dimensional finite lattice interference function.
 //! @param lattice: object specifying a 2d lattice structure
 //! @param N_1: number of lattice cells in the first lattice direction
 //! @param N_2: number of lattice cells in the second lattice direction
-InterferenceFunctionFinite2DLattice::InterferenceFunctionFinite2DLattice(
-        const Lattice2D& lattice, unsigned N_1, unsigned N_2)
-    : m_integrate_xi(false)
-    , m_N_1(N_1)
-    , m_N_2(N_2)
+InterferenceFunctionFinite2DLattice::InterferenceFunctionFinite2DLattice(const Lattice2D& lattice,
+                                                                         unsigned N_1, unsigned N_2)
+    : m_integrate_xi(false), m_N_1(N_1), m_N_2(N_2)
 {
     setName(BornAgain::InterferenceFunctionFinite2DLatticeType);
     setLattice(lattice);
@@ -48,18 +45,18 @@ InterferenceFunctionFinite2DLattice::InterferenceFunctionFinite2DLattice(
 //! @param xi: rotation of lattice with respect to x-axis (beam direction) in radians
 //! @param N_1: number of lattice cells in the first lattice direction
 //! @param N_2: number of lattice cells in the second lattice direction
-InterferenceFunctionFinite2DLattice::InterferenceFunctionFinite2DLattice(
-        double length_1, double length_2, double alpha, double xi, unsigned N_1, unsigned N_2)
-    : m_integrate_xi(false)
-    , m_N_1(N_1)
-    , m_N_2(N_2)
+InterferenceFunctionFinite2DLattice::InterferenceFunctionFinite2DLattice(double length_1,
+                                                                         double length_2,
+                                                                         double alpha, double xi,
+                                                                         unsigned N_1, unsigned N_2)
+    : m_integrate_xi(false), m_N_1(N_1), m_N_2(N_2)
 {
     setName(BornAgain::InterferenceFunctionFinite2DLatticeType);
     setLattice(BasicLattice(length_1, length_2, alpha, xi));
     init_parameters();
 }
 
-InterferenceFunctionFinite2DLattice::~InterferenceFunctionFinite2DLattice() =default;
+InterferenceFunctionFinite2DLattice::~InterferenceFunctionFinite2DLattice() = default;
 
 InterferenceFunctionFinite2DLattice* InterferenceFunctionFinite2DLattice::clone() const
 {
@@ -71,11 +68,11 @@ InterferenceFunctionFinite2DLattice* InterferenceFunctionFinite2DLattice::clone(
 //! @param xi: rotation of lattice with respect to x-axis in radians
 //! @param N_1: number of lattice cells in the first lattice direction
 //! @param N_2: number of lattice cells in the second lattice direction
-InterferenceFunctionFinite2DLattice* InterferenceFunctionFinite2DLattice::createSquare(
-    double lattice_length, double xi, unsigned N_1, unsigned N_2)
+InterferenceFunctionFinite2DLattice*
+InterferenceFunctionFinite2DLattice::createSquare(double lattice_length, double xi, unsigned N_1,
+                                                  unsigned N_2)
 {
-    return new InterferenceFunctionFinite2DLattice(SquareLattice(lattice_length, xi),
-                                                   N_1, N_2);
+    return new InterferenceFunctionFinite2DLattice(SquareLattice(lattice_length, xi), N_1, N_2);
 }
 
 //! Creates hexagonal lattice.
@@ -83,11 +80,11 @@ InterferenceFunctionFinite2DLattice* InterferenceFunctionFinite2DLattice::create
 //! @param xi: rotation of lattice with respect to x-axis in radians
 //! @param N_1: number of lattice cells in the first lattice direction
 //! @param N_2: number of lattice cells in the second lattice direction
-InterferenceFunctionFinite2DLattice* InterferenceFunctionFinite2DLattice::createHexagonal(
-    double lattice_length, double xi, unsigned N_1, unsigned N_2)
+InterferenceFunctionFinite2DLattice*
+InterferenceFunctionFinite2DLattice::createHexagonal(double lattice_length, double xi, unsigned N_1,
+                                                     unsigned N_2)
 {
-    return new InterferenceFunctionFinite2DLattice(HexagonalLattice(lattice_length, xi),
-                                                   N_1, N_2);
+    return new InterferenceFunctionFinite2DLattice(HexagonalLattice(lattice_length, xi), N_1, N_2);
 }
 
 void InterferenceFunctionFinite2DLattice::setIntegrationOverXi(bool integrate_xi)
@@ -98,7 +95,7 @@ void InterferenceFunctionFinite2DLattice::setIntegrationOverXi(bool integrate_xi
 
 const Lattice2D& InterferenceFunctionFinite2DLattice::lattice() const
 {
-    if(!mP_lattice)
+    if (!mP_lattice)
         throw std::runtime_error("InterferenceFunctionFinite2DLattice::lattice() -> Error. "
                                  "No lattice defined.");
     return *mP_lattice;
@@ -107,7 +104,7 @@ const Lattice2D& InterferenceFunctionFinite2DLattice::lattice() const
 double InterferenceFunctionFinite2DLattice::getParticleDensity() const
 {
     double area = mP_lattice->unitCellArea();
-    return area == 0.0 ? 0.0 : 1.0/area;
+    return area == 0.0 ? 0.0 : 1.0 / area;
 }
 
 std::vector<const INode*> InterferenceFunctionFinite2DLattice::getChildren() const
@@ -125,13 +122,11 @@ double InterferenceFunctionFinite2DLattice::iff_without_dw(const kvector_t q) co
 }
 
 InterferenceFunctionFinite2DLattice::InterferenceFunctionFinite2DLattice(
-        const InterferenceFunctionFinite2DLattice& other)
-    : IInterferenceFunction(other)
-    , m_N_1(other.m_N_1)
-    , m_N_2(other.m_N_2)
+    const InterferenceFunctionFinite2DLattice& other)
+    : IInterferenceFunction(other), m_N_1(other.m_N_1), m_N_2(other.m_N_2)
 {
     setName(other.getName());
-    if(other.mP_lattice)
+    if (other.mP_lattice)
         setLattice(*other.mP_lattice);
     setIntegrationOverXi(other.integrationOverXi());
     init_parameters();
@@ -145,8 +140,8 @@ void InterferenceFunctionFinite2DLattice::setLattice(const Lattice2D& lattice)
 
 void InterferenceFunctionFinite2DLattice::init_parameters()
 {
-    mP_integrator
-        = make_integrator_real(this, &InterferenceFunctionFinite2DLattice::interferenceForXi);
+    mP_integrator =
+        make_integrator_real(this, &InterferenceFunctionFinite2DLattice::interferenceForXi);
 }
 
 double InterferenceFunctionFinite2DLattice::interferenceForXi(double xi) const
@@ -155,10 +150,10 @@ double InterferenceFunctionFinite2DLattice::interferenceForXi(double xi) const
     double b = mP_lattice->length2();
     double xialpha = xi + mP_lattice->latticeAngle();
 
-    double qadiv2 = (m_qx*a*std::cos(xi) + m_qy*a*std::sin(xi)) / 2.0;
-    double qbdiv2 = (m_qx*b*std::cos(xialpha) + m_qy*b*std::sin(xialpha)) / 2.0;
-    double ampl = Laue(qadiv2, m_N_1)*Laue(qbdiv2, m_N_2);
-    double lattice_factor = ampl*ampl / (m_N_1*m_N_2);
+    double qadiv2 = (m_qx * a * std::cos(xi) + m_qy * a * std::sin(xi)) / 2.0;
+    double qbdiv2 = (m_qx * b * std::cos(xialpha) + m_qy * b * std::sin(xialpha)) / 2.0;
+    double ampl = Laue(qadiv2, m_N_1) * Laue(qbdiv2, m_N_2);
+    double lattice_factor = ampl * ampl / (m_N_1 * m_N_2);
 
     return lattice_factor;
 }
diff --git a/Core/Aggregate/InterferenceFunctionFinite2DLattice.h b/Core/Aggregate/InterferenceFunctionFinite2DLattice.h
index 3093ce49976..400190e505b 100644
--- a/Core/Aggregate/InterferenceFunctionFinite2DLattice.h
+++ b/Core/Aggregate/InterferenceFunctionFinite2DLattice.h
@@ -27,18 +27,18 @@ class BA_CORE_API_ InterferenceFunctionFinite2DLattice : public IInterferenceFun
 {
 public:
     InterferenceFunctionFinite2DLattice(const Lattice2D& lattice, unsigned N_1, unsigned N_2);
-    InterferenceFunctionFinite2DLattice(double length_1, double length_2, double alpha,
-                                        double xi, unsigned N_1, unsigned N_2);
+    InterferenceFunctionFinite2DLattice(double length_1, double length_2, double alpha, double xi,
+                                        unsigned N_1, unsigned N_2);
     ~InterferenceFunctionFinite2DLattice() final;
 
     InterferenceFunctionFinite2DLattice* clone() const override final;
 
     void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
-    static InterferenceFunctionFinite2DLattice* createSquare(
-            double lattice_length, double xi, unsigned N_1, unsigned N_2);
-    static InterferenceFunctionFinite2DLattice* createHexagonal(
-            double lattice_length, double xi, unsigned N_1, unsigned N_2);
+    static InterferenceFunctionFinite2DLattice* createSquare(double lattice_length, double xi,
+                                                             unsigned N_1, unsigned N_2);
+    static InterferenceFunctionFinite2DLattice* createHexagonal(double lattice_length, double xi,
+                                                                unsigned N_1, unsigned N_2);
 
     unsigned numberUnitCells1() const { return m_N_1; }
     unsigned numberUnitCells2() const { return m_N_2; }
@@ -63,7 +63,7 @@ private:
 
     bool m_integrate_xi; //!< Integrate over the orientation xi
     std::unique_ptr<Lattice2D> mP_lattice;
-    unsigned m_N_1, m_N_2;  //!< Size of the finite lattice in lattice units
+    unsigned m_N_1, m_N_2; //!< Size of the finite lattice in lattice units
     mutable double m_qx;
     mutable double m_qy;
 #ifndef SWIG
diff --git a/Core/Aggregate/InterferenceFunctionFinite3DLattice.cpp b/Core/Aggregate/InterferenceFunctionFinite3DLattice.cpp
index 93b6887ccf0..6c046ecdb04 100644
--- a/Core/Aggregate/InterferenceFunctionFinite3DLattice.cpp
+++ b/Core/Aggregate/InterferenceFunctionFinite3DLattice.cpp
@@ -28,8 +28,9 @@ using MathFunctions::Laue;
 //! @param lattice: object specifying a 2d lattice structure
 //! @param N_1: number of lattice cells in the first lattice direction
 //! @param N_2: number of lattice cells in the second lattice direction
-InterferenceFunctionFinite3DLattice::InterferenceFunctionFinite3DLattice(
-        const Lattice& lattice, unsigned N_1, unsigned N_2, unsigned N_3)
+InterferenceFunctionFinite3DLattice::InterferenceFunctionFinite3DLattice(const Lattice& lattice,
+                                                                         unsigned N_1, unsigned N_2,
+                                                                         unsigned N_3)
     : m_N_1(N_1), m_N_2(N_2), m_N_3(N_3)
 {
     setName(BornAgain::InterferenceFunctionFinite3DLatticeType);
diff --git a/Core/Aggregate/InterferenceFunctionFinite3DLattice.h b/Core/Aggregate/InterferenceFunctionFinite3DLattice.h
index 58a3b59a903..93439a28b9b 100644
--- a/Core/Aggregate/InterferenceFunctionFinite3DLattice.h
+++ b/Core/Aggregate/InterferenceFunctionFinite3DLattice.h
@@ -41,13 +41,14 @@ public:
     bool supportsMultilayer() const override final { return false; }
 
     std::vector<const INode*> getChildren() const override final;
+
 private:
     double iff_without_dw(const kvector_t q) const override final;
     InterferenceFunctionFinite3DLattice(const InterferenceFunctionFinite3DLattice& other);
     void setLattice(const Lattice& lattice);
 
     std::unique_ptr<Lattice> mP_lattice;
-    unsigned m_N_1, m_N_2, m_N_3;  //!< Size of the finite lattice in lattice units
+    unsigned m_N_1, m_N_2, m_N_3; //!< Size of the finite lattice in lattice units
 };
 
 #endif // INTERFERENCEFUNCTIONFINITE3DLATTICE_H
diff --git a/Core/Aggregate/InterferenceFunctionHardDisk.cpp b/Core/Aggregate/InterferenceFunctionHardDisk.cpp
index 0a0e20f5df3..a1786627e1d 100644
--- a/Core/Aggregate/InterferenceFunctionHardDisk.cpp
+++ b/Core/Aggregate/InterferenceFunctionHardDisk.cpp
@@ -19,13 +19,13 @@
 #include "RealParameter.h"
 #include <cmath>
 
-
-namespace {
-static const double p = 7.0/3.0 - 4.0*std::sqrt(3.0)/M_PI;
+namespace
+{
+static const double p = 7.0 / 3.0 - 4.0 * std::sqrt(3.0) / M_PI;
 double Czero(double packing);
 double S2(double packing);
 double W2(double x);
-}
+} // namespace
 
 InterferenceFunctionHardDisk::InterferenceFunctionHardDisk(double radius, double density)
     : m_radius(radius), m_density(density)
@@ -35,7 +35,7 @@ InterferenceFunctionHardDisk::InterferenceFunctionHardDisk(double radius, double
     init_parameters();
 }
 
-InterferenceFunctionHardDisk::~InterferenceFunctionHardDisk() =default;
+InterferenceFunctionHardDisk::~InterferenceFunctionHardDisk() = default;
 
 InterferenceFunctionHardDisk* InterferenceFunctionHardDisk::clone() const
 {
@@ -47,14 +47,19 @@ double InterferenceFunctionHardDisk::getParticleDensity() const
     return m_density;
 }
 
-double InterferenceFunctionHardDisk::radius() const { return m_radius; }
+double InterferenceFunctionHardDisk::radius() const
+{
+    return m_radius;
+}
 
-double InterferenceFunctionHardDisk::density() const { return m_density; }
+double InterferenceFunctionHardDisk::density() const
+{
+    return m_density;
+}
 
-InterferenceFunctionHardDisk::InterferenceFunctionHardDisk(const InterferenceFunctionHardDisk &other)
-    : IInterferenceFunction(other)
-    , m_radius(other.m_radius)
-    , m_density(other.m_density)
+InterferenceFunctionHardDisk::InterferenceFunctionHardDisk(
+    const InterferenceFunctionHardDisk& other)
+    : IInterferenceFunction(other), m_radius(other.m_radius), m_density(other.m_density)
 {
     setName(BornAgain::InterferenceFunctionHardDiskType);
     validateParameters();
@@ -65,22 +70,22 @@ double InterferenceFunctionHardDisk::iff_without_dw(const kvector_t q) const
 {
     double qx = q.x();
     double qy = q.y();
-    m_q = 2.0*std::sqrt(qx*qx+qy*qy)*m_radius;
+    m_q = 2.0 * std::sqrt(qx * qx + qy * qy) * m_radius;
     m_packing = packingRatio();
     m_c_zero = Czero(m_packing);
     m_s2 = S2(m_packing);
-    double c_q = 2.0*M_PI*mP_integrator->integrate(0.0, 1.0);
-    double rho = 4.0*m_packing/M_PI;
-    return 1.0/(1.0 - rho*c_q);
+    double c_q = 2.0 * M_PI * mP_integrator->integrate(0.0, 1.0);
+    double rho = 4.0 * m_packing / M_PI;
+    return 1.0 / (1.0 - rho * c_q);
 }
 
 void InterferenceFunctionHardDisk::init_parameters()
 {
-    mP_integrator =
-            make_integrator_real(this, &InterferenceFunctionHardDisk::integrand);
+    mP_integrator = make_integrator_real(this, &InterferenceFunctionHardDisk::integrand);
     registerParameter(BornAgain::Radius, &m_radius).setUnit(BornAgain::UnitsNm).setNonnegative();
-    registerParameter(BornAgain::TotalParticleDensity, &m_density).setUnit(BornAgain::UnitsNm)
-            .setNonnegative();
+    registerParameter(BornAgain::TotalParticleDensity, &m_density)
+        .setUnit(BornAgain::UnitsNm)
+        .setNonnegative();
 }
 
 void InterferenceFunctionHardDisk::validateParameters() const
@@ -93,33 +98,35 @@ void InterferenceFunctionHardDisk::validateParameters() const
 
 double InterferenceFunctionHardDisk::packingRatio() const
 {
-    return M_PI*m_radius*m_radius*m_density;
+    return M_PI * m_radius * m_radius * m_density;
 }
 
 double InterferenceFunctionHardDisk::integrand(double x) const
 {
-    double cx = m_c_zero*(1.0 + 4.0*m_packing*(W2(x/2.0) - 1.0) + m_s2*x);
-    return x * cx * MathFunctions::Bessel_J0(m_q*x);
+    double cx = m_c_zero * (1.0 + 4.0 * m_packing * (W2(x / 2.0) - 1.0) + m_s2 * x);
+    return x * cx * MathFunctions::Bessel_J0(m_q * x);
 }
 
-namespace {
+namespace
+{
 double Czero(double packing)
 {
-    double numerator = 1.0 + packing + 3.0*p*packing*packing - p*std::pow(packing, 3);
-    double denominator = std::pow(1.0-packing, 3);
-    return -numerator/denominator;
+    double numerator = 1.0 + packing + 3.0 * p * packing * packing - p * std::pow(packing, 3);
+    double denominator = std::pow(1.0 - packing, 3);
+    return -numerator / denominator;
 }
 
 double S2(double packing)
 {
-    double factor = 3.0*packing*packing/8.0;
-    double numerator = 8.0*(1.0-2.0*p) + (25.0-9.0*p)*p*packing - (7.0-3.0*p)*p*packing*packing;
-    double denominator = 1.0 + packing + 3.0*p*packing*packing - p*std::pow(packing, 3);
-    return factor*numerator/denominator;
+    double factor = 3.0 * packing * packing / 8.0;
+    double numerator = 8.0 * (1.0 - 2.0 * p) + (25.0 - 9.0 * p) * p * packing
+                       - (7.0 - 3.0 * p) * p * packing * packing;
+    double denominator = 1.0 + packing + 3.0 * p * packing * packing - p * std::pow(packing, 3);
+    return factor * numerator / denominator;
 }
 
 double W2(double x)
 {
-    return 2.0*(std::acos(x) - x*std::sqrt(1.0 - x*x))/M_PI;
-}
+    return 2.0 * (std::acos(x) - x * std::sqrt(1.0 - x * x)) / M_PI;
 }
+} // namespace
diff --git a/Core/Aggregate/InterferenceFunctionHardDisk.h b/Core/Aggregate/InterferenceFunctionHardDisk.h
index b18dc1ceea1..42490a9101d 100644
--- a/Core/Aggregate/InterferenceFunctionHardDisk.h
+++ b/Core/Aggregate/InterferenceFunctionHardDisk.h
@@ -40,6 +40,7 @@ public:
 
     double radius() const;
     double density() const;
+
 private:
     InterferenceFunctionHardDisk(const InterferenceFunctionHardDisk& other);
     double iff_without_dw(const kvector_t q) const override final;
diff --git a/Core/Aggregate/InterferenceFunctionRadialParaCrystal.cpp b/Core/Aggregate/InterferenceFunctionRadialParaCrystal.cpp
index 29e11cd8a72..7a55f096f4c 100644
--- a/Core/Aggregate/InterferenceFunctionRadialParaCrystal.cpp
+++ b/Core/Aggregate/InterferenceFunctionRadialParaCrystal.cpp
@@ -22,28 +22,28 @@
 //! Constructor of interference function of radial paracrystal.
 //! @param peak_distance: average distance to the next neighbor in nanometers
 //! @param damping_length: the damping (coherence) length of the paracrystal in nanometers
-InterferenceFunctionRadialParaCrystal::InterferenceFunctionRadialParaCrystal(
-        double peak_distance, double damping_length)
-    : m_peak_distance(peak_distance)
-    , m_damping_length(damping_length)
-    , m_use_damping_length(true)
-    , m_kappa(0.0)
-    , m_domain_size(0.0)
+InterferenceFunctionRadialParaCrystal::InterferenceFunctionRadialParaCrystal(double peak_distance,
+                                                                             double damping_length)
+    : m_peak_distance(peak_distance), m_damping_length(damping_length), m_use_damping_length(true),
+      m_kappa(0.0), m_domain_size(0.0)
 {
     setName(BornAgain::InterferenceFunctionRadialParaCrystalType);
-    if (m_damping_length==0.0)
+    if (m_damping_length == 0.0)
         m_use_damping_length = false;
     init_parameters();
 }
 
 void InterferenceFunctionRadialParaCrystal::init_parameters()
 {
-    registerParameter(BornAgain::PeakDistance, &m_peak_distance).setUnit(BornAgain::UnitsNm)
+    registerParameter(BornAgain::PeakDistance, &m_peak_distance)
+        .setUnit(BornAgain::UnitsNm)
         .setNonnegative();
-    registerParameter(BornAgain::DampingLength, &m_damping_length).setUnit(BornAgain::UnitsNm)
+    registerParameter(BornAgain::DampingLength, &m_damping_length)
+        .setUnit(BornAgain::UnitsNm)
         .setNonnegative();
     registerParameter(BornAgain::SizeSpaceCoupling, &m_kappa).setNonnegative();
-    registerParameter(BornAgain::DomainSize, &m_domain_size).setUnit(BornAgain::UnitsNm)
+    registerParameter(BornAgain::DomainSize, &m_domain_size)
+        .setUnit(BornAgain::UnitsNm)
         .setNonnegative();
 }
 
@@ -74,18 +74,18 @@ void InterferenceFunctionRadialParaCrystal::setDomainSize(double size)
 
 complex_t InterferenceFunctionRadialParaCrystal::FTPDF(double qpar) const
 {
-    complex_t phase = exp_I(qpar*m_peak_distance);
+    complex_t phase = exp_I(qpar * m_peak_distance);
     double amplitude = mP_pdf->evaluate(qpar);
-    complex_t result = phase*amplitude;
+    complex_t result = phase * amplitude;
     if (m_use_damping_length)
-        result *= std::exp(-m_peak_distance/m_damping_length);
+        result *= std::exp(-m_peak_distance / m_damping_length);
     return result;
 }
 
 //! Sets one-dimensional probability distribution.
 //! @param pdf: probability distribution (Fourier transform of probability density)
 
-void InterferenceFunctionRadialParaCrystal::setProbabilityDistribution(const IFTDistribution1D &pdf)
+void InterferenceFunctionRadialParaCrystal::setProbabilityDistribution(const IFTDistribution1D& pdf)
 {
     mP_pdf.reset(pdf.clone());
     registerChild(mP_pdf.get());
@@ -100,54 +100,52 @@ double InterferenceFunctionRadialParaCrystal::iff_without_dw(const kvector_t q)
 {
     if (!mP_pdf)
         throw Exceptions::NullPointerException("InterferenceFunctionRadialParaCrystal::"
-                "evaluate() -> Error! Probability distribution for "
-                "interference function not properly initialized");
-    double result=0.0;
+                                               "evaluate() -> Error! Probability distribution for "
+                                               "interference function not properly initialized");
+    double result = 0.0;
     double qxr = q.x();
     double qyr = q.y();
-    double qpar = std::sqrt(qxr*qxr + qyr*qyr);
-    int n = static_cast<int>(std::abs(m_domain_size/m_peak_distance));
+    double qpar = std::sqrt(qxr * qxr + qyr * qyr);
+    int n = static_cast<int>(std::abs(m_domain_size / m_peak_distance));
     double nd = static_cast<double>(n);
     complex_t fp = FTPDF(qpar);
-    if (n<1) {
-        if (std::abs(1.0 - fp) < 10.*std::numeric_limits<double>::epsilon()) {
-            result = mP_pdf->qSecondDerivative()/m_peak_distance/m_peak_distance;
+    if (n < 1) {
+        if (std::abs(1.0 - fp) < 10. * std::numeric_limits<double>::epsilon()) {
+            result = mP_pdf->qSecondDerivative() / m_peak_distance / m_peak_distance;
         } else {
-            result = ((1.0 + fp)/(1.0 - fp)).real();
+            result = ((1.0 + fp) / (1.0 - fp)).real();
         }
     } else {
-        if (std::norm(1.0-fp) < 10.*std::numeric_limits<double>::epsilon() ) {
+        if (std::norm(1.0 - fp) < 10. * std::numeric_limits<double>::epsilon()) {
             result = nd;
         }
         // for (1-fp)*nd small, take the series expansion to second order in nd*(1-fp)
-        else if (std::abs(1.0-fp)*nd < 2e-4) {
-            complex_t intermediate = (nd-1.0)/2.0 + (nd*nd-1.0)*(fp-1.0)/6.0
-                    + (nd*nd*nd-2.0*nd*nd-nd+2.0)*(fp-1.0)*(fp-1.0)/24.0;
-            result = 1.0 + 2.0*intermediate.real();
-        }
-        else {
+        else if (std::abs(1.0 - fp) * nd < 2e-4) {
+            complex_t intermediate =
+                (nd - 1.0) / 2.0 + (nd * nd - 1.0) * (fp - 1.0) / 6.0
+                + (nd * nd * nd - 2.0 * nd * nd - nd + 2.0) * (fp - 1.0) * (fp - 1.0) / 24.0;
+            result = 1.0 + 2.0 * intermediate.real();
+        } else {
             complex_t tmp;
-            if (std::abs(fp)==0.0
-             || std::log(std::abs(fp))*nd < std::log(std::numeric_limits<double>::min())) {
-                            tmp = 0.0;
+            if (std::abs(fp) == 0.0
+                || std::log(std::abs(fp)) * nd < std::log(std::numeric_limits<double>::min())) {
+                tmp = 0.0;
             } else {
-                tmp = std::pow(fp,n);
+                tmp = std::pow(fp, n);
             }
-            complex_t intermediate = fp/(1.0-fp) - fp*(1.0-tmp)/nd/(1.0-fp)/(1.0-fp);
-            result = 1.0 + 2.0*intermediate.real();
+            complex_t intermediate =
+                fp / (1.0 - fp) - fp * (1.0 - tmp) / nd / (1.0 - fp) / (1.0 - fp);
+            result = 1.0 + 2.0 * intermediate.real();
         }
     }
     return result;
 }
 
 InterferenceFunctionRadialParaCrystal::InterferenceFunctionRadialParaCrystal(
-        const InterferenceFunctionRadialParaCrystal& other)
-    : IInterferenceFunction(other)
-    , m_peak_distance(other.m_peak_distance)
-    , m_damping_length(other.m_damping_length)
-    , m_use_damping_length(other.m_use_damping_length)
-    , m_kappa(other.m_kappa)
-    , m_domain_size(other.m_domain_size)
+    const InterferenceFunctionRadialParaCrystal& other)
+    : IInterferenceFunction(other), m_peak_distance(other.m_peak_distance),
+      m_damping_length(other.m_damping_length), m_use_damping_length(other.m_use_damping_length),
+      m_kappa(other.m_kappa), m_domain_size(other.m_domain_size)
 {
     setName(other.getName());
     init_parameters();
diff --git a/Core/Aggregate/InterferenceFunctionRadialParaCrystal.h b/Core/Aggregate/InterferenceFunctionRadialParaCrystal.h
index 47033d84599..f6dbd894c11 100644
--- a/Core/Aggregate/InterferenceFunctionRadialParaCrystal.h
+++ b/Core/Aggregate/InterferenceFunctionRadialParaCrystal.h
@@ -15,9 +15,9 @@
 #ifndef INTERFERENCEFUNCTIONRADIALPARACRYSTAL_H
 #define INTERFERENCEFUNCTIONRADIALPARACRYSTAL_H
 
-#include "IInterferenceFunction.h"
 #include "Complex.h"
 #include "FTDistributions1D.h"
+#include "IInterferenceFunction.h"
 #include <memory>
 
 //! Interference function of radial paracrystal.
@@ -26,7 +26,7 @@
 class BA_CORE_API_ InterferenceFunctionRadialParaCrystal : public IInterferenceFunction
 {
 public:
-    InterferenceFunctionRadialParaCrystal(double peak_distance, double damping_length=0.0);
+    InterferenceFunctionRadialParaCrystal(double peak_distance, double damping_length = 0.0);
     InterferenceFunctionRadialParaCrystal* clone() const override final;
 
     void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
@@ -54,12 +54,12 @@ private:
     InterferenceFunctionRadialParaCrystal(const InterferenceFunctionRadialParaCrystal& other);
     void init_parameters();
 
-    double m_peak_distance; //!< the distance to the first neighbor peak
+    double m_peak_distance;  //!< the distance to the first neighbor peak
     double m_damping_length; //!< damping length of paracrystal
     //! Fourier transformed probability distribution of the nearest particle
     std::unique_ptr<IFTDistribution1D> mP_pdf;
     bool m_use_damping_length;
-    double m_kappa; //!< Size-spacing coupling parameter
+    double m_kappa;       //!< Size-spacing coupling parameter
     double m_domain_size; //!< Size of coherence domain
 };
 
diff --git a/Core/Aggregate/InterferenceFunctionTwin.cpp b/Core/Aggregate/InterferenceFunctionTwin.cpp
index e990a164c1e..9825e8a80a4 100644
--- a/Core/Aggregate/InterferenceFunctionTwin.cpp
+++ b/Core/Aggregate/InterferenceFunctionTwin.cpp
@@ -47,10 +47,8 @@ double InterferenceFunctionTwin::stdDev() const
 }
 
 InterferenceFunctionTwin::InterferenceFunctionTwin(const InterferenceFunctionTwin& other)
-    : IInterferenceFunction(other)
-    , m_direction(other.m_direction)
-    , m_distance(other.m_distance)
-    , m_std_dev(other.m_std_dev)
+    : IInterferenceFunction(other), m_direction(other.m_direction), m_distance(other.m_distance),
+      m_std_dev(other.m_std_dev)
 {
     setName(BornAgain::InterferenceFunctionTwinType);
     validateParameters();
@@ -60,7 +58,9 @@ InterferenceFunctionTwin::InterferenceFunctionTwin(const InterferenceFunctionTwi
 double InterferenceFunctionTwin::iff_without_dw(const kvector_t q) const
 {
     double q_proj = q.dot(m_direction.unit());
-    return 1.0 + std::exp(-q_proj*q_proj*m_std_dev*m_std_dev/2.0)*std::cos(q_proj*m_distance);
+    return 1.0
+           + std::exp(-q_proj * q_proj * m_std_dev * m_std_dev / 2.0)
+                 * std::cos(q_proj * m_distance);
 }
 
 void InterferenceFunctionTwin::validateParameters() const
diff --git a/Core/Aggregate/ParticleLayout.cpp b/Core/Aggregate/ParticleLayout.cpp
index 01b67f67827..b4d7f69e23c 100644
--- a/Core/Aggregate/ParticleLayout.cpp
+++ b/Core/Aggregate/ParticleLayout.cpp
@@ -17,30 +17,29 @@
 #include "Exceptions.h"
 #include "IInterferenceFunction.h"
 #include "InterferenceFunctionNone.h"
+#include "ParameterPool.h"
 #include "Particle.h"
 #include "ParticleDistribution.h"
 #include "RealParameter.h"
-#include "ParameterPool.h"
 
-namespace {
+namespace
+{
 
 //! Returns true if interference function is able to calculate particle density automatically,
 //! which is the case for 2D functions.
 bool particleDensityIsProvidedByInterference(const IInterferenceFunction& iff)
 {
-    if(iff.getName() == BornAgain::InterferenceFunction2DLatticeType ||
-       iff.getName() == BornAgain::InterferenceFunction2DParaCrystalType ||
-       iff.getName() == BornAgain::InterferenceFunction2DSuperLattice ||
-       iff.getName() == BornAgain::InterferenceFunctionFinite2DLatticeType ||
-       iff.getName() == BornAgain::InterferenceFunctionHardDiskType)
+    if (iff.getName() == BornAgain::InterferenceFunction2DLatticeType
+        || iff.getName() == BornAgain::InterferenceFunction2DParaCrystalType
+        || iff.getName() == BornAgain::InterferenceFunction2DSuperLattice
+        || iff.getName() == BornAgain::InterferenceFunctionFinite2DLatticeType
+        || iff.getName() == BornAgain::InterferenceFunctionHardDiskType)
         return true;
     return false;
 }
-}
+} // namespace
 
-ParticleLayout::ParticleLayout()
-    : mP_interference_function {nullptr}
-    , m_total_particle_density {0.01}
+ParticleLayout::ParticleLayout() : mP_interference_function{nullptr}, m_total_particle_density{0.01}
 {
     setName(BornAgain::ParticleLayoutType);
     registerParticleDensity();
@@ -50,8 +49,7 @@ ParticleLayout::ParticleLayout()
 ParticleLayout::~ParticleLayout() {} // needs member class definitions => don't move to .h
 
 ParticleLayout::ParticleLayout(const IAbstractParticle& particle, double abundance)
-    : mP_interference_function {nullptr}
-    , m_total_particle_density {0.01}
+    : mP_interference_function{nullptr}, m_total_particle_density{0.01}
 {
     setName(BornAgain::ParticleLayoutType);
     addParticle(particle, abundance);
@@ -83,12 +81,12 @@ 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() };
-    if (abundance>=0.0)
+    std::unique_ptr<IAbstractParticle> P_particle_clone{particle.clone()};
+    if (abundance >= 0.0)
         P_particle_clone->setAbundance(abundance);
     if (!rotation.isIdentity())
         P_particle_clone->rotate(rotation);
-    if(position != kvector_t(0,0,0))
+    if (position != kvector_t(0, 0, 0))
         P_particle_clone->translate(position);
     addAndRegisterAbstractParticle(P_particle_clone.release());
 }
@@ -98,10 +96,10 @@ void ParticleLayout::addParticle(const IAbstractParticle& particle, double abund
 SafePointerVector<IParticle> ParticleLayout::particles() const
 {
     SafePointerVector<IParticle> particle_vector;
-    for (auto particle: m_particles) {
+    for (auto particle : m_particles) {
         if (const auto* p_part_distr = dynamic_cast<const ParticleDistribution*>(particle)) {
             SafePointerVector<IParticle> generated_particles = p_part_distr->generateParticles();
-            for (const IParticle* particle: generated_particles)
+            for (const IParticle* particle : generated_particles)
                 particle_vector.push_back(particle->clone());
         } else if (const auto* p_iparticle = dynamic_cast<const IParticle*>(particle)) {
             particle_vector.push_back(p_iparticle->clone());
@@ -110,7 +108,7 @@ SafePointerVector<IParticle> ParticleLayout::particles() const
     return particle_vector;
 }
 
-const IInterferenceFunction *ParticleLayout::interferenceFunction() const
+const IInterferenceFunction* ParticleLayout::interferenceFunction() const
 {
     return mP_interference_function.get();
 }
@@ -147,7 +145,7 @@ void ParticleLayout::setTotalParticleSurfaceDensity(double particle_density)
 std::vector<const INode*> ParticleLayout::getChildren() const
 {
     std::vector<const INode*> result;
-    for(auto particle : m_particles)
+    for (auto particle : m_particles)
         result.push_back(particle);
     result << mP_interference_function;
     return result;
@@ -166,7 +164,7 @@ void ParticleLayout::setAndRegisterInterferenceFunction(IInterferenceFunction* c
     mP_interference_function.reset(child);
     registerChild(child);
 
-    if(particleDensityIsProvidedByInterference(*mP_interference_function))
+    if (particleDensityIsProvidedByInterference(*mP_interference_function))
         registerParticleDensity(false);
     else
         registerParticleDensity(true);
@@ -174,8 +172,8 @@ void ParticleLayout::setAndRegisterInterferenceFunction(IInterferenceFunction* c
 
 void ParticleLayout::registerParticleDensity(bool make_registered)
 {
-    if(make_registered) {
-        if(!parameter(BornAgain::TotalParticleDensity))
+    if (make_registered) {
+        if (!parameter(BornAgain::TotalParticleDensity))
             registerParameter(BornAgain::TotalParticleDensity, &m_total_particle_density);
     } else {
         removeParameter(BornAgain::TotalParticleDensity);
diff --git a/Core/Aggregate/ParticleLayout.h b/Core/Aggregate/ParticleLayout.h
index 9fbe903bacb..4e93d96fd90 100644
--- a/Core/Aggregate/ParticleLayout.h
+++ b/Core/Aggregate/ParticleLayout.h
@@ -31,16 +31,16 @@ class BA_CORE_API_ ParticleLayout : public ILayout
 {
 public:
     ParticleLayout();
-    ParticleLayout(const IAbstractParticle& particle, double abundance=-1.0);
+    ParticleLayout(const IAbstractParticle& particle, double abundance = -1.0);
     ~ParticleLayout() override;
 
     ParticleLayout* clone() const final override;
 
     void accept(INodeVisitor* visitor) const final override { visitor->visit(this); }
 
-    void addParticle(const IAbstractParticle& particle, double abundance=-1.0,
-                     const kvector_t position=kvector_t(),
-                     const IRotation& rotation=IdentityRotation());
+    void addParticle(const IAbstractParticle& particle, double abundance = -1.0,
+                     const kvector_t position = kvector_t(),
+                     const IRotation& rotation = IdentityRotation());
 
     SafePointerVector<IParticle> particles() const final override;
 
diff --git a/Core/Basics/BornAgainNamespace.h b/Core/Basics/BornAgainNamespace.h
index c7e4258ff6c..2c94354d01b 100644
--- a/Core/Basics/BornAgainNamespace.h
+++ b/Core/Basics/BornAgainNamespace.h
@@ -255,6 +255,6 @@ const std::string UnitsRad = "rad";
 const std::string UnitsNm = "nm";
 const std::string UnitsNm2 = "nm^2";
 const std::string UnitsNone = "";
-}
+} // namespace BornAgain
 
 #endif // BORNAGAINNAMESPACE_H
diff --git a/Core/Basics/Complex.h b/Core/Basics/Complex.h
index 3528a8b66c4..25a7739b88f 100644
--- a/Core/Basics/Complex.h
+++ b/Core/Basics/Complex.h
@@ -20,9 +20,15 @@
 typedef std::complex<double> complex_t;
 
 //! Returns product I*z, where I is the imaginary unit.
-inline complex_t mul_I( complex_t z ) { return complex_t( -z.imag(), z.real() ); }
+inline complex_t mul_I(complex_t z)
+{
+    return complex_t(-z.imag(), z.real());
+}
 
 //! Returns exp(I*z), where I is the imaginary unit.
-inline complex_t exp_I( complex_t z ) { return std::exp( complex_t( -z.imag(), z.real() ) ); }
+inline complex_t exp_I(complex_t z)
+{
+    return std::exp(complex_t(-z.imag(), z.real()));
+}
 
 #endif // COMPLEX_H
diff --git a/Core/Basics/Exceptions.cpp b/Core/Basics/Exceptions.cpp
index cc2191433d8..fb83b213714 100644
--- a/Core/Basics/Exceptions.cpp
+++ b/Core/Basics/Exceptions.cpp
@@ -15,35 +15,34 @@
 #include "Exceptions.h"
 #include <iostream>
 
-namespace Exceptions {
+namespace Exceptions
+{
 
 void LogExceptionMessage(const std::string&)
 {
-//    std::cerr << message << std::endl;
+    //    std::cerr << message << std::endl;
 }
 
 NotImplementedException::NotImplementedException(const std::string& message)
     : std::logic_error(message)
 {
-     LogExceptionMessage(message);
+    LogExceptionMessage(message);
 }
 
-NullPointerException::NullPointerException(const std::string& message)
-    : std::logic_error(message)
+NullPointerException::NullPointerException(const std::string& message) : std::logic_error(message)
 {
-     LogExceptionMessage(message);
+    LogExceptionMessage(message);
 }
 
-OutOfBoundsException::OutOfBoundsException(const std::string& message)
-    : std::logic_error(message)
+OutOfBoundsException::OutOfBoundsException(const std::string& message) : std::logic_error(message)
 {
-     LogExceptionMessage(message);
+    LogExceptionMessage(message);
 }
 
 ClassInitializationException::ClassInitializationException(const std::string& message)
     : std::runtime_error(message)
 {
-     LogExceptionMessage(message);
+    LogExceptionMessage(message);
 }
 
 UnknownClassRegistrationException::UnknownClassRegistrationException(const std::string& message)
@@ -58,8 +57,7 @@ ExistingClassRegistrationException::ExistingClassRegistrationException(const std
     LogExceptionMessage(message);
 }
 
-LogicErrorException::LogicErrorException(const std::string& message)
-    : std::logic_error(message)
+LogicErrorException::LogicErrorException(const std::string& message) : std::logic_error(message)
 {
     LogExceptionMessage(message);
 }
@@ -76,8 +74,7 @@ DivisionByZeroException::DivisionByZeroException(const std::string& message)
     LogExceptionMessage(message);
 }
 
-DomainErrorException::DomainErrorException(const std::string& message)
-    : std::domain_error(message)
+DomainErrorException::DomainErrorException(const std::string& message) : std::domain_error(message)
 {
     LogExceptionMessage(message);
 }
@@ -88,14 +85,12 @@ FileNotIsOpenException::FileNotIsOpenException(const std::string& message)
     LogExceptionMessage(message);
 }
 
-FileIsBadException::FileIsBadException(const std::string& message)
-    : std::runtime_error(message)
+FileIsBadException::FileIsBadException(const std::string& message) : std::runtime_error(message)
 {
     LogExceptionMessage(message);
 }
 
-FormatErrorException::FormatErrorException(const std::string& message)
-    : std::runtime_error(message)
+FormatErrorException::FormatErrorException(const std::string& message) : std::runtime_error(message)
 {
     LogExceptionMessage(message);
 }
diff --git a/Core/Basics/Exceptions.h b/Core/Basics/Exceptions.h
index 5ee28d23513..c837ce9c516 100644
--- a/Core/Basics/Exceptions.h
+++ b/Core/Basics/Exceptions.h
@@ -22,13 +22,14 @@
 #ifdef _WIN32
 #ifdef _MSC_VER
 #pragma warning(push)
-#pragma warning(disable: 4275)
+#pragma warning(disable : 4275)
 #endif
 #endif
 
 //! Different exceptions, all inheriting from std::exception.
 
-namespace Exceptions {
+namespace Exceptions
+{
 
 class BA_CORE_API_ NotImplementedException : public std::logic_error
 {
@@ -110,7 +111,7 @@ public:
 
 void LogExceptionMessage(const std::string& message);
 
-} // namespace Exceptions;
+} // namespace Exceptions
 
 #ifdef _WIN32
 #ifdef _MSC_VER
diff --git a/Core/Basics/ICloneable.cpp b/Core/Basics/ICloneable.cpp
index 9325a4d90dd..b4bcbe68205 100644
--- a/Core/Basics/ICloneable.cpp
+++ b/Core/Basics/ICloneable.cpp
@@ -15,5 +15,5 @@
 #include "ICloneable.h"
 
 // To emit vtable in this translation unit (see warning weak-vtables):
-ICloneable::ICloneable() =default;
-ICloneable::~ICloneable() =default;
+ICloneable::ICloneable() = default;
+ICloneable::~ICloneable() = default;
diff --git a/Core/Basics/ICloneable.h b/Core/Basics/ICloneable.h
index 4b85e67ae13..22b4af7acff 100644
--- a/Core/Basics/ICloneable.h
+++ b/Core/Basics/ICloneable.h
@@ -29,10 +29,10 @@ public:
     ICloneable();
     virtual ~ICloneable();
 
-    ICloneable(const ICloneable&) =delete;
-    ICloneable& operator=(const ICloneable&) =delete;
+    ICloneable(const ICloneable&) = delete;
+    ICloneable& operator=(const ICloneable&) = delete;
 
-    virtual ICloneable* clone() const =0;
+    virtual ICloneable* clone() const = 0;
     virtual void transferToCPP() {} //!< Used for Python overriding of clone (see swig/tweaks.py)
 };
 
diff --git a/Core/Basics/INamed.cpp b/Core/Basics/INamed.cpp
index 6d24a4045c0..68e54f6ba96 100644
--- a/Core/Basics/INamed.cpp
+++ b/Core/Basics/INamed.cpp
@@ -15,5 +15,3 @@
 #include "INamed.h"
 
 INamed::~INamed() = default;
-
-
diff --git a/Core/Basics/INamed.h b/Core/Basics/INamed.h
index 86ad1ce00ea..c872b740f17 100644
--- a/Core/Basics/INamed.h
+++ b/Core/Basics/INamed.h
@@ -15,8 +15,8 @@
 #ifndef INAMED_H
 #define INAMED_H
 
-#include <string>
 #include "WinDllMacros.h"
+#include <string>
 
 //! Interface for named objects.
 //! @ingroup tools_internal
diff --git a/Core/Basics/ISingleton.h b/Core/Basics/ISingleton.h
index 2be269a0d55..fc331937fca 100644
--- a/Core/Basics/ISingleton.h
+++ b/Core/Basics/ISingleton.h
@@ -22,15 +22,15 @@
 //! Base class for singletons.
 //! @ingroup tools_internal
 
-template <class T>
-class ISingleton
+template <class T> class ISingleton
 {
 public:
-    static T& instance() {
+    static T& instance()
+    {
         static std::mutex single_mutex;
-        std::unique_lock<std::mutex> single_lock( single_mutex );
-        if( !m_instance) {
-            if( m_destroyed )
+        std::unique_lock<std::mutex> single_lock(single_mutex);
+        if (!m_instance) {
+            if (m_destroyed)
                 // In BornAgain, an ISingleton is deleted when and only when the application
                 // terminates. Therefore there is no point in re-creating a deleted ISingleton.
                 // To be 110% sure, we explicitly forbid re-creation.
@@ -38,13 +38,16 @@ public:
             static T theInstance;
             m_instance = &theInstance;
         }
-        return *m_instance; }
+        return *m_instance;
+    }
 
 protected:
-    ISingleton(){}
-    virtual ~ISingleton() {
+    ISingleton() {}
+    virtual ~ISingleton()
+    {
         m_instance = nullptr;
-        m_destroyed = true; }
+        m_destroyed = true;
+    }
 
 private:
     ISingleton(const ISingleton&) = delete;
@@ -54,7 +57,7 @@ private:
 };
 
 // for templated classes, initializations go into the .h file:
-template<class T> T* ISingleton<T>::m_instance = nullptr;
-template<class T> bool ISingleton<T>::m_destroyed = false;
+template <class T> T* ISingleton<T>::m_instance = nullptr;
+template <class T> bool ISingleton<T>::m_destroyed = false;
 
 #endif // ISINGLETON_H
diff --git a/Core/Basics/Macros.h b/Core/Basics/Macros.h
index bf2d688260b..b1e4f671a8a 100644
--- a/Core/Basics/Macros.h
+++ b/Core/Basics/Macros.h
@@ -36,23 +36,22 @@ http://gcc.gnu.org/onlinedocs/gcc-4.4.7/gcc/Diagnostic-Pragmas.html
 */
 
 #if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 402
-    #define GCC_DIAG_STR(s) #s
-    #define GCC_DIAG_JOINSTR(x,y) GCC_DIAG_STR(x ## y)
-    # define GCC_DIAG_DO_PRAGMA(x) _Pragma (#x)
-    # define GCC_DIAG_PRAGMA(x) GCC_DIAG_DO_PRAGMA(GCC diagnostic x)
-    # if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406
-        #  define GCC_DIAG_OFF(x) GCC_DIAG_PRAGMA(push) \
-            GCC_DIAG_PRAGMA(ignored GCC_DIAG_JOINSTR(-W,x))
-        #  define GCC_DIAG_ON(x) GCC_DIAG_PRAGMA(pop)
-    # else
-        #  define GCC_DIAG_OFF(x) GCC_DIAG_PRAGMA(ignored GCC_DIAG_JOINSTR(-W,x))
-        #  define GCC_DIAG_ON(x) GCC_DIAG_PRAGMA(warning GCC_DIAG_JOINSTR(-W,x))
-    # endif
+#define GCC_DIAG_STR(s) #s
+#define GCC_DIAG_JOINSTR(x, y) GCC_DIAG_STR(x##y)
+#define GCC_DIAG_DO_PRAGMA(x) _Pragma(#x)
+#define GCC_DIAG_PRAGMA(x) GCC_DIAG_DO_PRAGMA(GCC diagnostic x)
+#if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406
+#define GCC_DIAG_OFF(x)                                                                            \
+    GCC_DIAG_PRAGMA(push)                                                                          \
+    GCC_DIAG_PRAGMA(ignored GCC_DIAG_JOINSTR(-W, x))
+#define GCC_DIAG_ON(x) GCC_DIAG_PRAGMA(pop)
 #else
-    # define GCC_DIAG_OFF(x)
-    # define GCC_DIAG_ON(x)
+#define GCC_DIAG_OFF(x) GCC_DIAG_PRAGMA(ignored GCC_DIAG_JOINSTR(-W, x))
+#define GCC_DIAG_ON(x) GCC_DIAG_PRAGMA(warning GCC_DIAG_JOINSTR(-W, x))
+#endif
+#else
+#define GCC_DIAG_OFF(x)
+#define GCC_DIAG_ON(x)
 #endif
 
 #endif // MACROS_H
-
-
diff --git a/Core/Basics/MathConstants.h b/Core/Basics/MathConstants.h
index b49245ccd70..866cb434389 100644
--- a/Core/Basics/MathConstants.h
+++ b/Core/Basics/MathConstants.h
@@ -31,21 +31,21 @@
 #undef M_SQRT1_2
 
 // and define them using these potentially inactivated lines from math.h
-#define M_E            2.7182818284590452354   /* e */
-#define M_LOG2E        1.4426950408889634074   /* log_2 e */
-#define M_LOG10E       0.43429448190325182765  /* log_10 e */
-#define M_LN2          0.69314718055994530942  /* log_e 2 */
-#define M_LN10         2.30258509299404568402  /* log_e 10 */
-#define M_PI           3.14159265358979323846  /* pi */
-#define M_PI_2         1.57079632679489661923  /* pi/2 */
-#define M_PI_4         0.78539816339744830962  /* pi/4 */
-#define M_1_PI         0.31830988618379067154  /* 1/pi */
-#define M_2_PI         0.63661977236758134308  /* 2/pi */
-#define M_2_SQRTPI     1.12837916709551257390  /* 2/sqrt(pi) */
-#define M_SQRT2        1.41421356237309504880  /* sqrt(2) */
-#define M_SQRT1_2      0.70710678118654752440  /* 1/sqrt(2) */
+#define M_E 2.7182818284590452354         /* e */
+#define M_LOG2E 1.4426950408889634074     /* log_2 e */
+#define M_LOG10E 0.43429448190325182765   /* log_10 e */
+#define M_LN2 0.69314718055994530942      /* log_e 2 */
+#define M_LN10 2.30258509299404568402     /* log_e 10 */
+#define M_PI 3.14159265358979323846       /* pi */
+#define M_PI_2 1.57079632679489661923     /* pi/2 */
+#define M_PI_4 0.78539816339744830962     /* pi/4 */
+#define M_1_PI 0.31830988618379067154     /* 1/pi */
+#define M_2_PI 0.63661977236758134308     /* 2/pi */
+#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
+#define M_SQRT2 1.41421356237309504880    /* sqrt(2) */
+#define M_SQRT1_2 0.70710678118654752440  /* 1/sqrt(2) */
 
 // additionally, we find convenient:
-#define M_TWOPI        6.28318530717958647693
+#define M_TWOPI 6.28318530717958647693
 
 #endif // MATHCONSTANTS_H
diff --git a/Core/Basics/PhysicalConstants.h b/Core/Basics/PhysicalConstants.h
index 6332e4c7e7d..e2f537e8d56 100644
--- a/Core/Basics/PhysicalConstants.h
+++ b/Core/Basics/PhysicalConstants.h
@@ -15,15 +15,16 @@
 #ifndef PHYSICALCONSTANTS_H_
 #define PHYSICALCONSTANTS_H_
 
-namespace PhysConsts {
-constexpr double m_n = 1.674927471e-27; //!< Neutron mass, kg
-constexpr double h_bar = 1.05457180e-34; //!< Reduced Plank constant, J s
-constexpr double mu_N = 5.050783699e-27; //!< Nuclear magneton (\f$ \mu_N \f$), J/T
-constexpr double mu_B = 9.274009994e-24; //!< Bohr magneton (\f$ \mu_B \f$), J/T
-constexpr double r_e = 2.8179403227e-15; //!< Thomson scattering length (\f$ r_e \f$), m
-constexpr double gamma_n = 1.91304272; //!< \f$\gamma\f$ factor for neutron magnetic moment,
-                                             //!< \f$\mu_n = \gamma \cdot \mu_N\f$
+namespace PhysConsts
+{
+constexpr double m_n = 1.674927471e-27;    //!< Neutron mass, kg
+constexpr double h_bar = 1.05457180e-34;   //!< Reduced Plank constant, J s
+constexpr double mu_N = 5.050783699e-27;   //!< Nuclear magneton (\f$ \mu_N \f$), J/T
+constexpr double mu_B = 9.274009994e-24;   //!< Bohr magneton (\f$ \mu_B \f$), J/T
+constexpr double r_e = 2.8179403227e-15;   //!< Thomson scattering length (\f$ r_e \f$), m
+constexpr double gamma_n = 1.91304272;     //!< \f$\gamma\f$ factor for neutron magnetic moment,
+                                           //!< \f$\mu_n = \gamma \cdot \mu_N\f$
 constexpr double g_factor_n = -3.82608545; //!< neutron g-factor
-}
+} // namespace PhysConsts
 
 #endif /* PHYSICALCONSTANTS_H_ */
diff --git a/Core/Beam/Beam.cpp b/Core/Beam/Beam.cpp
index 1fd821b7717..410bb1a937a 100644
--- a/Core/Beam/Beam.cpp
+++ b/Core/Beam/Beam.cpp
@@ -17,25 +17,21 @@
 #include "Complex.h"
 #include "Exceptions.h"
 #include "FootprintFactorGaussian.h"
-#include "RealParameter.h"
 #include "MathConstants.h"
+#include "RealParameter.h"
 
 // Allow for 90 degrees by adding a relatively small constant to pi/2
 static constexpr double INCLINATION_LIMIT = M_PI_2 + 1e-10;
 
-Beam::Beam()
-    : m_wavelength(1.0), m_alpha(0.0), m_phi(0.0)
-    , m_intensity(1.0)
+Beam::Beam() : m_wavelength(1.0), m_alpha(0.0), m_phi(0.0), m_intensity(1.0)
 {
     setName(BornAgain::BeamType);
     init_parameters();
 }
 
 Beam::Beam(const Beam& other)
-    : m_wavelength(other.m_wavelength), m_alpha(other.m_alpha)
-    , m_phi(other.m_phi)
-    , m_intensity(other.m_intensity)
-    , m_bloch_vector(other.m_bloch_vector)
+    : m_wavelength(other.m_wavelength), m_alpha(other.m_alpha), m_phi(other.m_phi),
+      m_intensity(other.m_intensity), m_bloch_vector(other.m_bloch_vector)
 {
     setName(other.getName());
     if (other.m_shape_factor)
@@ -53,7 +49,7 @@ Beam& Beam::operator=(const Beam& other)
     return *this;
 }
 
-Beam::~Beam() =default;
+Beam::~Beam() = default;
 
 kvector_t Beam::getCentralK() const
 {
@@ -115,7 +111,7 @@ Eigen::Matrix2cd Beam::getPolarization() const
     double z = m_bloch_vector.z();
     result(0, 0) = (1.0 + z) / 2.0;
     result(0, 1) = complex_t(x, -y) / 2.0;
-    result(1, 0) = complex_t(x,  y) / 2.0;
+    result(1, 0) = complex_t(x, y) / 2.0;
     result(1, 1) = (1.0 - z) / 2.0;
     return result;
 }
@@ -131,11 +127,14 @@ std::vector<const INode*> Beam::getChildren() const
 void Beam::init_parameters()
 {
     registerParameter(BornAgain::Intensity, &m_intensity).setNonnegative();
-    registerParameter(BornAgain::Wavelength, &m_wavelength).setUnit(BornAgain::UnitsNm)
+    registerParameter(BornAgain::Wavelength, &m_wavelength)
+        .setUnit(BornAgain::UnitsNm)
         .setNonnegative();
-    registerParameter(BornAgain::Inclination, &m_alpha).setUnit(BornAgain::UnitsRad)
+    registerParameter(BornAgain::Inclination, &m_alpha)
+        .setUnit(BornAgain::UnitsRad)
         .setLimited(0, INCLINATION_LIMIT);
-    registerParameter(BornAgain::Azimuth, &m_phi).setUnit(BornAgain::UnitsRad)
+    registerParameter(BornAgain::Azimuth, &m_phi)
+        .setUnit(BornAgain::UnitsRad)
         .setLimited(-M_PI_2, M_PI_2);
     registerVector(BornAgain::BlochVector, &m_bloch_vector, BornAgain::UnitsNone);
 }
diff --git a/Core/Beam/Beam.h b/Core/Beam/Beam.h
index 0a68c969122..612b302664e 100644
--- a/Core/Beam/Beam.h
+++ b/Core/Beam/Beam.h
@@ -15,8 +15,8 @@
 #ifndef BEAM_H
 #define BEAM_H
 
-#include "INode.h"
 #include "EigenCore.h"
+#include "INode.h"
 #include "Vectors3D.h"
 
 class IFootprintFactor;
@@ -77,10 +77,10 @@ private:
 
     void swapContent(Beam& other);
 
-    double m_wavelength, m_alpha, m_phi; //!< wavelength and angles of beam
-    double m_intensity;                  //!< beam intensity (neutrons/sec)
+    double m_wavelength, m_alpha, m_phi;              //!< wavelength and angles of beam
+    double m_intensity;                               //!< beam intensity (neutrons/sec)
     std::unique_ptr<IFootprintFactor> m_shape_factor; //!< footprint correction handler
-    kvector_t m_bloch_vector;            //!< Bloch vector encoding the beam's polarization
+    kvector_t m_bloch_vector; //!< Bloch vector encoding the beam's polarization
 };
 
 #endif // BEAM_H
diff --git a/Core/Beam/IFootprintFactor.cpp b/Core/Beam/IFootprintFactor.cpp
index 68a7c1b6c9e..98a555d2078 100644
--- a/Core/Beam/IFootprintFactor.cpp
+++ b/Core/Beam/IFootprintFactor.cpp
@@ -35,8 +35,7 @@ void IFootprintFactor::setWidthRatio(double width_ratio)
 }
 
 IFootprintFactor::IFootprintFactor(const IFootprintFactor& other)
-    : ICloneable()
-    , m_width_ratio(other.m_width_ratio)
+    : ICloneable(), m_width_ratio(other.m_width_ratio)
 {
     initialize();
 }
diff --git a/Core/Beam/IFootprintFactor.h b/Core/Beam/IFootprintFactor.h
index f63d900d6f3..e41388350e5 100644
--- a/Core/Beam/IFootprintFactor.h
+++ b/Core/Beam/IFootprintFactor.h
@@ -34,7 +34,7 @@ public:
     virtual IFootprintFactor* clone() const = 0;
 
     void setWidthRatio(double width_ratio);
-    double widthRatio() const {return m_width_ratio;}
+    double widthRatio() const { return m_width_ratio; }
 
     //! Calculate footprint correction coefficient from the beam incident angle _alpha_.
     virtual double calculate(double alpha) const = 0;
diff --git a/Core/Binning/Bin.cpp b/Core/Binning/Bin.cpp
index 9411f7b67f9..659b936f98a 100644
--- a/Core/Binning/Bin.cpp
+++ b/Core/Binning/Bin.cpp
@@ -14,12 +14,15 @@
 
 #include "Bin.h"
 
-bool BinContains(const Bin1D &bin, double value)
+bool BinContains(const Bin1D& bin, double value)
 {
-    if (bin.getBinSize()==0.0) return false;
-    double coordinate = (value - bin.m_lower)/bin.getBinSize();
-    if (coordinate < 0.0) return false;
-    if (coordinate >= 1.0) return false;
+    if (bin.getBinSize() == 0.0)
+        return false;
+    double coordinate = (value - bin.m_lower) / bin.getBinSize();
+    if (coordinate < 0.0)
+        return false;
+    if (coordinate >= 1.0)
+        return false;
     return true;
 }
 
@@ -35,8 +38,6 @@ Bin1DKVector::Bin1DKVector(double wavelength, const Bin1D& alpha_bin, const Bin1
 Bin1DCVector::Bin1DCVector(double wavelength, const Bin1D& alpha_bin, const Bin1D& phi_bin)
     : m_q_lower(), m_q_upper()
 {
-    m_q_lower = vecOfLambdaAlphaPhi(
-        wavelength, alpha_bin.m_lower, phi_bin.m_lower).complex();
-    m_q_upper = vecOfLambdaAlphaPhi(
-        wavelength, alpha_bin.m_upper, phi_bin.m_upper).complex();
+    m_q_lower = vecOfLambdaAlphaPhi(wavelength, alpha_bin.m_lower, phi_bin.m_lower).complex();
+    m_q_upper = vecOfLambdaAlphaPhi(wavelength, alpha_bin.m_upper, phi_bin.m_upper).complex();
 }
diff --git a/Core/Binning/Bin.h b/Core/Binning/Bin.h
index 1d99de37d23..61cfd529aa7 100644
--- a/Core/Binning/Bin.h
+++ b/Core/Binning/Bin.h
@@ -17,13 +17,12 @@
 
 #include "Vectors3D.h"
 
-struct BA_CORE_API_ Bin1D
-{
+struct BA_CORE_API_ Bin1D {
     Bin1D() : m_lower(0), m_upper(0) {}
     Bin1D(double lower, double upper) : m_lower(lower), m_upper(upper) {}
-    double m_lower;  //!< lower bound of the bin
-    double m_upper;  //!< upper bound of the bin
-    double getMidPoint() const { return (m_lower + m_upper)/2.0; }
+    double m_lower; //!< lower bound of the bin
+    double m_upper; //!< upper bound of the bin
+    double getMidPoint() const { return (m_lower + m_upper) / 2.0; }
     double getBinSize() const { return m_upper - m_lower; }
 };
 
@@ -34,17 +33,17 @@ bool BinContains(const Bin1D& bin, double value);
 //! An one-dimensional range of kvector_t's.
 //! @ingroup tools_internal
 
-struct BA_CORE_API_ Bin1DKVector
-{
+struct BA_CORE_API_ Bin1DKVector {
     Bin1DKVector() : m_q_lower(), m_q_upper() {}
-    Bin1DKVector(const kvector_t lower, const kvector_t upper)
-        : m_q_lower(lower), m_q_upper(upper) {}
+    Bin1DKVector(const kvector_t lower, const kvector_t upper) : m_q_lower(lower), m_q_upper(upper)
+    {
+    }
     Bin1DKVector(double wavelength, const Bin1D& alpha_bin, const Bin1D& phi_bin);
 
-    kvector_t getMidPoint() const { return (m_q_lower + m_q_upper)/2.0; }
+    kvector_t getMidPoint() const { return (m_q_lower + m_q_upper) / 2.0; }
     kvector_t getDelta() const { return m_q_upper - m_q_lower; }
-    kvector_t m_q_lower;  //!< lower bound of the bin
-    kvector_t m_q_upper;  //!< upper bound of the bin
+    kvector_t m_q_lower; //!< lower bound of the bin
+    kvector_t m_q_upper; //!< upper bound of the bin
 };
 
 //! An one-dimensional range of cvector_t's.
@@ -54,13 +53,12 @@ class BA_CORE_API_ Bin1DCVector
 {
 public:
     Bin1DCVector() : m_q_lower(), m_q_upper() {}
-    Bin1DCVector(cvector_t lower, cvector_t upper)
-        : m_q_lower(lower), m_q_upper(upper) {}
+    Bin1DCVector(cvector_t lower, cvector_t upper) : m_q_lower(lower), m_q_upper(upper) {}
     Bin1DCVector(double wavelength, const Bin1D& alpha_bin, const Bin1D& phi_bin);
-    cvector_t getMidPoint() const { return (m_q_lower + m_q_upper)/2.0; }
+    cvector_t getMidPoint() const { return (m_q_lower + m_q_upper) / 2.0; }
     cvector_t getDelta() const { return m_q_upper - m_q_lower; }
-    cvector_t m_q_lower;  //!< lower bound of the bin
-    cvector_t m_q_upper;  //!< upper bound of the bin
+    cvector_t m_q_lower; //!< lower bound of the bin
+    cvector_t m_q_upper; //!< upper bound of the bin
 };
 
 #endif // BIN_H
diff --git a/Core/Binning/ConstKBinAxis.cpp b/Core/Binning/ConstKBinAxis.cpp
index 567ad82beac..6d14e27865d 100644
--- a/Core/Binning/ConstKBinAxis.cpp
+++ b/Core/Binning/ConstKBinAxis.cpp
@@ -17,30 +17,26 @@
 #include "Numeric.h"
 #include <iomanip>
 
-ConstKBinAxis::ConstKBinAxis(const std::string &name, size_t nbins)
-    : VariableBinAxis(name, nbins)
-    , m_start(0)
-    , m_end(0)
+ConstKBinAxis::ConstKBinAxis(const std::string& name, size_t nbins)
+    : VariableBinAxis(name, nbins), m_start(0), m_end(0)
 {
 }
 
-ConstKBinAxis::ConstKBinAxis(const std::string &name, size_t nbins, double start, double end)
-    : VariableBinAxis(name, nbins)
-    , m_start(start)
-    , m_end(end)
+ConstKBinAxis::ConstKBinAxis(const std::string& name, size_t nbins, double start, double end)
+    : VariableBinAxis(name, nbins), m_start(start), m_end(end)
 {
-    if(m_start >= m_end)
+    if (m_start >= m_end)
         throw Exceptions::LogicErrorException(
             "ConstKBinAxis::ConstKBinAxis() -> Error. start >= end is not allowed.");
 
     double start_sin = std::sin(m_start);
     double end_sin = std::sin(m_end);
-    double step = (end_sin-start_sin)/(m_nbins);
+    double step = (end_sin - start_sin) / (m_nbins);
 
     std::vector<double> bin_boundaries;
     bin_boundaries.resize(m_nbins + 1, 0.0);
-    for(size_t i=0; i<bin_boundaries.size(); ++i) {
-        bin_boundaries[i] = std::asin(start_sin + step*i);
+    for (size_t i = 0; i < bin_boundaries.size(); ++i) {
+        bin_boundaries[i] = std::asin(start_sin + step * i);
     }
     setBinBoundaries(bin_boundaries);
 }
@@ -52,20 +48,22 @@ ConstKBinAxis* ConstKBinAxis::clone() const
 
 ConstKBinAxis* ConstKBinAxis::createClippedAxis(double left, double right) const
 {
-    if(left >= right)
+    if (left >= right)
         throw Exceptions::LogicErrorException(
             "ConstKBinAxis::createClippedAxis() -> Error. 'left'' should be smaller than 'right'");
 
-    if(left < getMin()) left = getBin(0).getMidPoint();
-    if(right >= getMax()) right = getBin(size()-1).getMidPoint();
+    if (left < getMin())
+        left = getBin(0).getMidPoint();
+    if (right >= getMax())
+        right = getBin(size() - 1).getMidPoint();
 
     size_t nbin1 = findClosestIndex(left);
     size_t nbin2 = findClosestIndex(right);
 
-    size_t new_nbins = nbin2-nbin1+1;
+    size_t new_nbins = nbin2 - nbin1 + 1;
     std::vector<double> new_boundaries;
     std::vector<double> old_boundaries = getBinBoundaries();
-    for(size_t i=0; i<new_nbins+1; ++i) {
+    for (size_t i = 0; i < new_nbins + 1; ++i) {
         new_boundaries.push_back(old_boundaries[nbin1 + i]);
     }
 
@@ -78,11 +76,15 @@ ConstKBinAxis* ConstKBinAxis::createClippedAxis(double left, double right) const
 
 bool ConstKBinAxis::equals(const IAxis& other) const
 {
-    if (!IAxis::equals(other)) return false;
+    if (!IAxis::equals(other))
+        return false;
     if (const ConstKBinAxis* otherAxis = dynamic_cast<const ConstKBinAxis*>(&other)) {
-        if (size() != otherAxis->size()) return false;
-        if ( !Numeric::AreAlmostEqual(m_start, otherAxis->m_start)) return false;
-        if ( !Numeric::AreAlmostEqual(m_end, otherAxis->m_end)) return false;
+        if (size() != otherAxis->size())
+            return false;
+        if (!Numeric::AreAlmostEqual(m_start, otherAxis->m_start))
+            return false;
+        if (!Numeric::AreAlmostEqual(m_end, otherAxis->m_end))
+            return false;
         return true;
     }
     return false;
@@ -91,6 +93,6 @@ bool ConstKBinAxis::equals(const IAxis& other) const
 void ConstKBinAxis::print(std::ostream& ostr) const
 {
     ostr << "ConstKBinAxis(\"" << getName() << "\", " << size() << ", "
-         << std::setprecision(std::numeric_limits<double>::digits10+2)
-         << m_start << ", " << m_end << ")";
+         << std::setprecision(std::numeric_limits<double>::digits10 + 2) << m_start << ", " << m_end
+         << ")";
 }
diff --git a/Core/Binning/CustomBinAxis.cpp b/Core/Binning/CustomBinAxis.cpp
index 4796e3641c2..4cff923d98f 100644
--- a/Core/Binning/CustomBinAxis.cpp
+++ b/Core/Binning/CustomBinAxis.cpp
@@ -18,41 +18,38 @@
 #include <iomanip>
 #include <limits>
 
-CustomBinAxis::CustomBinAxis(const std::string &name, size_t nbins, double start, double end)
-    : VariableBinAxis(name, nbins)
-    , m_start(start)
-    , m_end(end)
+CustomBinAxis::CustomBinAxis(const std::string& name, size_t nbins, double start, double end)
+    : VariableBinAxis(name, nbins), m_start(start), m_end(end)
 {
-    if(m_start >= m_end)
+    if (m_start >= m_end)
         throw Exceptions::LogicErrorException("CustomBinAxis::CustomBinAxis() -> Error."
                                               " start >= end is not allowed.");
 
     double start_sin = std::sin(start);
     double end_sin = std::sin(end);
-    double step = (end_sin - start_sin)/(m_nbins-1);  // m_nbins-1 is intentionally
+    double step = (end_sin - start_sin) / (m_nbins - 1); // m_nbins-1 is intentionally
 
     m_bin_centers.resize(m_nbins, 0.0);
-    for(size_t i=0; i<m_bin_centers.size(); ++i) {
-        m_bin_centers[i] = std::asin(start_sin + i*step);
+    for (size_t i = 0; i < m_bin_centers.size(); ++i) {
+        m_bin_centers[i] = std::asin(start_sin + i * step);
     }
 
     std::vector<double> bin_boundaries;
     bin_boundaries.resize(m_nbins + 1, 0.0);
-    for(size_t i=0; i<bin_boundaries.size(); ++i) {
-        bin_boundaries[i] = std::asin(start_sin -step/2. + step*i);
+    for (size_t i = 0; i < bin_boundaries.size(); ++i) {
+        bin_boundaries[i] = std::asin(start_sin - step / 2. + step * i);
     }
     setBinBoundaries(bin_boundaries);
 }
 
-
-CustomBinAxis *CustomBinAxis::clone() const
+CustomBinAxis* CustomBinAxis::clone() const
 {
     return new CustomBinAxis(getName(), m_nbins, m_start, m_end);
 }
 
 Bin1D CustomBinAxis::getBin(size_t index) const
 {
-    if(index >= m_nbins)
+    if (index >= m_nbins)
         throw Exceptions::OutOfBoundsException("CustomBinAxis::getBin() -> Error. Wrong index.");
 
     Bin1D result(m_bin_centers[index], m_bin_centers[index]);
@@ -64,28 +61,30 @@ std::vector<double> CustomBinAxis::getBinCenters() const
     return m_bin_centers;
 }
 
-CustomBinAxis *CustomBinAxis::createClippedAxis(double /* left */, double /* right */) const
+CustomBinAxis* CustomBinAxis::createClippedAxis(double /* left */, double /* right */) const
 {
     throw Exceptions::NotImplementedException("VariableBinAxis::CustomBinAxis() -> Error."
                                               " Not implemented.");
 }
 
-
-void CustomBinAxis::print(std::ostream &ostr) const
+void CustomBinAxis::print(std::ostream& ostr) const
 {
     ostr << "CustomBinAxis(\"" << getName() << "\", " << size() << ", "
-         << std::setprecision(std::numeric_limits<double>::digits10+2)
-         << m_start << ", " << m_end << ")";
+         << std::setprecision(std::numeric_limits<double>::digits10 + 2) << m_start << ", " << m_end
+         << ")";
 }
 
-
-bool CustomBinAxis::equals(const IAxis &other) const
+bool CustomBinAxis::equals(const IAxis& other) const
 {
-    if (!IAxis::equals(other)) return false;
-    if (const CustomBinAxis *otherAxis = dynamic_cast<const CustomBinAxis *>(&other)) {
-        if (size() != otherAxis->size()) return false;
-        if ( !Numeric::AreAlmostEqual(m_start, otherAxis->m_start)) return false;
-        if ( !Numeric::AreAlmostEqual(m_end, otherAxis->m_end)) return false;
+    if (!IAxis::equals(other))
+        return false;
+    if (const CustomBinAxis* otherAxis = dynamic_cast<const CustomBinAxis*>(&other)) {
+        if (size() != otherAxis->size())
+            return false;
+        if (!Numeric::AreAlmostEqual(m_start, otherAxis->m_start))
+            return false;
+        if (!Numeric::AreAlmostEqual(m_end, otherAxis->m_end))
+            return false;
         return true;
     }
     return false;
diff --git a/Core/Binning/CustomBinAxis.h b/Core/Binning/CustomBinAxis.h
index b5b8137091e..61e4f1a0ee9 100644
--- a/Core/Binning/CustomBinAxis.h
+++ b/Core/Binning/CustomBinAxis.h
@@ -36,7 +36,7 @@ public:
 
     Bin1D getBin(size_t index) const;
 
-    std::vector<double > getBinCenters() const;
+    std::vector<double> getBinCenters() const;
 
     CustomBinAxis* createClippedAxis(double left, double right) const;
 
diff --git a/Core/Binning/FixedBinAxis.cpp b/Core/Binning/FixedBinAxis.cpp
index 40cb1180ba2..cbef2c1a0ee 100644
--- a/Core/Binning/FixedBinAxis.cpp
+++ b/Core/Binning/FixedBinAxis.cpp
@@ -18,53 +18,53 @@
 #include <iomanip>
 #include <limits>
 
-FixedBinAxis::FixedBinAxis(const std::string &name, size_t nbins, double start, double end)
+FixedBinAxis::FixedBinAxis(const std::string& name, size_t nbins, double start, double end)
     : IAxis(name), m_nbins(nbins), m_start(start), m_end(end)
 {
 }
 
-FixedBinAxis *FixedBinAxis::clone() const
+FixedBinAxis* FixedBinAxis::clone() const
 {
-    FixedBinAxis *result = new FixedBinAxis(getName(), m_nbins, m_start, m_end);
+    FixedBinAxis* result = new FixedBinAxis(getName(), m_nbins, m_start, m_end);
     return result;
 }
 
 double FixedBinAxis::operator[](size_t index) const
 {
-    if(index >= m_nbins)
+    if (index >= m_nbins)
         throw Exceptions::OutOfBoundsException("FixedBinAxis::operator[] -> Error. Wrong index.");
 
-    double step = (m_end - m_start)/m_nbins;
-    return m_start + (index + 0.5)*step;
+    double step = (m_end - m_start) / m_nbins;
+    return m_start + (index + 0.5) * step;
 }
 
 Bin1D FixedBinAxis::getBin(size_t index) const
 {
-    if(index >= m_nbins)
+    if (index >= m_nbins)
         throw Exceptions::OutOfBoundsException("FixedBinAxis::getBin() -> Error. Wrong index.");
 
-    double step = (m_end - m_start)/m_nbins;
-    Bin1D result( m_start + step*index, m_start + step*(index+1) );
+    double step = (m_end - m_start) / m_nbins;
+    Bin1D result(m_start + step * index, m_start + step * (index + 1));
     return result;
 }
 
 size_t FixedBinAxis::findClosestIndex(double value) const
 {
-    if( value < getMin()) {
+    if (value < getMin()) {
         return 0;
-    } else if(value >= getMax()) {
-        return m_nbins-1;
+    } else if (value >= getMax()) {
+        return m_nbins - 1;
     }
 
-    double step = (m_end - m_start)/m_nbins;
-    return int( (value-m_start)/step);
+    double step = (m_end - m_start) / m_nbins;
+    return int((value - m_start) / step);
 }
 
 std::vector<double> FixedBinAxis::getBinCenters() const
 {
     std::vector<double> result;
     result.resize(size(), 0.0);
-    for(size_t i=0; i<size(); ++i) {
+    for (size_t i = 0; i < size(); ++i) {
         result[i] = getBin(i).getMidPoint();
     }
     return result;
@@ -73,44 +73,50 @@ std::vector<double> FixedBinAxis::getBinCenters() const
 std::vector<double> FixedBinAxis::getBinBoundaries() const
 {
     std::vector<double> result;
-    result.resize(size()+1, 0.0);
-    for(size_t i=0; i<size(); ++i) {
+    result.resize(size() + 1, 0.0);
+    for (size_t i = 0; i < size(); ++i) {
         result[i] = getBin(i).m_lower;
     }
-    result[size()] = getBin(size()-1).m_upper;
+    result[size()] = getBin(size() - 1).m_upper;
     return result;
 }
 
-FixedBinAxis *FixedBinAxis::createClippedAxis(double left, double right) const
+FixedBinAxis* FixedBinAxis::createClippedAxis(double left, double right) const
 {
-    if(left >= right)
+    if (left >= right)
         throw Exceptions::LogicErrorException("FixedBinAxis::createClippedAxis() -> Error. "
-                                  "'left' should be smaller than 'right'");
+                                              "'left' should be smaller than 'right'");
 
-    if(left < getMin()) left = getBin(0).getMidPoint();
-    if(right >= getMax()) right = getBin(size()-1).getMidPoint();
+    if (left < getMin())
+        left = getBin(0).getMidPoint();
+    if (right >= getMax())
+        right = getBin(size() - 1).getMidPoint();
 
     size_t nbin1 = findClosestIndex(left);
     size_t nbin2 = findClosestIndex(right);
 
-    return new FixedBinAxis(
-        getName(), nbin2-nbin1+1, getBin(nbin1).m_lower, getBin(nbin2).m_upper );
+    return new FixedBinAxis(getName(), nbin2 - nbin1 + 1, getBin(nbin1).m_lower,
+                            getBin(nbin2).m_upper);
 }
 
 void FixedBinAxis::print(std::ostream& ostr) const
 {
     ostr << "FixedBinAxis(\"" << getName() << "\", " << size() << ", "
-         << std::setprecision(std::numeric_limits<double>::digits10+2) << getMin() << ", "
+         << std::setprecision(std::numeric_limits<double>::digits10 + 2) << getMin() << ", "
          << getMax() << ")";
 }
 
 bool FixedBinAxis::equals(const IAxis& other) const
 {
-    if (!IAxis::equals(other)) return false;
-    if (const FixedBinAxis *otherAxis = dynamic_cast<const FixedBinAxis *>(&other)) {
-        if (size() != otherAxis->size()) return false;
-        if ( !Numeric::AreAlmostEqual(m_start, otherAxis->m_start)) return false;
-        if ( !Numeric::AreAlmostEqual(m_end, otherAxis->m_end)) return false;
+    if (!IAxis::equals(other))
+        return false;
+    if (const FixedBinAxis* otherAxis = dynamic_cast<const FixedBinAxis*>(&other)) {
+        if (size() != otherAxis->size())
+            return false;
+        if (!Numeric::AreAlmostEqual(m_start, otherAxis->m_start))
+            return false;
+        if (!Numeric::AreAlmostEqual(m_end, otherAxis->m_end))
+            return false;
         return true;
     }
     return false;
diff --git a/Core/Binning/FixedBinAxis.h b/Core/Binning/FixedBinAxis.h
index 7495a154ff6..e91a1b858b4 100644
--- a/Core/Binning/FixedBinAxis.h
+++ b/Core/Binning/FixedBinAxis.h
@@ -28,10 +28,10 @@ public:
     //! @param nbins number of bins
     //! @param start low edge of first bin
     //! @param end upper edge of last bin
-    FixedBinAxis(const std::string &name, size_t nbins, double start, double end);
+    FixedBinAxis(const std::string& name, size_t nbins, double start, double end);
     virtual ~FixedBinAxis() {}
 
-    FixedBinAxis *clone() const;
+    FixedBinAxis* clone() const;
 
     size_t size() const { return m_nbins; }
 
@@ -46,11 +46,11 @@ public:
 
     size_t findClosestIndex(double value) const;
 
-    std::vector<double > getBinCenters() const;
+    std::vector<double> getBinCenters() const;
 
-    std::vector<double > getBinBoundaries() const;
+    std::vector<double> getBinBoundaries() const;
 
-    FixedBinAxis *createClippedAxis(double left, double right) const;
+    FixedBinAxis* createClippedAxis(double left, double right) const;
 
 protected:
     void print(std::ostream& ostr) const;
diff --git a/Core/Binning/IAxis.cpp b/Core/Binning/IAxis.cpp
index 2d10f048f40..bfb17c58d05 100644
--- a/Core/Binning/IAxis.cpp
+++ b/Core/Binning/IAxis.cpp
@@ -17,7 +17,7 @@
 
 bool IAxis::equals(const IAxis& other) const
 {
-    return getName()==other.getName();
+    return getName() == other.getName();
 }
 
 std::vector<double> IAxis::getBinCenters() const
diff --git a/Core/Binning/IAxis.h b/Core/Binning/IAxis.h
index e9a48906b67..552280fcdb3 100644
--- a/Core/Binning/IAxis.h
+++ b/Core/Binning/IAxis.h
@@ -28,13 +28,13 @@ public:
     IAxis(const std::string& name) : m_name(name) {}
 
     //! clone function
-    virtual IAxis* clone() const=0;
+    virtual IAxis* clone() const = 0;
 
     //! destructor
     virtual ~IAxis() {}
 
     //! retrieve the number of bins
-    virtual size_t size() const=0;
+    virtual size_t size() const = 0;
 
     //! retrieve the label of the axis
     std::string getName() const { return m_name; }
@@ -43,28 +43,31 @@ public:
     void setName(std::string name) { m_name = name; }
 
     //! indexed accessor retrieves a sample
-    virtual double operator[](size_t index) const=0;
+    virtual double operator[](size_t index) const = 0;
 
     //! retrieve a 1d bin for the given index
-    virtual Bin1D getBin(size_t index) const=0;
+    virtual Bin1D getBin(size_t index) const = 0;
 
     //! Returns value of first point of axis
-    virtual double getMin() const=0;
+    virtual double getMin() const = 0;
 
     //! Returns value of last point of axis
-    virtual double getMax() const=0;
+    virtual double getMax() const = 0;
 
-    virtual double getBinCenter(size_t index) const=0;
+    virtual double getBinCenter(size_t index) const = 0;
 
     //! find bin index which is best match for given value
-    virtual size_t findClosestIndex(double value) const=0;
+    virtual size_t findClosestIndex(double value) const = 0;
 
     //! test for equality
     bool operator==(const IAxis& right) const { return equals(right); }
-    bool operator!=(const IAxis& right) const { return !(*this==right); }
+    bool operator!=(const IAxis& right) const { return !(*this == right); }
 
-    friend std::ostream& operator<<(std::ostream& ostr, const IAxis& m) {
-        m.print(ostr); return ostr; }
+    friend std::ostream& operator<<(std::ostream& ostr, const IAxis& m)
+    {
+        m.print(ostr);
+        return ostr;
+    }
 
     virtual std::vector<double> getBinCenters() const;
 
@@ -77,14 +80,14 @@ public:
     virtual bool contains(double value) const;
 
 protected:
-    virtual void print(std::ostream& ostr) const=0;
+    virtual void print(std::ostream& ostr) const = 0;
     virtual bool equals(const IAxis& other) const; // overloaded in child classes
 
 private:
     IAxis(const IAxis&);
     IAxis& operator=(const IAxis&);
 
-    std::string m_name;  //!< axis name
+    std::string m_name; //!< axis name
 };
 
 //! global helper function for comparison of axes
diff --git a/Core/Binning/IPixel.h b/Core/Binning/IPixel.h
index 1b49d92a779..f8ac970ff52 100644
--- a/Core/Binning/IPixel.h
+++ b/Core/Binning/IPixel.h
@@ -15,8 +15,8 @@
 #ifndef IPIXEL_H
 #define IPIXEL_H
 
-#include "WinDllMacros.h"
 #include "Vectors3D.h"
+#include "WinDllMacros.h"
 
 //! Interface for a function that maps [0,1]x[0,1] to the kvectors in a pixel.
 //! @ingroup simulation
@@ -26,11 +26,11 @@ class BA_CORE_API_ IPixel
 public:
     virtual ~IPixel() {}
 
-    virtual IPixel* clone() const=0;
-    virtual IPixel* createZeroSizePixel(double x, double y) const=0;
-    virtual kvector_t getK(double x, double y, double wavelength) const=0;
-    virtual double getIntegrationFactor(double x, double y) const=0;
-    virtual double getSolidAngle() const=0;
+    virtual IPixel* clone() const = 0;
+    virtual IPixel* createZeroSizePixel(double x, double y) const = 0;
+    virtual kvector_t getK(double x, double y, double wavelength) const = 0;
+    virtual double getIntegrationFactor(double x, double y) const = 0;
+    virtual double getSolidAngle() const = 0;
 };
 
 #endif // IPIXEL_H
diff --git a/Core/Binning/PointwiseAxis.cpp b/Core/Binning/PointwiseAxis.cpp
index 4fd3e2f5dc4..3d6fa61f250 100644
--- a/Core/Binning/PointwiseAxis.cpp
+++ b/Core/Binning/PointwiseAxis.cpp
@@ -37,7 +37,7 @@ double PointwiseAxis::getMin() const
 
 double PointwiseAxis::getMax() const
 {
-    return upperBoundary(m_coordinates.size()-1);
+    return upperBoundary(m_coordinates.size() - 1);
 }
 
 double PointwiseAxis::getBinCenter(size_t index) const
@@ -48,10 +48,10 @@ double PointwiseAxis::getBinCenter(size_t index) const
 
 size_t PointwiseAxis::findClosestIndex(double value) const
 {
-    if( value <= m_coordinates.front())
+    if (value <= m_coordinates.front())
         return 0;
-    if(value >= m_coordinates.back())
-        return m_coordinates.size()-1;
+    if (value >= m_coordinates.back())
+        return m_coordinates.size() - 1;
 
     const auto begin = m_coordinates.begin();
     auto result = std::lower_bound(begin, m_coordinates.end(), value);
@@ -66,7 +66,7 @@ std::vector<double> PointwiseAxis::getBinBoundaries() const
     result.reserve(v_size + 1);
     for (size_t i = 0; i < v_size; ++i)
         result.push_back(lowerBoundary(i));
-    result.push_back(upperBoundary(v_size-1));
+    result.push_back(upperBoundary(v_size - 1));
     return result;
 }
 
@@ -86,7 +86,8 @@ PointwiseAxis* PointwiseAxis::createClippedAxis(double left, double right) const
 void PointwiseAxis::print(std::ostream& ostr) const
 {
     auto precision = std::setprecision(std::numeric_limits<double>::digits10 + 2);
-    ostr << "PointwiseAxis(\"" << getName() << "\", " << ", [";
+    ostr << "PointwiseAxis(\"" << getName() << "\", "
+         << ", [";
     for (size_t i = 0, fin = m_coordinates.size() - 1; i < fin; ++i)
         ostr << precision << m_coordinates[i] << ",";
     ostr << precision << m_coordinates.back() << "])";
diff --git a/Core/Binning/PointwiseAxis.h b/Core/Binning/PointwiseAxis.h
index 63725822fd2..96d8bf5f5d2 100644
--- a/Core/Binning/PointwiseAxis.h
+++ b/Core/Binning/PointwiseAxis.h
@@ -32,10 +32,9 @@
 class BA_CORE_API_ PointwiseAxis : public IAxis
 {
 public:
-    template<class String, class Vector>
+    template <class String, class Vector>
     PointwiseAxis(String&& name, Vector&& coordinate_values)
-        : IAxis(std::forward<String>(name))
-        , m_coordinates(std::forward<Vector>(coordinate_values))
+        : IAxis(std::forward<String>(name)), m_coordinates(std::forward<Vector>(coordinate_values))
     {
         sanityCheck();
     }
@@ -46,10 +45,10 @@ public:
     ~PointwiseAxis() override = default;
 
     //! retrieve the number of bins
-    size_t size() const override {return m_coordinates.size();}
+    size_t size() const override { return m_coordinates.size(); }
 
     //! indexed accessor retrieves a sample
-    double operator[](size_t index) const override {return getBinCenter(index);}
+    double operator[](size_t index) const override { return getBinCenter(index); }
 
     //! retrieve a 1d bin for the given index
     Bin1D getBin(size_t index) const override;
@@ -67,7 +66,7 @@ public:
     //! find index of the coordinate closest to the given value
     size_t findClosestIndex(double value) const override;
 
-    std::vector<double> getBinCenters() const override {return m_coordinates;}
+    std::vector<double> getBinCenters() const override { return m_coordinates; }
 
     std::vector<double> getBinBoundaries() const override;
 
diff --git a/Core/Binning/VariableBinAxis.cpp b/Core/Binning/VariableBinAxis.cpp
index 8aea98e4f90..efebcdae3f4 100644
--- a/Core/Binning/VariableBinAxis.cpp
+++ b/Core/Binning/VariableBinAxis.cpp
@@ -18,55 +18,48 @@
 #include <algorithm>
 #include <iomanip>
 
-VariableBinAxis::VariableBinAxis(
-    const std::string &name, size_t nbins, const std::vector<double> &bin_boundaries)
-    : IAxis(name)
-    , m_nbins(nbins)
+VariableBinAxis::VariableBinAxis(const std::string& name, size_t nbins,
+                                 const std::vector<double>& bin_boundaries)
+    : IAxis(name), m_nbins(nbins)
 {
-    if(m_nbins != bin_boundaries.size()-1)
-        throw Exceptions::LogicErrorException("VariableBinAxis::VariableBinAxis() -> Error! "
+    if (m_nbins != bin_boundaries.size() - 1)
+        throw Exceptions::LogicErrorException(
+            "VariableBinAxis::VariableBinAxis() -> Error! "
             "The size of bin_boundaries should be of size [nbins+1].");
 
     setBinBoundaries(bin_boundaries);
 }
 
-
-VariableBinAxis::VariableBinAxis(const std::string &name, size_t nbins)
-    : IAxis(name)
-    , m_nbins(nbins)
+VariableBinAxis::VariableBinAxis(const std::string& name, size_t nbins)
+    : IAxis(name), m_nbins(nbins)
 {
 }
 
-
 VariableBinAxis* VariableBinAxis::clone() const
 {
     VariableBinAxis* result = new VariableBinAxis(getName(), m_nbins, m_bin_boundaries);
     return result;
 }
 
-
 double VariableBinAxis::operator[](size_t index) const
 {
     return getBin(index).getMidPoint();
 }
 
-
 Bin1D VariableBinAxis::getBin(size_t index) const
 {
-    if(index >= m_nbins)
+    if (index >= m_nbins)
         throw Exceptions::OutOfBoundsException("VariableBinAxis::getBin() -> Error. Wrong index.");
 
-    Bin1D result(m_bin_boundaries[index], m_bin_boundaries[index+1]);
+    Bin1D result(m_bin_boundaries[index], m_bin_boundaries[index + 1]);
     return result;
 }
 
-
 double VariableBinAxis::getMin() const
 {
     return m_bin_boundaries.front();
 }
 
-
 double VariableBinAxis::getMax() const
 {
     return m_bin_boundaries.back();
@@ -77,22 +70,22 @@ double VariableBinAxis::getBinCenter(size_t index) const
     return getBin(index).getMidPoint();
 }
 
-
 size_t VariableBinAxis::findClosestIndex(double value) const
 {
-    if(m_bin_boundaries.size()<2)
+    if (m_bin_boundaries.size() < 2)
         throw Exceptions::ClassInitializationException(
             "VariableBinAxis::findClosestIndex() -> Error! "
-            "VariableBinAxis not  correctly initialized" );
-    if( value < getMin()) {
+            "VariableBinAxis not  correctly initialized");
+    if (value < getMin()) {
         return 0;
-    } else if(value >= getMax()) {
-        return m_nbins-1;
+    } else if (value >= getMax()) {
+        return m_nbins - 1;
     }
 
     std::vector<double>::const_iterator top_limit =
         std::lower_bound(m_bin_boundaries.begin(), m_bin_boundaries.end(), value);
-    if( *top_limit != value ) --top_limit;
+    if (*top_limit != value)
+        --top_limit;
     size_t nbin = top_limit - m_bin_boundaries.begin();
     return nbin;
 }
@@ -101,7 +94,7 @@ std::vector<double> VariableBinAxis::getBinCenters() const
 {
     std::vector<double> result;
     result.resize(size(), 0.0);
-    for(size_t i=0; i<size(); ++i) {
+    for (size_t i = 0; i < size(); ++i) {
         result[i] = getBin(i).getMidPoint();
     }
     return result;
@@ -110,44 +103,47 @@ std::vector<double> VariableBinAxis::getBinCenters() const
 VariableBinAxis* VariableBinAxis::createClippedAxis(double left, double right) const
 {
 
-    if(left >= right)
+    if (left >= right)
         throw Exceptions::LogicErrorException("VariableBinAxis::createClippedAxis() -> Error. "
-                                  "'left'' should be smaller than 'right'" );
+                                              "'left'' should be smaller than 'right'");
 
-    if(left < getMin()) left = getBin(0).getMidPoint();
-    if(right >= getMax()) right = getBin(size()-1).getMidPoint();
+    if (left < getMin())
+        left = getBin(0).getMidPoint();
+    if (right >= getMax())
+        right = getBin(size() - 1).getMidPoint();
 
     size_t nbin1 = findClosestIndex(left);
     size_t nbin2 = findClosestIndex(right);
 
-    size_t new_nbins = nbin2-nbin1+1;
+    size_t new_nbins = nbin2 - nbin1 + 1;
     std::vector<double> new_boundaries;
-    for(size_t i=0; i<new_nbins+1; ++i) {
+    for (size_t i = 0; i < new_nbins + 1; ++i) {
         new_boundaries.push_back(m_bin_boundaries[nbin1 + i]);
     }
 
     return new VariableBinAxis(getName(), new_nbins, new_boundaries);
 }
 
-
 void VariableBinAxis::print(std::ostream& ostr) const
 {
     ostr << "VariableBinAxis(\"" << getName() << "\", " << size() << ", [";
-    for(size_t i=0; i<m_bin_boundaries.size(); ++i) {
-        ostr << std::setprecision(std::numeric_limits<double>::digits10+2) << m_bin_boundaries[i];
-        if(i!=m_bin_boundaries.size()-1) ostr << ", ";
+    for (size_t i = 0; i < m_bin_boundaries.size(); ++i) {
+        ostr << std::setprecision(std::numeric_limits<double>::digits10 + 2) << m_bin_boundaries[i];
+        if (i != m_bin_boundaries.size() - 1)
+            ostr << ", ";
     }
     ostr << "])";
 }
 
-
 bool VariableBinAxis::equals(const IAxis& other) const
 {
-    if (!IAxis::equals(other)) return false;
+    if (!IAxis::equals(other))
+        return false;
     if (const VariableBinAxis* p_other_cast = dynamic_cast<const VariableBinAxis*>(&other)) {
-        if (size() != p_other_cast->size()) return false;
-        for(size_t i=0; i<m_bin_boundaries.size(); ++i) {
-            if( !Numeric::AreAlmostEqual(m_bin_boundaries[i], p_other_cast->m_bin_boundaries[i])) {
+        if (size() != p_other_cast->size())
+            return false;
+        for (size_t i = 0; i < m_bin_boundaries.size(); ++i) {
+            if (!Numeric::AreAlmostEqual(m_bin_boundaries[i], p_other_cast->m_bin_boundaries[i])) {
                 return false;
             }
         }
@@ -156,26 +152,23 @@ bool VariableBinAxis::equals(const IAxis& other) const
     return false;
 }
 
-
 void VariableBinAxis::setBinBoundaries(const std::vector<double>& bin_boundaries)
 {
     // checking that values are sorted
     std::vector<double> vec_sorted = bin_boundaries;
-    std::sort( vec_sorted.begin(), vec_sorted.end());
-    for(size_t i=0; i<bin_boundaries.size(); ++i) {
-        if(vec_sorted[i] != bin_boundaries[i])
-            throw Exceptions::LogicErrorException(
-                "VariableBinAxis::VariableBinAxis() -> Error. "
-                "Array with bin edges is not sorted." );
+    std::sort(vec_sorted.begin(), vec_sorted.end());
+    for (size_t i = 0; i < bin_boundaries.size(); ++i) {
+        if (vec_sorted[i] != bin_boundaries[i])
+            throw Exceptions::LogicErrorException("VariableBinAxis::VariableBinAxis() -> Error. "
+                                                  "Array with bin edges is not sorted.");
     }
 
     std::vector<double> vec = bin_boundaries;
-    vec.erase(std::unique(vec.begin(), vec.end()),vec.end());
+    vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
 
-    if(vec.size() != bin_boundaries.size())
-       throw Exceptions::LogicErrorException(
-           "VariableBinAxis::VariableBinAxis() -> Error. "
-           "Array with bin edges contains repeating values." );
+    if (vec.size() != bin_boundaries.size())
+        throw Exceptions::LogicErrorException("VariableBinAxis::VariableBinAxis() -> Error. "
+                                              "Array with bin edges contains repeating values.");
 
     m_bin_boundaries = bin_boundaries;
 }
diff --git a/Core/Binning/VariableBinAxis.h b/Core/Binning/VariableBinAxis.h
index bd0e192c34a..83c67b2f9e1 100644
--- a/Core/Binning/VariableBinAxis.h
+++ b/Core/Binning/VariableBinAxis.h
@@ -54,14 +54,14 @@ public:
 
 protected:
     VariableBinAxis(const std::string& name, size_t nbins = 0);
-    void setBinBoundaries(const std::vector<double> &bin_boundaries);
+    void setBinBoundaries(const std::vector<double>& bin_boundaries);
 
     virtual void print(std::ostream& ostr) const;
     virtual bool equals(const IAxis& other) const;
     size_t m_nbins;
 
 private:
-    std::vector<double> m_bin_boundaries;  //!< vector containing the bin limits
+    std::vector<double> m_bin_boundaries; //!< vector containing the bin limits
 };
 
 #endif // VARIABLEBINAXIS_H
diff --git a/Core/Computation/ComputationStatus.h b/Core/Computation/ComputationStatus.h
index 5e5016dbbb9..967d1952f9e 100644
--- a/Core/Computation/ComputationStatus.h
+++ b/Core/Computation/ComputationStatus.h
@@ -28,9 +28,9 @@ public:
     bool isCompleted() const { return m_status == COMPLETED; }
     std::string errorMessage() const { return m_error_message; }
 
-    void setRunning()   { m_status = RUNNING; }
+    void setRunning() { m_status = RUNNING; }
     void setCompleted() { m_status = COMPLETED; }
-    void setFailed()    { m_status = FAILED; }
+    void setFailed() { m_status = FAILED; }
     void setErrorMessage(const std::string& message) { m_error_message = message; }
 
 private:
diff --git a/Core/Computation/ConstantBackground.cpp b/Core/Computation/ConstantBackground.cpp
index 2e08f90a161..62bd58d8ffb 100644
--- a/Core/Computation/ConstantBackground.cpp
+++ b/Core/Computation/ConstantBackground.cpp
@@ -15,7 +15,6 @@
 #include "ConstantBackground.h"
 #include "RealParameter.h"
 
-
 ConstantBackground::ConstantBackground(double background_value)
     : m_background_value(background_value)
 {
@@ -23,7 +22,7 @@ ConstantBackground::ConstantBackground(double background_value)
     init_parameters();
 }
 
-ConstantBackground::~ConstantBackground() =default;
+ConstantBackground::~ConstantBackground() = default;
 
 ConstantBackground* ConstantBackground::clone() const
 {
diff --git a/Core/Computation/ConstantBackground.h b/Core/Computation/ConstantBackground.h
index 7e607b2bedc..d25c31eb3b8 100644
--- a/Core/Computation/ConstantBackground.h
+++ b/Core/Computation/ConstantBackground.h
@@ -33,6 +33,7 @@ public:
     void accept(INodeVisitor* visitor) const override { visitor->visit(this); }
 
     double addBackGround(double intensity) const override final;
+
 private:
     void init_parameters();
 
diff --git a/Core/Computation/DWBAComputation.h b/Core/Computation/DWBAComputation.h
index ee5245e37dd..11b009da6cd 100644
--- a/Core/Computation/DWBAComputation.h
+++ b/Core/Computation/DWBAComputation.h
@@ -15,8 +15,8 @@
 #ifndef MAINCOMPUTATION_H
 #define MAINCOMPUTATION_H
 
-#include "IComputation.h"
 #include "DWBASingleComputation.h"
+#include "IComputation.h"
 #include "SimulationOptions.h"
 
 class MultiLayer;
@@ -32,8 +32,7 @@ class DWBAComputation : public IComputation
 {
 public:
     DWBAComputation(const MultiLayer& multilayer, const SimulationOptions& options,
-                    ProgressHandler& progress,
-                    std::vector<SimulationElement>::iterator begin_it,
+                    ProgressHandler& progress, std::vector<SimulationElement>::iterator begin_it,
                     std::vector<SimulationElement>::iterator end_it);
     ~DWBAComputation() override;
 
diff --git a/Core/Computation/DWBASingleComputation.cpp b/Core/Computation/DWBASingleComputation.cpp
index 45769b32ccf..d6d3dbfb4cd 100644
--- a/Core/Computation/DWBASingleComputation.cpp
+++ b/Core/Computation/DWBASingleComputation.cpp
@@ -18,12 +18,11 @@
 #include "ParticleLayoutComputation.h"
 #include "RoughMultiLayerComputation.h"
 
+DWBASingleComputation::DWBASingleComputation() = default;
 
-DWBASingleComputation::DWBASingleComputation() =default;
+DWBASingleComputation::~DWBASingleComputation() = default;
 
-DWBASingleComputation::~DWBASingleComputation() =default;
-
-DWBASingleComputation::DWBASingleComputation(DWBASingleComputation&&) =default;
+DWBASingleComputation::DWBASingleComputation(DWBASingleComputation&&) = default;
 
 void DWBASingleComputation::setProgressHandler(ProgressHandler* p_progress)
 {
diff --git a/Core/Computation/DelayedProgressCounter.cpp b/Core/Computation/DelayedProgressCounter.cpp
index 93c5e59fa80..98c600ef10a 100644
--- a/Core/Computation/DelayedProgressCounter.cpp
+++ b/Core/Computation/DelayedProgressCounter.cpp
@@ -12,19 +12,18 @@
 //
 // ************************************************************************** //
 
-#include "ProgressHandler.h"
 #include "DelayedProgressCounter.h"
+#include "ProgressHandler.h"
 
 DelayedProgressCounter::DelayedProgressCounter(ProgressHandler* p_progress, size_t interval)
-    : mp_progress(p_progress)
-    , m_interval(interval)
-    , m_count(0)
-{}
+    : mp_progress(p_progress), m_interval(interval), m_count(0)
+{
+}
 
 void DelayedProgressCounter::stepProgress()
 {
     ++m_count;
-    if( m_count==m_interval ) {
+    if (m_count == m_interval) {
         mp_progress->incrementDone(m_interval);
         m_count = 0;
     }
diff --git a/Core/Computation/DelayedProgressCounter.h b/Core/Computation/DelayedProgressCounter.h
index bf3d7f2df36..3c68a33edfc 100644
--- a/Core/Computation/DelayedProgressCounter.h
+++ b/Core/Computation/DelayedProgressCounter.h
@@ -29,6 +29,7 @@ public:
 
     //! Increments inner counter; at regular intervals updates progress handler.
     void stepProgress();
+
 private:
     ProgressHandler* mp_progress;
     const size_t m_interval;
diff --git a/Core/Computation/DepthProbeComputation.cpp b/Core/Computation/DepthProbeComputation.cpp
index 05bd3e9b34d..7768334bf8f 100644
--- a/Core/Computation/DepthProbeComputation.cpp
+++ b/Core/Computation/DepthProbeComputation.cpp
@@ -27,9 +27,8 @@ DepthProbeComputation::DepthProbeComputation(const MultiLayer& multilayer,
                                              ProgressHandler& progress,
                                              DepthProbeElementIter begin_it,
                                              DepthProbeElementIter end_it)
-    : IComputation(multilayer, options, progress)
-    , m_begin_it(begin_it), m_end_it(end_it)
-    , m_computation_term(mP_processed_sample.get())
+    : IComputation(multilayer, options, progress), m_begin_it(begin_it), m_end_it(end_it),
+      m_computation_term(mP_processed_sample.get())
 {
 }
 
@@ -40,7 +39,7 @@ void DepthProbeComputation::runProtected()
     if (!mp_progress->alive())
         return;
     m_computation_term.setProgressHandler(mp_progress);
-    for (auto it=m_begin_it; it != m_end_it; ++it) {
+    for (auto it = m_begin_it; it != m_end_it; ++it) {
         m_computation_term.compute(*it);
     }
 }
diff --git a/Core/Computation/DepthProbeComputation.h b/Core/Computation/DepthProbeComputation.h
index 8c143b70854..baa7d02358d 100644
--- a/Core/Computation/DepthProbeComputation.h
+++ b/Core/Computation/DepthProbeComputation.h
@@ -15,9 +15,9 @@
 #ifndef DEPTHPROBECOMPUTATION_H
 #define DEPTHPROBECOMPUTATION_H
 
+#include "DepthProbeComputationTerm.h"
 #include "IComputation.h"
 #include "SimulationOptions.h"
-#include "DepthProbeComputationTerm.h"
 
 class MultiLayer;
 
@@ -30,6 +30,7 @@ class MultiLayer;
 class DepthProbeComputation : public IComputation
 {
     using DepthProbeElementIter = std::vector<DepthProbeElement>::iterator;
+
 public:
     DepthProbeComputation(const MultiLayer& multilayer, const SimulationOptions& options,
                           ProgressHandler& progress, DepthProbeElementIter begin_it,
diff --git a/Core/Computation/DepthProbeComputationTerm.cpp b/Core/Computation/DepthProbeComputationTerm.cpp
index f255f944778..8bdc40b1f60 100644
--- a/Core/Computation/DepthProbeComputationTerm.cpp
+++ b/Core/Computation/DepthProbeComputationTerm.cpp
@@ -22,9 +22,10 @@
 
 DepthProbeComputationTerm::DepthProbeComputationTerm(const ProcessedSample* p_sample)
     : mp_sample{p_sample}
-{}
+{
+}
 
-DepthProbeComputationTerm::~DepthProbeComputationTerm() =default;
+DepthProbeComputationTerm::~DepthProbeComputationTerm() = default;
 
 void DepthProbeComputationTerm::setProgressHandler(ProgressHandler* p_progress)
 {
@@ -55,8 +56,7 @@ void DepthProbeComputationTerm::compute(DepthProbeElement& elem) const
 
             // Compute intensity for z's of the layer
             size_t ip1_z = start_z_ind;
-            for (; ip1_z > 0; --ip1_z)
-            {
+            for (; ip1_z > 0; --ip1_z) {
                 const size_t i_z = ip1_z - 1;
                 if (i_layer + 1 != n_layers && z_positions[i_z] <= z_layer_bottom)
                     break;
diff --git a/Core/Computation/GISASSpecularComputation.h b/Core/Computation/GISASSpecularComputation.h
index 36ccdc42c89..942dca612d5 100644
--- a/Core/Computation/GISASSpecularComputation.h
+++ b/Core/Computation/GISASSpecularComputation.h
@@ -27,6 +27,7 @@ public:
     GISASSpecularComputation(const IFresnelMap* p_fresnel_map);
 
     void compute(SimulationElement& elem) const;
+
 private:
     const IFresnelMap* mp_fresnel_map;
 };
diff --git a/Core/Computation/IBackground.h b/Core/Computation/IBackground.h
index 3698423a11d..e3dfffc1ed5 100644
--- a/Core/Computation/IBackground.h
+++ b/Core/Computation/IBackground.h
@@ -26,7 +26,7 @@ class BA_CORE_API_ IBackground : public ICloneable, public INode
 {
 public:
     virtual ~IBackground();
-    virtual IBackground* clone() const =0;
+    virtual IBackground* clone() const = 0;
 
     virtual double addBackGround(double element) const = 0;
 };
diff --git a/Core/Computation/IComputation.cpp b/Core/Computation/IComputation.cpp
index b7ed432616c..e132c442990 100644
--- a/Core/Computation/IComputation.cpp
+++ b/Core/Computation/IComputation.cpp
@@ -20,10 +20,10 @@
 
 IComputation::IComputation(const MultiLayer& sample, const SimulationOptions& options,
                            ProgressHandler& progress)
-    : m_sim_options(options),
-      mp_progress(&progress),
+    : m_sim_options(options), mp_progress(&progress),
       mP_processed_sample(std::make_unique<ProcessedSample>(sample, options))
-{}
+{
+}
 
 IComputation::~IComputation() = default;
 
diff --git a/Core/Computation/MultiLayerUtils.cpp b/Core/Computation/MultiLayerUtils.cpp
index fa80492f21d..dc14d05302a 100644
--- a/Core/Computation/MultiLayerUtils.cpp
+++ b/Core/Computation/MultiLayerUtils.cpp
@@ -85,9 +85,8 @@ std::vector<ZLimits> MultiLayerUtils::ParticleRegions(const MultiLayer& multilay
 
 bool MultiLayerUtils::hasRoughness(const MultiLayer& sample)
 {
-    for(size_t i = 0; i < sample.numberOfLayers() - 1; i++ )
-    {
-        if( sample.layerInterface(i)->getRoughness() )
+    for (size_t i = 0; i < sample.numberOfLayers() - 1; i++) {
+        if (sample.layerInterface(i)->getRoughness())
             return true;
     }
     return false;
diff --git a/Core/Computation/ParticleLayoutComputation.cpp b/Core/Computation/ParticleLayoutComputation.cpp
index 8d42dcf3bb4..8fb12bdc7c0 100644
--- a/Core/Computation/ParticleLayoutComputation.cpp
+++ b/Core/Computation/ParticleLayoutComputation.cpp
@@ -19,7 +19,8 @@
 #include "SimulationElement.h"
 
 ParticleLayoutComputation::ParticleLayoutComputation(const ProcessedLayout* p_layout,
-                                                     const SimulationOptions& options, bool polarized)
+                                                     const SimulationOptions& options,
+                                                     bool polarized)
     : mp_layout(p_layout)
 {
     LayoutStrategyBuilder builder(p_layout, options, polarized);
@@ -28,7 +29,7 @@ ParticleLayoutComputation::ParticleLayoutComputation(const ProcessedLayout* p_la
     m_surface_density = p_layout->surfaceDensity();
 }
 
-ParticleLayoutComputation::~ParticleLayoutComputation() =default;
+ParticleLayoutComputation::~ParticleLayoutComputation() = default;
 
 void ParticleLayoutComputation::compute(SimulationElement& elem) const
 {
@@ -42,10 +43,9 @@ void ParticleLayoutComputation::compute(SimulationElement& elem) const
 }
 
 void ParticleLayoutComputation::mergeRegionMap(
-        std::map<size_t, std::vector<HomogeneousRegion>>& region_map) const
+    std::map<size_t, std::vector<HomogeneousRegion>>& region_map) const
 {
-    for (auto& entry : m_region_map)
-    {
+    for (auto& entry : m_region_map) {
         size_t i = entry.first;
         auto& regions = entry.second;
         region_map[i].insert(region_map[i].begin(), regions.begin(), regions.end());
diff --git a/Core/Computation/ParticleLayoutComputation.h b/Core/Computation/ParticleLayoutComputation.h
index 78714b62cf9..0dbc592a804 100644
--- a/Core/Computation/ParticleLayoutComputation.h
+++ b/Core/Computation/ParticleLayoutComputation.h
@@ -32,8 +32,8 @@ class SimulationOptions;
 class ParticleLayoutComputation final
 {
 public:
-    ParticleLayoutComputation(const ProcessedLayout* p_layout,
-                              const SimulationOptions& options, bool polarized);
+    ParticleLayoutComputation(const ProcessedLayout* p_layout, const SimulationOptions& options,
+                              bool polarized);
     ~ParticleLayoutComputation();
 
     void compute(SimulationElement& elem) const;
diff --git a/Core/Computation/PoissonNoiseBackground.cpp b/Core/Computation/PoissonNoiseBackground.cpp
index 89b1adf2f36..826e89ed600 100644
--- a/Core/Computation/PoissonNoiseBackground.cpp
+++ b/Core/Computation/PoissonNoiseBackground.cpp
@@ -20,9 +20,9 @@ PoissonNoiseBackground::PoissonNoiseBackground()
     setName(BornAgain::PoissonNoiseBackgroundType);
 }
 
-PoissonNoiseBackground::~PoissonNoiseBackground() =default;
+PoissonNoiseBackground::~PoissonNoiseBackground() = default;
 
-PoissonNoiseBackground*PoissonNoiseBackground::clone() const
+PoissonNoiseBackground* PoissonNoiseBackground::clone() const
 {
     return new PoissonNoiseBackground;
 }
diff --git a/Core/Computation/ProcessedLayout.h b/Core/Computation/ProcessedLayout.h
index de5fe46652f..7503aa1748e 100644
--- a/Core/Computation/ProcessedLayout.h
+++ b/Core/Computation/ProcessedLayout.h
@@ -50,7 +50,8 @@ public:
 
 private:
     void collectFormFactors(const ILayout& layout, const std::vector<Slice>& slices, double z_ref);
-    FormFactorCoherentSum ProcessParticle(const IParticle& particle, const std::vector<Slice>& slices, double z_ref);
+    FormFactorCoherentSum ProcessParticle(const IParticle& particle,
+                                          const std::vector<Slice>& slices, double z_ref);
     void mergeRegionMap(const std::map<size_t, std::vector<HomogeneousRegion>>& region_map);
     const IFresnelMap* mp_fresnel_map;
     bool m_polarized;
diff --git a/Core/Computation/ProcessedSample.cpp b/Core/Computation/ProcessedSample.cpp
index 53f224efd27..e1b9931df3a 100644
--- a/Core/Computation/ProcessedSample.cpp
+++ b/Core/Computation/ProcessedSample.cpp
@@ -213,7 +213,7 @@ void ProcessedSample::initLayouts(const MultiLayer& sample)
     m_polarized = ContainsMagneticMaterial(sample);
     for (size_t i = 0; i < sample.numberOfLayers(); ++i) {
         if (i > 1)
-            z_ref -= MultiLayerUtils::LayerThickness(sample, i-1);
+            z_ref -= MultiLayerUtils::LayerThickness(sample, i - 1);
         auto p_layer = sample.layer(i);
         for (auto p_layout : p_layer->layouts()) {
             m_layouts.emplace_back(*p_layout, m_slices, z_ref, mP_fresnel_map.get(), m_polarized);
diff --git a/Core/Computation/ProfileHelper.cpp b/Core/Computation/ProfileHelper.cpp
index c9be6ef5618..748a5f2ec8c 100644
--- a/Core/Computation/ProfileHelper.cpp
+++ b/Core/Computation/ProfileHelper.cpp
@@ -66,17 +66,14 @@ std::vector<complex_t> ProfileHelper::calculateProfile(const std::vector<double>
 std::pair<double, double> ProfileHelper::defaultLimits() const
 {
     if (m_zlimits.size() < 1)
-        return { 0.0, 0.0 };
+        return {0.0, 0.0};
     double interface_span = m_zlimits.front() - m_zlimits.back();
-    double default_margin = interface_span > 0.0 ?
-                interface_span / 20.0 : 10.0;
-    double top_margin = m_sigmas.front() > 0.0 ?
-                5.0 * m_sigmas.front() : default_margin;
-    double bottom_margin = m_sigmas.back() > 0.0 ?
-                5.0 * m_sigmas.back() : default_margin;
+    double default_margin = interface_span > 0.0 ? interface_span / 20.0 : 10.0;
+    double top_margin = m_sigmas.front() > 0.0 ? 5.0 * m_sigmas.front() : default_margin;
+    double bottom_margin = m_sigmas.back() > 0.0 ? 5.0 * m_sigmas.back() : default_margin;
     double z_min = m_zlimits.back() - bottom_margin;
     double z_max = m_zlimits.front() + top_margin;
-    return { z_min, z_max };
+    return {z_min, z_max};
 }
 
 ProfileHelper::~ProfileHelper() = default;
diff --git a/Core/Computation/ProfileHelper.h b/Core/Computation/ProfileHelper.h
index bff40b10396..6938805e033 100644
--- a/Core/Computation/ProfileHelper.h
+++ b/Core/Computation/ProfileHelper.h
@@ -38,6 +38,7 @@ public:
 
     std::vector<complex_t> calculateProfile(const std::vector<double>& z_values) const;
     std::pair<double, double> defaultLimits() const;
+
 private:
     std::vector<complex_t> m_materialdata;
     std::vector<double> m_zlimits;
diff --git a/Core/Computation/ProgressHandler.cpp b/Core/Computation/ProgressHandler.cpp
index 4430b7bd8bf..d7a972a3852 100644
--- a/Core/Computation/ProgressHandler.cpp
+++ b/Core/Computation/ProgressHandler.cpp
@@ -31,15 +31,15 @@ void ProgressHandler::subscribe(ProgressHandler::Callback_t inform)
 void ProgressHandler::incrementDone(size_t ticks_done)
 {
     static std::mutex single_mutex;
-    std::unique_lock<std::mutex> single_lock( single_mutex );
+    std::unique_lock<std::mutex> single_lock(single_mutex);
 
     m_completed_nticks += ticks_done;
     if (m_completed_nticks > m_expected_nticks)
-        m_expected_nticks = m_completed_nticks+1;
+        m_expected_nticks = m_completed_nticks + 1;
 
-    int percentage_done = (int) (100.*m_completed_nticks/m_expected_nticks);
+    int percentage_done = (int)(100. * m_completed_nticks / m_expected_nticks);
     // fractional part is discarded, which is fine here:
     // the value 100 is only returned if everything is done
 
-    m_continuation_flag = ( !m_inform || m_inform(percentage_done) ) && m_continuation_flag;
+    m_continuation_flag = (!m_inform || m_inform(percentage_done)) && m_continuation_flag;
 }
diff --git a/Core/Computation/ProgressHandler.h b/Core/Computation/ProgressHandler.h
index ca8864c1b78..91f1554dde0 100644
--- a/Core/Computation/ProgressHandler.h
+++ b/Core/Computation/ProgressHandler.h
@@ -35,13 +35,20 @@ public:
 
     ProgressHandler()
         : m_inform(nullptr), m_expected_nticks(0), m_completed_nticks(0), m_continuation_flag(true)
-    {}
+    {
+    }
     ProgressHandler(const ProgressHandler& other)
         : m_inform(other.m_inform) // not clear whether we want multiple copies of this
-        , m_expected_nticks(other.m_expected_nticks)
-        , m_completed_nticks(other.m_completed_nticks) {}
+          ,
+          m_expected_nticks(other.m_expected_nticks), m_completed_nticks(other.m_completed_nticks)
+    {
+    }
     void subscribe(ProgressHandler::Callback_t callback);
-    void reset() { m_completed_nticks = 0; m_continuation_flag = true; }
+    void reset()
+    {
+        m_completed_nticks = 0;
+        m_continuation_flag = true;
+    }
     void setExpectedNTicks(size_t n) { m_expected_nticks = n; }
     void incrementDone(size_t ticks_done);
     bool alive() { return m_continuation_flag; }
diff --git a/Core/Computation/RoughMultiLayerComputation.cpp b/Core/Computation/RoughMultiLayerComputation.cpp
index 286205fbe0c..02eadd2b3fe 100644
--- a/Core/Computation/RoughMultiLayerComputation.cpp
+++ b/Core/Computation/RoughMultiLayerComputation.cpp
@@ -13,14 +13,14 @@
 // ************************************************************************** //
 
 #include "RoughMultiLayerComputation.h"
-#include "ILayerRTCoefficients.h"
-#include "IFresnelMap.h"
 #include "Faddeeva.hh"
+#include "IFresnelMap.h"
+#include "ILayerRTCoefficients.h"
 #include "Layer.h"
 #include "LayerInterface.h"
 #include "LayerRoughness.h"
-#include "MultiLayer.h"
 #include "MathConstants.h"
+#include "MultiLayer.h"
 #include "ProcessedSample.h"
 #include "SimulationElement.h"
 #include "Slice.h"
@@ -28,24 +28,26 @@
 // Diffuse scattering from rough interfaces is modelled after
 // Phys. Rev. B, vol. 51 (4), p. 2311 (1995)
 
-namespace {
-    complex_t h_plus(complex_t z)
-    {
-        return 0.5*Faddeeva::erfcx(-mul_I(z)/std::sqrt(2.0));
-    }
-    complex_t h_min(complex_t z)
-    {
-        return 0.5*Faddeeva::erfcx(mul_I(z)/std::sqrt(2.0));
-    }
+namespace
+{
+complex_t h_plus(complex_t z)
+{
+    return 0.5 * Faddeeva::erfcx(-mul_I(z) / std::sqrt(2.0));
 }
+complex_t h_min(complex_t z)
+{
+    return 0.5 * Faddeeva::erfcx(mul_I(z) / std::sqrt(2.0));
+}
+} // namespace
 
 RoughMultiLayerComputation::RoughMultiLayerComputation(const ProcessedSample* p_sample)
     : mp_sample{p_sample}
-{}
+{
+}
 
 void RoughMultiLayerComputation::compute(SimulationElement& elem) const
 {
-    if (elem.getAlphaMean()<0.0)
+    if (elem.getAlphaMean() < 0.0)
         return;
     auto n_slices = mp_sample->numberOfSlices();
     kvector_t q = elem.getMeanQ();
@@ -53,85 +55,85 @@ void RoughMultiLayerComputation::compute(SimulationElement& elem) const
     double autocorr(0.0);
     complex_t crosscorr(0.0, 0.0);
 
-    std::vector<complex_t > rterm( n_slices-1 );
-    std::vector<complex_t > sterm( n_slices-1 );
+    std::vector<complex_t> rterm(n_slices - 1);
+    std::vector<complex_t> sterm(n_slices - 1);
 
-    for (size_t i=0; i+1<n_slices; i++){
+    for (size_t i = 0; i + 1 < n_slices; i++) {
         rterm[i] = get_refractive_term(i, wavelength);
         sterm[i] = get_sum8terms(i, elem);
     }
-    for (size_t i=0; i+1<n_slices; i++) {
-        const LayerRoughness *rough = mp_sample->bottomRoughness(i);
-        if(rough)
-            autocorr += std::norm( rterm[i] ) * std::norm( sterm[i] ) * rough->getSpectralFun(q);
+    for (size_t i = 0; i + 1 < n_slices; i++) {
+        const LayerRoughness* rough = mp_sample->bottomRoughness(i);
+        if (rough)
+            autocorr += std::norm(rterm[i]) * std::norm(sterm[i]) * rough->getSpectralFun(q);
     }
     // cross correlation between layers
     if (mp_sample->crossCorrelationLength() != 0.0) {
-        for(size_t j=0; j<n_slices-1; j++){
-            for(size_t k=0; k<n_slices-1; k++) {
-                if(j==k) continue;
-                crosscorr += rterm[j]*sterm[j]*
-                    mp_sample->crossCorrSpectralFun(q,j,k)*
-                    std::conj(rterm[k])*std::conj(sterm[k]);
+        for (size_t j = 0; j < n_slices - 1; j++) {
+            for (size_t k = 0; k < n_slices - 1; k++) {
+                if (j == k)
+                    continue;
+                crosscorr += rterm[j] * sterm[j] * mp_sample->crossCorrSpectralFun(q, j, k)
+                             * std::conj(rterm[k]) * std::conj(sterm[k]);
             }
         }
     }
     //! @TODO clarify complex vs double
-    elem.addIntensity((autocorr+crosscorr.real())*M_PI/4./wavelength/wavelength);
+    elem.addIntensity((autocorr + crosscorr.real()) * M_PI / 4. / wavelength / wavelength);
 }
 
 complex_t RoughMultiLayerComputation::get_refractive_term(size_t ilayer, double wavelength) const
 {
     auto& slices = mp_sample->slices();
-    return slices[ilayer  ].material().refractiveIndex2(wavelength) -
-           slices[ilayer+1].material().refractiveIndex2(wavelength);
+    return slices[ilayer].material().refractiveIndex2(wavelength)
+           - slices[ilayer + 1].material().refractiveIndex2(wavelength);
 }
 
-complex_t RoughMultiLayerComputation::get_sum8terms(
-    size_t ilayer, const SimulationElement& sim_element) const
+complex_t RoughMultiLayerComputation::get_sum8terms(size_t ilayer,
+                                                    const SimulationElement& sim_element) const
 {
     auto& slices = mp_sample->slices();
     auto p_fresnel_map = mp_sample->fresnelMap();
     const auto P_in_plus = p_fresnel_map->getInCoefficients(sim_element, ilayer);
     const auto P_out_plus = p_fresnel_map->getOutCoefficients(sim_element, ilayer);
 
-    const auto P_in_minus = p_fresnel_map->getInCoefficients(sim_element, ilayer+1);
-    const auto P_out_minus = p_fresnel_map->getOutCoefficients(sim_element, ilayer+1);
+    const auto P_in_minus = p_fresnel_map->getInCoefficients(sim_element, ilayer + 1);
+    const auto P_out_minus = p_fresnel_map->getOutCoefficients(sim_element, ilayer + 1);
 
     complex_t kiz_plus = P_in_plus->getScalarKz();
     complex_t kfz_plus = P_out_plus->getScalarKz();
-    complex_t qz1_plus = - kiz_plus - kfz_plus;
-    complex_t qz2_plus = - kiz_plus + kfz_plus;
-    complex_t qz3_plus = - qz2_plus;
-    complex_t qz4_plus = - qz1_plus;
+    complex_t qz1_plus = -kiz_plus - kfz_plus;
+    complex_t qz2_plus = -kiz_plus + kfz_plus;
+    complex_t qz3_plus = -qz2_plus;
+    complex_t qz4_plus = -qz1_plus;
     double thickness = slices[ilayer].thickness();
-    complex_t T_in_plus  = P_in_plus ->getScalarT()*exp_I( kiz_plus*thickness);
-    complex_t R_in_plus  = P_in_plus ->getScalarR()*exp_I(-kiz_plus*thickness);
-    complex_t T_out_plus = P_out_plus->getScalarT()*exp_I( kfz_plus*thickness);
-    complex_t R_out_plus = P_out_plus->getScalarR()*exp_I(-kfz_plus*thickness);
+    complex_t T_in_plus = P_in_plus->getScalarT() * exp_I(kiz_plus * thickness);
+    complex_t R_in_plus = P_in_plus->getScalarR() * exp_I(-kiz_plus * thickness);
+    complex_t T_out_plus = P_out_plus->getScalarT() * exp_I(kfz_plus * thickness);
+    complex_t R_out_plus = P_out_plus->getScalarR() * exp_I(-kfz_plus * thickness);
 
     complex_t kiz_minus = P_in_minus->getScalarKz();
     complex_t kfz_minus = P_out_minus->getScalarKz();
-    complex_t qz1_minus = - kiz_minus - kfz_minus;
-    complex_t qz2_minus = - kiz_minus + kfz_minus;
-    complex_t qz3_minus = - qz2_minus;
-    complex_t qz4_minus = - qz1_minus;
+    complex_t qz1_minus = -kiz_minus - kfz_minus;
+    complex_t qz2_minus = -kiz_minus + kfz_minus;
+    complex_t qz3_minus = -qz2_minus;
+    complex_t qz4_minus = -qz1_minus;
 
     double sigma(0.0);
     if (const LayerRoughness* roughness = mp_sample->bottomRoughness(ilayer))
         sigma = roughness->getSigma();
-    complex_t term1 = T_in_plus * T_out_plus * h_plus(qz1_plus*sigma);
-    complex_t term2 = T_in_plus * R_out_plus * h_plus(qz2_plus*sigma);
-    complex_t term3 = R_in_plus * T_out_plus * h_plus(qz3_plus*sigma);
-    complex_t term4 = R_in_plus * R_out_plus * h_plus(qz4_plus*sigma);
-    complex_t term5 = P_in_minus->getScalarT() * P_out_minus->getScalarT()
-                      * h_min(qz1_minus*sigma);
-    complex_t term6 = P_in_minus->getScalarT() * P_out_minus->getScalarR()
-                      * h_min(qz2_minus*sigma);
-    complex_t term7 = P_in_minus->getScalarR() * P_out_minus->getScalarT()
-                      * h_min(qz3_minus*sigma);
-    complex_t term8 = P_in_minus->getScalarR() * P_out_minus->getScalarR()
-                      * h_min(qz4_minus*sigma);
+    complex_t term1 = T_in_plus * T_out_plus * h_plus(qz1_plus * sigma);
+    complex_t term2 = T_in_plus * R_out_plus * h_plus(qz2_plus * sigma);
+    complex_t term3 = R_in_plus * T_out_plus * h_plus(qz3_plus * sigma);
+    complex_t term4 = R_in_plus * R_out_plus * h_plus(qz4_plus * sigma);
+    complex_t term5 =
+        P_in_minus->getScalarT() * P_out_minus->getScalarT() * h_min(qz1_minus * sigma);
+    complex_t term6 =
+        P_in_minus->getScalarT() * P_out_minus->getScalarR() * h_min(qz2_minus * sigma);
+    complex_t term7 =
+        P_in_minus->getScalarR() * P_out_minus->getScalarT() * h_min(qz3_minus * sigma);
+    complex_t term8 =
+        P_in_minus->getScalarR() * P_out_minus->getScalarR() * h_min(qz4_minus * sigma);
 
     return term1 + term2 + term3 + term4 + term5 + term6 + term7 + term8;
 }
diff --git a/Core/Computation/Slice.h b/Core/Computation/Slice.h
index 366c28e5df4..4e60929836e 100644
--- a/Core/Computation/Slice.h
+++ b/Core/Computation/Slice.h
@@ -56,10 +56,11 @@ public:
     void invertBField();
 
     static constexpr double Magnetic_Permeability = 4e-7 * M_PI;
+
 private:
     double m_thickness;
     Material m_material;
-    kvector_t m_B_field;                  //!< cached value of magnetic induction
+    kvector_t m_B_field; //!< cached value of magnetic induction
     std::unique_ptr<LayerRoughness> mP_top_roughness;
 };
 
diff --git a/Core/Computation/SpecularComputation.cpp b/Core/Computation/SpecularComputation.cpp
index 1ba5d46b6fb..125fedf1782 100644
--- a/Core/Computation/SpecularComputation.cpp
+++ b/Core/Computation/SpecularComputation.cpp
@@ -28,15 +28,15 @@ SpecularComputation::SpecularComputation(const MultiLayer& multilayer,
                                          const SimulationOptions& options,
                                          ProgressHandler& progress, SpecularElementIter begin_it,
                                          SpecularElementIter end_it)
-    : IComputation(multilayer, options, progress)
-    , m_begin_it(begin_it)
-    , m_end_it(end_it)
+    : IComputation(multilayer, options, progress), m_begin_it(begin_it), m_end_it(end_it)
 {
     if (mP_processed_sample->containsMagneticMaterial()
         || mP_processed_sample->externalField() != kvector_t{})
-        m_computation_term.reset(new SpecularMatrixTerm(SpecularStrategyBuilder::build(multilayer, true)));
+        m_computation_term.reset(
+            new SpecularMatrixTerm(SpecularStrategyBuilder::build(multilayer, true)));
     else
-        m_computation_term.reset(new SpecularScalarTerm(SpecularStrategyBuilder::build(multilayer, false)));
+        m_computation_term.reset(
+            new SpecularScalarTerm(SpecularStrategyBuilder::build(multilayer, false)));
 }
 
 SpecularComputation::~SpecularComputation() = default;
diff --git a/Core/DecoratedFormFactor/FormFactorDecoratorMaterial.cpp b/Core/DecoratedFormFactor/FormFactorDecoratorMaterial.cpp
index 022b354464c..effb1e23e67 100644
--- a/Core/DecoratedFormFactor/FormFactorDecoratorMaterial.cpp
+++ b/Core/DecoratedFormFactor/FormFactorDecoratorMaterial.cpp
@@ -19,20 +19,18 @@
 #include "WavevectorInfo.h"
 
 FormFactorDecoratorMaterial::FormFactorDecoratorMaterial(const IFormFactor& form_factor)
-    : IFormFactorDecorator(form_factor)
-    , m_material(HomogeneousMaterial())
-    , m_ambient_material(HomogeneousMaterial())
+    : IFormFactorDecorator(form_factor), m_material(HomogeneousMaterial()),
+      m_ambient_material(HomogeneousMaterial())
 {
     setName(BornAgain::FormFactorDecoratorMaterialType);
 }
 
-FormFactorDecoratorMaterial::~FormFactorDecoratorMaterial()
-{}
+FormFactorDecoratorMaterial::~FormFactorDecoratorMaterial() {}
 
 FormFactorDecoratorMaterial* FormFactorDecoratorMaterial::clone() const
 {
     std::unique_ptr<FormFactorDecoratorMaterial> P_result(
-                new FormFactorDecoratorMaterial(*mp_form_factor));
+        new FormFactorDecoratorMaterial(*mp_form_factor));
     P_result->setMaterial(m_material);
     P_result->setAmbientMaterial(m_ambient_material);
     return P_result.release();
@@ -50,7 +48,7 @@ void FormFactorDecoratorMaterial::setAmbientMaterial(Material material)
 
 complex_t FormFactorDecoratorMaterial::evaluate(const WavevectorInfo& wavevectors) const
 {
-    return getRefractiveIndexFactor(wavevectors)*mp_form_factor->evaluate(wavevectors);
+    return getRefractiveIndexFactor(wavevectors) * mp_form_factor->evaluate(wavevectors);
 }
 
 Eigen::Matrix2cd FormFactorDecoratorMaterial::evaluatePol(const WavevectorInfo& wavevectors) const
@@ -62,13 +60,13 @@ Eigen::Matrix2cd FormFactorDecoratorMaterial::evaluatePol(const WavevectorInfo&
     time_reverse_conj(1, 0) = -1.0;
     // the interaction and time reversal taken together:
     Eigen::Matrix2cd V_eff = time_reverse_conj
-                             * (  m_material.polarizedSubtrSLD(wavevectors)
-                                - m_ambient_material.polarizedSubtrSLD(wavevectors) );
+                             * (m_material.polarizedSubtrSLD(wavevectors)
+                                - m_ambient_material.polarizedSubtrSLD(wavevectors));
     return mp_form_factor->evaluate(wavevectors) * V_eff;
 }
 
-complex_t FormFactorDecoratorMaterial::getRefractiveIndexFactor(
-        const WavevectorInfo& wavevectors) const
+complex_t
+FormFactorDecoratorMaterial::getRefractiveIndexFactor(const WavevectorInfo& wavevectors) const
 {
     return m_material.scalarSubtrSLD(wavevectors) - m_ambient_material.scalarSubtrSLD(wavevectors);
 }
diff --git a/Core/DecoratedFormFactor/FormFactorDecoratorPositionFactor.cpp b/Core/DecoratedFormFactor/FormFactorDecoratorPositionFactor.cpp
index b402fbf9276..69b4e5f39fd 100644
--- a/Core/DecoratedFormFactor/FormFactorDecoratorPositionFactor.cpp
+++ b/Core/DecoratedFormFactor/FormFactorDecoratorPositionFactor.cpp
@@ -17,8 +17,8 @@
 #include "Rotations.h"
 #include "WavevectorInfo.h"
 
-FormFactorDecoratorPositionFactor::FormFactorDecoratorPositionFactor(
-    const IFormFactor& form_factor, const kvector_t& position)
+FormFactorDecoratorPositionFactor::FormFactorDecoratorPositionFactor(const IFormFactor& form_factor,
+                                                                     const kvector_t& position)
     : IFormFactorDecorator(form_factor), m_position(position)
 {
     setName(BornAgain::FormFactorDecoratorPositionFactorType);
@@ -38,21 +38,20 @@ double FormFactorDecoratorPositionFactor::topZ(const IRotation& rotation) const
     return mp_form_factor->topZ(rotation) + rotated_translation.z();
 }
 
-complex_t FormFactorDecoratorPositionFactor::evaluate(
-    const WavevectorInfo& wavevectors) const
+complex_t FormFactorDecoratorPositionFactor::evaluate(const WavevectorInfo& wavevectors) const
 {
     return getPositionFactor(wavevectors) * mp_form_factor->evaluate(wavevectors);
 }
 
-Eigen::Matrix2cd FormFactorDecoratorPositionFactor::evaluatePol(
-        const WavevectorInfo& wavevectors) const
+Eigen::Matrix2cd
+FormFactorDecoratorPositionFactor::evaluatePol(const WavevectorInfo& wavevectors) const
 {
     return getPositionFactor(wavevectors) * mp_form_factor->evaluatePol(wavevectors);
 }
 
-complex_t FormFactorDecoratorPositionFactor::getPositionFactor(
-    const WavevectorInfo& wavevectors) const
+complex_t
+FormFactorDecoratorPositionFactor::getPositionFactor(const WavevectorInfo& wavevectors) const
 {
     cvector_t q = wavevectors.getQ();
-    return exp_I( m_position.dot(q) );
+    return exp_I(m_position.dot(q));
 }
diff --git a/Core/DecoratedFormFactor/FormFactorDecoratorPositionFactor.h b/Core/DecoratedFormFactor/FormFactorDecoratorPositionFactor.h
index 0c4990a9aa8..3c21e45c84a 100644
--- a/Core/DecoratedFormFactor/FormFactorDecoratorPositionFactor.h
+++ b/Core/DecoratedFormFactor/FormFactorDecoratorPositionFactor.h
@@ -26,8 +26,10 @@ class BA_CORE_API_ FormFactorDecoratorPositionFactor : public IFormFactorDecorat
 public:
     FormFactorDecoratorPositionFactor(const IFormFactor& form_factor, const kvector_t& position);
 
-    FormFactorDecoratorPositionFactor* clone() const override final {
-        return new FormFactorDecoratorPositionFactor(*mp_form_factor, m_position); }
+    FormFactorDecoratorPositionFactor* clone() const override final
+    {
+        return new FormFactorDecoratorPositionFactor(*mp_form_factor, m_position);
+    }
 
     void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
diff --git a/Core/DecoratedFormFactor/FormFactorDecoratorRotation.cpp b/Core/DecoratedFormFactor/FormFactorDecoratorRotation.cpp
index 0e8b18f22eb..47492c1018d 100644
--- a/Core/DecoratedFormFactor/FormFactorDecoratorRotation.cpp
+++ b/Core/DecoratedFormFactor/FormFactorDecoratorRotation.cpp
@@ -17,8 +17,8 @@
 #include "WavevectorInfo.h"
 #include <memory>
 
-FormFactorDecoratorRotation::FormFactorDecoratorRotation(
-    const IFormFactor& form_factor, const IRotation& rotation)
+FormFactorDecoratorRotation::FormFactorDecoratorRotation(const IFormFactor& form_factor,
+                                                         const IRotation& rotation)
     : IFormFactorDecorator(form_factor)
 {
     setName(BornAgain::FormFactorDecoratorRotationType);
@@ -33,14 +33,14 @@ FormFactorDecoratorRotation* FormFactorDecoratorRotation::clone() const
 double FormFactorDecoratorRotation::bottomZ(const IRotation& rotation) const
 {
     Transform3D transform = rotation.getTransform3D();
-    std::unique_ptr<IRotation> P_total_rotation(IRotation::createRotation(transform*m_transform));
+    std::unique_ptr<IRotation> P_total_rotation(IRotation::createRotation(transform * m_transform));
     return mp_form_factor->bottomZ(*P_total_rotation);
 }
 
 double FormFactorDecoratorRotation::topZ(const IRotation& rotation) const
 {
     Transform3D transform = rotation.getTransform3D();
-    std::unique_ptr<IRotation> P_total_rotation(IRotation::createRotation(transform*m_transform));
+    std::unique_ptr<IRotation> P_total_rotation(IRotation::createRotation(transform * m_transform));
     return mp_form_factor->topZ(*P_total_rotation);
 }
 
@@ -54,10 +54,9 @@ Eigen::Matrix2cd FormFactorDecoratorRotation::evaluatePol(const WavevectorInfo&
     return mp_form_factor->evaluatePol(wavevectors.transformed(m_transform.getInverse()));
 }
 
-FormFactorDecoratorRotation::FormFactorDecoratorRotation(
-    const IFormFactor& form_factor, const Transform3D& transform)
-    : IFormFactorDecorator(form_factor)
-    , m_transform(transform)
+FormFactorDecoratorRotation::FormFactorDecoratorRotation(const IFormFactor& form_factor,
+                                                         const Transform3D& transform)
+    : IFormFactorDecorator(form_factor), m_transform(transform)
 {
     setName(BornAgain::FormFactorDecoratorRotationType);
 }
diff --git a/Core/DecoratedFormFactor/IFormFactorDecorator.h b/Core/DecoratedFormFactor/IFormFactorDecorator.h
index d74ea34d9a6..97a7261a3a8 100644
--- a/Core/DecoratedFormFactor/IFormFactorDecorator.h
+++ b/Core/DecoratedFormFactor/IFormFactorDecorator.h
@@ -30,26 +30,26 @@ class BA_CORE_API_ IFormFactorDecorator : public IFormFactor
 public:
     IFormFactorDecorator(const IFormFactor& form_factor) : mp_form_factor(form_factor.clone()) {}
     ~IFormFactorDecorator() override { delete mp_form_factor; }
-    IFormFactorDecorator* clone() const override=0;
-    void accept(INodeVisitor* visitor) const override=0;
+    IFormFactorDecorator* clone() const override = 0;
+    void accept(INodeVisitor* visitor) const override = 0;
 
-    void setAmbientMaterial(Material material) override {
-        mp_form_factor->setAmbientMaterial(material); }
+    void setAmbientMaterial(Material material) override
+    {
+        mp_form_factor->setAmbientMaterial(material);
+    }
 
-    double volume() const override {
-        return mp_form_factor->volume(); }
+    double volume() const override { return mp_form_factor->volume(); }
 
-    double radialExtension() const override {
-        return mp_form_factor->radialExtension(); }
+    double radialExtension() const override { return mp_form_factor->radialExtension(); }
 
-    double bottomZ(const IRotation& rotation) const override {
-        return mp_form_factor->bottomZ(rotation); }
+    double bottomZ(const IRotation& rotation) const override
+    {
+        return mp_form_factor->bottomZ(rotation);
+    }
 
-    double topZ(const IRotation& rotation) const override {
-        return mp_form_factor->topZ(rotation); }
+    double topZ(const IRotation& rotation) const override { return mp_form_factor->topZ(rotation); }
 
-    const IFormFactor* getFormFactor() const {
-        return mp_form_factor; }
+    const IFormFactor* getFormFactor() const { return mp_form_factor; }
 
 protected:
     IFormFactor* mp_form_factor;
diff --git a/Core/Export/ExportToPython.cpp b/Core/Export/ExportToPython.cpp
index 113a46c613c..ae3eace4c57 100644
--- a/Core/Export/ExportToPython.cpp
+++ b/Core/Export/ExportToPython.cpp
@@ -13,11 +13,12 @@
 // ************************************************************************** //
 
 #include "ExportToPython.h"
-#include "SimulationToPython.h"
-#include "SampleToPython.h"
 #include "GISASSimulation.h"
+#include "SampleToPython.h"
+#include "SimulationToPython.h"
 
-namespace {
+namespace
+{
 std::string simulationCode(const Simulation& simulation,
                            SimulationToPython::EMainType mainFunctionType)
 {
@@ -27,7 +28,7 @@ std::string simulationCode(const Simulation& simulation,
     SimulationToPython generator;
     return generator.generateSimulationCode(*sim, mainFunctionType);
 }
-}
+} // namespace
 
 std::string ExportToPython::generateSampleCode(const MultiLayer& multilayer)
 {
diff --git a/Core/Export/ExportToPython.h b/Core/Export/ExportToPython.h
index ea6bb2b1fe6..0d3f13ac17d 100644
--- a/Core/Export/ExportToPython.h
+++ b/Core/Export/ExportToPython.h
@@ -23,12 +23,13 @@ class Simulation;
 
 //! Contains main methods to generate Python scripts from Core simulation objects.
 
-namespace ExportToPython {
+namespace ExportToPython
+{
 
 BA_CORE_API_ std::string generateSampleCode(const MultiLayer& multilayer);
 BA_CORE_API_ std::string generateSimulationCode(const Simulation& simulation);
 BA_CORE_API_ std::string generatePyExportTest(const Simulation& simulation);
 
-}
+} // namespace ExportToPython
 
-#endif  //EXPORTTOPYTHON_H
+#endif // EXPORTTOPYTHON_H
diff --git a/Core/Export/INodeUtils.h b/Core/Export/INodeUtils.h
index 6f2d2e6c3eb..5521eb768f8 100644
--- a/Core/Export/INodeUtils.h
+++ b/Core/Export/INodeUtils.h
@@ -17,8 +17,10 @@
 
 #include "INode.h"
 
-namespace INodeUtils {
-template<typename T> std::vector<const T*> ChildNodesOfType(const INode& node) {
+namespace INodeUtils
+{
+template <typename T> std::vector<const T*> ChildNodesOfType(const INode& node)
+{
     std::vector<const T*> result;
     for (auto p_child : node.getChildren()) {
         if (auto t = dynamic_cast<const T*>(p_child))
@@ -27,13 +29,16 @@ template<typename T> std::vector<const T*> ChildNodesOfType(const INode& node) {
     return result;
 }
 
-template<typename T> const T* OnlyChildOfType(const INode& node) {
+template <typename T> const T* OnlyChildOfType(const INode& node)
+{
     auto list = ChildNodesOfType<T>(node);
-    if (list.size()!=1) return nullptr;
+    if (list.size() != 1)
+        return nullptr;
     return list.front();
 }
 
-template<typename T> std::vector<const T*> AllDescendantsOfType(const INode& node) {
+template <typename T> std::vector<const T*> AllDescendantsOfType(const INode& node)
+{
     std::vector<const T*> result;
     for (auto p_child : node.getChildren()) {
         if (auto t = dynamic_cast<const T*>(p_child))
@@ -43,7 +48,6 @@ template<typename T> std::vector<const T*> AllDescendantsOfType(const INode& nod
     }
     return result;
 }
-}
-
+} // namespace INodeUtils
 
 #endif // INODEUTILS_H
diff --git a/Core/Export/PythonFormatting.cpp b/Core/Export/PythonFormatting.cpp
index 379e2041bf7..acb3a1f3482 100644
--- a/Core/Export/PythonFormatting.cpp
+++ b/Core/Export/PythonFormatting.cpp
@@ -16,20 +16,20 @@
 #include "BornAgainNamespace.h"
 #include "Distributions.h"
 #include "Ellipse.h"
+#include "FixedBinAxis.h"
 #include "IParameterized.h"
 #include "InfinitePlane.h"
 #include "Line.h"
 #include "MathConstants.h"
 #include "Numeric.h"
-#include "ParameterPool.h"
 #include "ParameterDistribution.h"
+#include "ParameterPool.h"
 #include "PointwiseAxis.h"
 #include "Polygon.h"
 #include "RealParameter.h"
 #include "Rectangle.h"
 #include "StringUtils.h"
 #include "Units.h"
-#include "FixedBinAxis.h"
 #include <iomanip>
 
 namespace PythonFormatting
@@ -49,7 +49,6 @@ std::string getSampleFunctionName()
     return "get_sample";
 }
 
-
 //! Returns fixed Python code snippet that defines the function "runSimulation".
 
 std::string representShape2D(const std::string& indent, const IShape2D* ishape, bool mask_value,
@@ -109,7 +108,10 @@ std::string representShape2D(const std::string& indent, const IShape2D* ishape,
     return result.str();
 }
 
-std::string printBool(double value) { return value ? "True" : "False"; }
+std::string printBool(double value)
+{
+    return value ? "True" : "False";
+}
 
 std::string printDouble(double input)
 {
@@ -315,10 +317,8 @@ std::string printAxis(const IAxis& axis, const std::string& units, size_t offset
     std::ostringstream result;
 
     if (auto fixedAxis = dynamic_cast<const FixedBinAxis*>(&axis)) {
-        result << "ba.FixedBinAxis("
-               << printString(fixedAxis->getName()) << ", "
-               << fixedAxis->size() << ", "
-               << printValue(fixedAxis->getMin(), units) << ", "
+        result << "ba.FixedBinAxis(" << printString(fixedAxis->getName()) << ", "
+               << fixedAxis->size() << ", " << printValue(fixedAxis->getMin(), units) << ", "
                << printValue(fixedAxis->getMax(), units) << ")";
     } else if (auto pointwise_axis = dynamic_cast<const PointwiseAxis*>(&axis)) {
         const std::string py_def_call = "numpy.asarray([";
@@ -326,7 +326,7 @@ std::string printAxis(const IAxis& axis, const std::string& units, size_t offset
         result << py_def_call;
 
         std::vector<double> points = pointwise_axis->getBinCenters();
-        for (auto iter = points.begin(); iter != points.end()-1; ++iter) {
+        for (auto iter = points.begin(); iter != points.end() - 1; ++iter) {
             result << printValue(*iter, units) << ",\n";
             result << indent(total_offset);
         }
diff --git a/Core/Export/PythonFormatting.h b/Core/Export/PythonFormatting.h
index bc3c6d038cc..9d918250d62 100644
--- a/Core/Export/PythonFormatting.h
+++ b/Core/Export/PythonFormatting.h
@@ -74,6 +74,6 @@ BA_CORE_API_ std::string printAxis(const IAxis& axis, const std::string& units,
 //! Returns a string of blanks with given width. By default
 //! the width equals standard offset in python files.
 BA_CORE_API_ std::string indent(size_t width = 4u);
-}
+} // namespace PythonFormatting
 
 #endif // PYTHONFORMATTING_H
diff --git a/Core/Export/SampleLabelHandler.cpp b/Core/Export/SampleLabelHandler.cpp
index ebb51b6ebd8..9a06ce3dcdc 100644
--- a/Core/Export/SampleLabelHandler.cpp
+++ b/Core/Export/SampleLabelHandler.cpp
@@ -92,107 +92,106 @@ std::string SampleLabelHandler::labelRoughness(const LayerRoughness* roughness)
 
 void SampleLabelHandler::insertCrystal(const Crystal* sample)
 {
-    std::string label = "crystal_" + std::to_string(m_CrystalLabel.size()+1);
+    std::string label = "crystal_" + std::to_string(m_CrystalLabel.size() + 1);
     m_CrystalLabel.insert(sample, label);
 }
 
 void SampleLabelHandler::insertFormFactor(const IFormFactor* sample)
 {
-    std::string label = "formFactor_" + std::to_string(m_FormFactorLabel.size()+1);
+    std::string label = "formFactor_" + std::to_string(m_FormFactorLabel.size() + 1);
     m_FormFactorLabel.insert(sample, label);
 }
 
 void SampleLabelHandler::insertInterferenceFunction(const IInterferenceFunction* sample)
 {
-    std::string label = "interference_" + std::to_string(m_InterferenceFunctionLabel.size()+1);
+    std::string label = "interference_" + std::to_string(m_InterferenceFunctionLabel.size() + 1);
     m_InterferenceFunctionLabel.insert(sample, label);
 }
 
 void SampleLabelHandler::insertLayer(const Layer* sample)
 {
-    std::string label = "layer_" + std::to_string(m_LayerLabel.size()+1);
+    std::string label = "layer_" + std::to_string(m_LayerLabel.size() + 1);
     m_LayerLabel.insert(sample, label);
 }
 
 void SampleLabelHandler::insertLayout(const ILayout* sample)
 {
-    std::string label = "layout_" + std::to_string(m_ILayoutLabel.size()+1);
+    std::string label = "layout_" + std::to_string(m_ILayoutLabel.size() + 1);
     m_ILayoutLabel.insert(sample, label);
 }
 
 void SampleLabelHandler::insertMaterial(const Material* mat)
 {
-    for (auto it=m_MaterialLabel.begin(); it!=m_MaterialLabel.end(); ++it) {
-        if( *(it->first) == *mat ) {
+    for (auto it = m_MaterialLabel.begin(); it != m_MaterialLabel.end(); ++it) {
+        if (*(it->first) == *mat) {
             m_MaterialLabel.insert(mat, it->second);
             return;
         }
     }
     // material not found => create new label
     std::set<std::string> unique_labels;
-    for (auto it=m_MaterialLabel.begin(); it!=m_MaterialLabel.end(); ++it)
+    for (auto it = m_MaterialLabel.begin(); it != m_MaterialLabel.end(); ++it)
         unique_labels.insert(it->second);
 
-    std::string label = "material_" + std::to_string(unique_labels.size()+1);
+    std::string label = "material_" + std::to_string(unique_labels.size() + 1);
     m_MaterialLabel.insert(mat, label);
 }
 
 void SampleLabelHandler::insertLattice(const Lattice* sample)
 {
-    std::string label = "lattice_" + std::to_string(m_LatticeLabel.size()+1);
+    std::string label = "lattice_" + std::to_string(m_LatticeLabel.size() + 1);
     m_LatticeLabel.insert(sample, label);
 }
 
 void SampleLabelHandler::insertMesoCrystal(const MesoCrystal* sample)
 {
-    std::string label = "mesocrystal_" + std::to_string(m_MesoCrystalLabel.size()+1);
+    std::string label = "mesocrystal_" + std::to_string(m_MesoCrystalLabel.size() + 1);
     m_MesoCrystalLabel.insert(sample, label);
 }
 
 void SampleLabelHandler::insertMultiLayer(const MultiLayer* sample)
 {
-    std::string label = "multiLayer_" + std::to_string(m_MultiLayerLabel.size()+1);
+    std::string label = "multiLayer_" + std::to_string(m_MultiLayerLabel.size() + 1);
     m_MultiLayerLabel.insert(sample, label);
 }
 
 void SampleLabelHandler::insertParticleComposition(const ParticleComposition* sample)
 {
-    std::string label = "particleComposition_" +
-            std::to_string(m_ParticleCompositionLabel.size()+1);
+    std::string label =
+        "particleComposition_" + std::to_string(m_ParticleCompositionLabel.size() + 1);
     m_ParticleCompositionLabel.insert(sample, label);
 }
 
 void SampleLabelHandler::insertParticleDistribution(const ParticleDistribution* sample)
 {
-    std::string label = "particleDistribution_" +
-            std::to_string(m_ParticleDistributionLabel.size()+1);
+    std::string label =
+        "particleDistribution_" + std::to_string(m_ParticleDistributionLabel.size() + 1);
     m_ParticleDistributionLabel.insert(sample, label);
 }
 
 void SampleLabelHandler::insertParticle(const Particle* sample)
 {
-    std::string label = "particle_" + std::to_string(m_ParticleLabel.size()+1);
+    std::string label = "particle_" + std::to_string(m_ParticleLabel.size() + 1);
     m_ParticleLabel.insert(sample, label);
 }
 
 void SampleLabelHandler::insertParticleCoreShell(const ParticleCoreShell* sample)
 {
-    std::string label = "particleCoreShell_" + std::to_string(m_ParticleCoreShellLabel.size()+1);
+    std::string label = "particleCoreShell_" + std::to_string(m_ParticleCoreShellLabel.size() + 1);
     m_ParticleCoreShellLabel.insert(sample, label);
 }
 
 void SampleLabelHandler::insertRotation(const IRotation* sample)
 {
-    std::string label = "rotation_" + std::to_string(m_RotationsLabel.size()+1);
+    std::string label = "rotation_" + std::to_string(m_RotationsLabel.size() + 1);
     m_RotationsLabel.insert(sample, label);
 }
 
 void SampleLabelHandler::insertRoughness(const LayerRoughness* sample)
 {
-    if (sample->getSigma() != 0 &&
-        sample->getHurstParameter() != 0 &&
-        sample->getLatteralCorrLength() != 0) {
-        std::string label = "layerRoughness_" + std::to_string(m_LayerRoughnessLabel.size()+1);
+    if (sample->getSigma() != 0 && sample->getHurstParameter() != 0
+        && sample->getLatteralCorrLength() != 0) {
+        std::string label = "layerRoughness_" + std::to_string(m_LayerRoughnessLabel.size() + 1);
         m_LayerRoughnessLabel.insert(sample, label);
     }
 }
diff --git a/Core/Export/SampleLabelHandler.h b/Core/Export/SampleLabelHandler.h
index a1339962482..76290c66fc5 100644
--- a/Core/Export/SampleLabelHandler.h
+++ b/Core/Export/SampleLabelHandler.h
@@ -35,12 +35,10 @@ class ParticleCoreShell;
 class ParticleDistribution;
 class MesoCrystal;
 
-template<class Key>
-class LabelMap : public OrderedMap<Key, std::string>
+template <class Key> class LabelMap : public OrderedMap<Key, std::string>
 {
 };
 
-
 //! The handler which construct labels for sample variables during python script generation.
 //! @ingroup tools_internal
 
diff --git a/Core/Export/SampleToPython.cpp b/Core/Export/SampleToPython.cpp
index 599a0904c6c..6f69f0bad2f 100644
--- a/Core/Export/SampleToPython.cpp
+++ b/Core/Export/SampleToPython.cpp
@@ -504,8 +504,7 @@ std::string SampleToPython::defineParticleLayouts() const
             if (auto p_iff = INodeUtils::OnlyChildOfType<IInterferenceFunction>(*particleLayout))
                 result << indent() << it->second << ".setInterferenceFunction("
                        << m_label->labelInterferenceFunction(p_iff) << ")\n";
-            result << indent() << it->second << ".setWeight("
-                   << particleLayout->weight() << ")\n";
+            result << indent() << it->second << ".setWeight(" << particleLayout->weight() << ")\n";
             result << indent() << it->second << ".setTotalParticleSurfaceDensity("
                    << particleLayout->totalParticleSurfaceDensity() << ")\n";
         }
diff --git a/Core/Export/SimulationToPython.cpp b/Core/Export/SimulationToPython.cpp
index d4a86f5b31c..156399f69c5 100644
--- a/Core/Export/SimulationToPython.cpp
+++ b/Core/Export/SimulationToPython.cpp
@@ -20,6 +20,7 @@
 #include "GISASSimulation.h"
 #include "INodeUtils.h"
 #include "ISpecularScan.h"
+#include "OffSpecSimulation.h"
 #include "ParameterUtils.h"
 #include "PoissonNoiseBackground.h"
 #include "PythonFormatting.h"
@@ -29,7 +30,6 @@
 #include "SampleToPython.h"
 #include "SpecularSimulation.h"
 #include "SphericalDetector.h"
-#include "OffSpecSimulation.h"
 #include <iomanip>
 
 using namespace PythonFormatting;
@@ -37,12 +37,14 @@ using namespace PythonFormatting;
 namespace
 {
 const std::string defineSimulate = "def run_simulation():\n"
-                                   "    sample = "+getSampleFunctionName()+"()\n"
-                                   "    simulation = get_simulation()\n"
-                                   "    simulation.setSample(sample)\n"
-                                   "    simulation.runSimulation()\n"
-                                   "    return simulation.result()\n"
-                                   "\n\n";
+                                   "    sample = "
+                                   + getSampleFunctionName()
+                                   + "()\n"
+                                     "    simulation = get_simulation()\n"
+                                     "    simulation.setSample(sample)\n"
+                                     "    simulation.runSimulation()\n"
+                                     "    return simulation.result()\n"
+                                     "\n\n";
 
 //! Returns a function that converts a coordinate to a Python code snippet with appropiate unit
 std::function<std::string(double)> printFunc(const IDetector* detector)
@@ -237,8 +239,8 @@ SimulationToPython::defineDetectorPolarizationAnalysis(const Simulation* simulat
     const IDetector* detector = simulation->getInstrument().getDetector();
     kvector_t analyzer_direction = detector->detectionProperties().analyzerDirection();
     double analyzer_efficiency = detector->detectionProperties().analyzerEfficiency();
-    double analyzer_total_transmission
-        = detector->detectionProperties().analyzerTotalTransmission();
+    double analyzer_total_transmission =
+        detector->detectionProperties().analyzerTotalTransmission();
 
     if (analyzer_direction.mag() > 0.0) {
         std::string direction_name = "analyzer_direction";
@@ -327,8 +329,8 @@ std::string SimulationToPython::defineBeamIntensity(const Beam& beam) const
 std::string SimulationToPython::defineParameterDistributions(const Simulation* simulation) const
 {
     std::ostringstream result;
-    const std::vector<ParameterDistribution>& distributions
-        = simulation->getDistributionHandler().getDistributions();
+    const std::vector<ParameterDistribution>& distributions =
+        simulation->getDistributionHandler().getDistributions();
     if (distributions.size() == 0)
         return "";
     for (size_t i = 0; i < distributions.size(); ++i) {
diff --git a/Core/Fitting/FitObjective.cpp b/Core/Fitting/FitObjective.cpp
index 42ad4164af4..cb3825edb63 100644
--- a/Core/Fitting/FitObjective.cpp
+++ b/Core/Fitting/FitObjective.cpp
@@ -64,9 +64,10 @@ simulation_builder_t FitObjective::simulationBuilder(PyBuilderCallback& callback
 
 FitObjective::FitObjective()
     : m_metric_module(
-          std::make_unique<ObjectiveMetricWrapper>(std::make_unique<PoissonLikeMetric>()))
-    , m_fit_status(std::make_unique<FitStatus>(this))
-{}
+        std::make_unique<ObjectiveMetricWrapper>(std::make_unique<PoissonLikeMetric>())),
+      m_fit_status(std::make_unique<FitStatus>(this))
+{
+}
 
 FitObjective::~FitObjective() = default;
 
@@ -185,9 +186,7 @@ void FitObjective::initPlot(int every_nth, fit_observer_t observer)
 
 void FitObjective::initPlot(int every_nth, PyObserverCallback& callback)
 {
-    fit_observer_t observer = [&](const FitObjective& objective) {
-        callback.update(objective);
-    };
+    fit_observer_t observer = [&](const FitObjective& objective) { callback.update(objective); };
     m_fit_status->addObserver(every_nth, observer);
 }
 
@@ -303,7 +302,7 @@ std::vector<double> FitObjective::composeArray(DataPairAccessor getter) const
 
     std::vector<double> result;
     result.reserve(numberOfFitElements());
-    for (auto& pair: m_fit_objects) {
+    for (auto& pair : m_fit_objects) {
         std::vector<double> array = (pair.*getter)();
         std::move(array.begin(), array.end(), std::back_inserter(result));
     }
@@ -322,8 +321,7 @@ size_t FitObjective::check_index(size_t index) const
 IMetricWrapper::~IMetricWrapper() = default;
 
 ChiModuleWrapper::ChiModuleWrapper(std::unique_ptr<IChiSquaredModule> module)
-    : IMetricWrapper()
-    , m_module(std::move(module))
+    : IMetricWrapper(), m_module(std::move(module))
 {
     if (!m_module)
         throw std::runtime_error("Error in ChiModuleWrapper: empty chi square module passed");
@@ -333,12 +331,12 @@ double ChiModuleWrapper::compute(const std::vector<SimDataPair>& fit_objects, si
 {
     size_t n_points = 0;
     double result = 0.0;
-    for (auto& obj: fit_objects) {
+    for (auto& obj : fit_objects) {
         const auto sim_array = obj.simulation_array();
         const auto exp_array = obj.experimental_array();
         const auto weights = obj.user_weights_array();
         const size_t n_elements = sim_array.size();
-        for(size_t i = 0; i < n_elements; ++i) {
+        for (size_t i = 0; i < n_elements; ++i) {
             double value = m_module->residual(sim_array[i], exp_array[i], weights[i]);
             result += value * value;
         }
@@ -353,23 +351,21 @@ double ChiModuleWrapper::compute(const std::vector<SimDataPair>& fit_objects, si
 }
 
 ObjectiveMetricWrapper::ObjectiveMetricWrapper(std::unique_ptr<ObjectiveMetric> module)
-    : IMetricWrapper()
-    , m_module(std::move(module))
+    : IMetricWrapper(), m_module(std::move(module))
 {
     if (!m_module)
         throw std::runtime_error("Error in ObjectiveMetricWrapper: empty objective metric passed");
 }
 
-double ObjectiveMetricWrapper::compute(const std::vector<SimDataPair>& fit_objects,
-                                       size_t) const
+double ObjectiveMetricWrapper::compute(const std::vector<SimDataPair>& fit_objects, size_t) const
 {
     // deciding whether to use uncertainties in metrics computation.
     bool use_uncertainties = true;
-    for (auto& obj: fit_objects)
+    for (auto& obj : fit_objects)
         use_uncertainties = use_uncertainties && obj.containsUncertainties();
 
     double result = 0.0;
-    for (auto& obj: fit_objects)
+    for (auto& obj : fit_objects)
         result += m_module->compute(obj, use_uncertainties);
     return result;
 }
diff --git a/Core/Fitting/FitObjective.h b/Core/Fitting/FitObjective.h
index 7c988d246ab..e2cb40a5fdd 100644
--- a/Core/Fitting/FitObjective.h
+++ b/Core/Fitting/FitObjective.h
@@ -15,8 +15,8 @@
 #ifndef FITOBJECTIVE_H
 #define FITOBJECTIVE_H
 
-#include "FitTypes.h"
 #include "ArrayUtils.h"
+#include "FitTypes.h"
 #include "IterationInfo.h"
 #include "MinimizerResult.h"
 #include "OutputData.h"
@@ -146,4 +146,4 @@ private:
     std::unique_ptr<FitStatus> m_fit_status;
 };
 
-#endif  // FITOBJECTIVE_H
+#endif // FITOBJECTIVE_H
diff --git a/Core/Fitting/FitObserver.h b/Core/Fitting/FitObserver.h
index 4fb76ababc5..9a385ea9078 100644
--- a/Core/Fitting/FitObserver.h
+++ b/Core/Fitting/FitObserver.h
@@ -22,8 +22,7 @@
 //! Contains collection of observers and call them at specified intervals.
 //! Each observer will be called at first iteration and every-nth iterations.
 
-template <class T>
-class FitObserver
+template <class T> class FitObserver
 {
 public:
     using observer_t = std::function<void(const T&)>;
@@ -41,12 +40,14 @@ public:
     void notify_all(const T& data);
 
 private:
-    class ObserverData {
+    class ObserverData
+    {
     public:
-        ObserverData()
-            : m_every_nth(0) {}
+        ObserverData() : m_every_nth(0) {}
         ObserverData(int every_nth, observer_t observer)
-            : m_every_nth(every_nth), m_observer(observer) {}
+            : m_every_nth(every_nth), m_observer(observer)
+        {
+        }
         int m_every_nth;
         observer_t m_observer;
     };
@@ -57,22 +58,17 @@ private:
     int m_notify_count; //! Total number of notify calls
 };
 
-template<class T>
-FitObserver<T>::FitObserver() : m_notify_count(0)
-{
+template <class T> FitObserver<T>::FitObserver() : m_notify_count(0) {}
 
-}
-
-template<class T>
+template <class T>
 void FitObserver<T>::addObserver(int every_nth, typename FitObserver::observer_t observer)
 {
     m_observers.push_back(ObserverData(every_nth, observer));
 }
 
-template<class T>
-void FitObserver<T>::notify(const T& data)
+template <class T> void FitObserver<T>::notify(const T& data)
 {
-    for(const auto& observer : m_observers) {
+    for (const auto& observer : m_observers) {
         if (need_notify(observer.m_every_nth))
             observer.m_observer(data);
     }
@@ -80,19 +76,17 @@ void FitObserver<T>::notify(const T& data)
     m_notify_count++;
 }
 
-template<class T>
-void FitObserver<T>::notify_all(const T& data)
+template <class T> void FitObserver<T>::notify_all(const T& data)
 {
-    for(const auto& observer : m_observers)
+    for (const auto& observer : m_observers)
         observer.m_observer(data);
 
     m_notify_count++;
 }
 
-template<class T>
-bool FitObserver<T>::need_notify(int every_nth)
+template <class T> bool FitObserver<T>::need_notify(int every_nth)
 {
-    return m_notify_count == 0 || m_notify_count%every_nth == 0 ? true : false;
+    return m_notify_count == 0 || m_notify_count % every_nth == 0 ? true : false;
 }
 
 #endif // FITOBSERVER_H
diff --git a/Core/Fitting/FitPrintService.cpp b/Core/Fitting/FitPrintService.cpp
index b6da83bca71..68b72a76976 100644
--- a/Core/Fitting/FitPrintService.cpp
+++ b/Core/Fitting/FitPrintService.cpp
@@ -14,14 +14,14 @@
 
 #include "FitPrintService.h"
 #include "FitObjective.h"
-#include "StringUtils.h"
 #include "MinimizerResult.h"
-#include <iostream>
+#include "StringUtils.h"
 #include <iomanip>
+#include <iostream>
 #include <sstream>
 
-
-namespace {
+namespace
+{
 
 size_t length_of_longest_name(const Fit::Parameters& params)
 {
@@ -33,7 +33,7 @@ size_t length_of_longest_name(const Fit::Parameters& params)
     return result;
 }
 
-}
+} // namespace
 
 FitPrintService::FitPrintService() = default;
 
@@ -61,9 +61,8 @@ std::string FitPrintService::iterationHeaderString(const FitObjective& objective
     std::ostringstream result;
 
     result << "FitPrintService::update() -> Info."
-           << " NCall:" << objective.iterationInfo().iterationCount()
-           << " Chi2:" << std::scientific << std::setprecision(8)
-           << objective.iterationInfo().chi2() << "\n";
+           << " NCall:" << objective.iterationInfo().iterationCount() << " Chi2:" << std::scientific
+           << std::setprecision(8) << objective.iterationInfo().chi2() << "\n";
 
     return result.str();
 }
@@ -88,9 +87,8 @@ std::string FitPrintService::parameterString(const FitObjective& objective)
     const auto length = length_of_longest_name(params);
 
     for (const auto& par : params) {
-        result << StringUtils::padRight(par.name(), length)
-               << std::scientific << std::setprecision(6)
-               << "  " << par.startValue() << " " << par.limits().toString()
+        result << StringUtils::padRight(par.name(), length) << std::scientific
+               << std::setprecision(6) << "  " << par.startValue() << " " << par.limits().toString()
                << "  " << par.value() << "\n";
     }
 
@@ -104,8 +102,9 @@ std::string FitPrintService::fitResultString(const FitObjective& objective)
     m_run_time.stop();
 
     result << "This was the last iteration." << std::endl;
-    result << "Total time spend: " << std::fixed << std::setprecision(2)
-           << m_run_time.runTime() << " sec." << "\n\n";
+    result << "Total time spend: " << std::fixed << std::setprecision(2) << m_run_time.runTime()
+           << " sec."
+           << "\n\n";
 
     result << objective.minimizerResult().toString();
     return result.str();
diff --git a/Core/Fitting/FitPrintService.h b/Core/Fitting/FitPrintService.h
index 93b44d1972c..6d799e5a1ab 100644
--- a/Core/Fitting/FitPrintService.h
+++ b/Core/Fitting/FitPrintService.h
@@ -15,8 +15,8 @@
 #ifndef FITPRINTSERVICE_H
 #define FITPRINTSERVICE_H
 
-#include "WinDllMacros.h"
 #include "TimeInterval.h"
+#include "WinDllMacros.h"
 #include <string>
 
 class FitObjective;
diff --git a/Core/Fitting/FitStatus.cpp b/Core/Fitting/FitStatus.cpp
index eed8bb0dfba..845ef6a8bf4 100644
--- a/Core/Fitting/FitStatus.cpp
+++ b/Core/Fitting/FitStatus.cpp
@@ -18,10 +18,8 @@
 #include <stdexcept>
 
 FitStatus::FitStatus(const FitObjective* fit_objective)
-    : m_fit_status(IDLE)
-    , m_fit_objective(fit_objective)
+    : m_fit_status(IDLE), m_fit_objective(fit_objective)
 {
-
 }
 
 FitStatus::~FitStatus() = default;
@@ -43,7 +41,8 @@ bool FitStatus::isCompleted() const
 
 void FitStatus::update(const Fit::Parameters& params, double chi2)
 {
-    if (!isInterrupted()) m_fit_status = RUNNING;
+    if (!isInterrupted())
+        m_fit_status = RUNNING;
 
     m_iterationInfo.update(params, chi2);
 
@@ -86,4 +85,3 @@ void FitStatus::finalize(const Fit::MinimizerResult& result)
     m_fit_status = COMPLETED;
     m_observers.notify_all(*m_fit_objective);
 }
-
diff --git a/Core/Fitting/FitStatus.h b/Core/Fitting/FitStatus.h
index e0e5f524f0b..2ddb33fa760 100644
--- a/Core/Fitting/FitStatus.h
+++ b/Core/Fitting/FitStatus.h
@@ -15,14 +15,17 @@
 #ifndef FITSTATUS_H
 #define FITSTATUS_H
 
-#include "WinDllMacros.h"
-#include "FitTypes.h"
 #include "FitObserver.h"
+#include "FitTypes.h"
 #include "IterationInfo.h"
-#include <vector>
+#include "WinDllMacros.h"
 #include <functional>
+#include <vector>
 
-namespace Fit { class MinimizerResult; }
+namespace Fit
+{
+class MinimizerResult;
+}
 class FitObjective;
 class FitPrintService;
 
diff --git a/Core/Fitting/FitTypes.h b/Core/Fitting/FitTypes.h
index 23bd9f79b67..89de252231d 100644
--- a/Core/Fitting/FitTypes.h
+++ b/Core/Fitting/FitTypes.h
@@ -20,7 +20,10 @@
 #include <memory>
 
 class Simulation;
-namespace Fit { class Parameters; }
+namespace Fit
+{
+class Parameters;
+}
 class FitObjective;
 
 using simulation_builder_t = std::function<std::unique_ptr<Simulation>(const Fit::Parameters&)>;
diff --git a/Core/Fitting/IterationInfo.cpp b/Core/Fitting/IterationInfo.cpp
index 36916443a63..c2e8e6fd43e 100644
--- a/Core/Fitting/IterationInfo.cpp
+++ b/Core/Fitting/IterationInfo.cpp
@@ -14,13 +14,7 @@
 
 #include "IterationInfo.h"
 
-
-IterationInfo::IterationInfo()
-    : m_chi2(0.0)
-    , m_iteration_count(0)
-{
-
-}
+IterationInfo::IterationInfo() : m_chi2(0.0), m_iteration_count(0) {}
 
 void IterationInfo::update(const Fit::Parameters& params, double chi2)
 {
@@ -34,7 +28,6 @@ unsigned IterationInfo::iterationCount() const
     return m_iteration_count;
 }
 
-
 double IterationInfo::chi2() const
 {
     return m_chi2;
@@ -49,7 +42,7 @@ std::map<std::string, double> IterationInfo::parameterMap() const
 {
     std::map<std::string, double> result;
 
-    for(const auto& par : m_current_parameters)
+    for (const auto& par : m_current_parameters)
         result.insert(std::make_pair(par.name(), par.value()));
 
     return result;
diff --git a/Core/Fitting/IterationInfo.h b/Core/Fitting/IterationInfo.h
index f9688e6b6de..7705b509eac 100644
--- a/Core/Fitting/IterationInfo.h
+++ b/Core/Fitting/IterationInfo.h
@@ -15,8 +15,8 @@
 #ifndef ITERATIONINFO_H
 #define ITERATIONINFO_H
 
-#include "WinDllMacros.h"
 #include "Parameters.h"
+#include "WinDllMacros.h"
 #include <map>
 #include <string>
 
@@ -46,5 +46,4 @@ private:
     unsigned m_iteration_count;
 };
 
-
 #endif // ITERATIONINFO_H
diff --git a/Core/Fitting/ObjectiveMetric.cpp b/Core/Fitting/ObjectiveMetric.cpp
index dd7d3be10eb..816907a3fae 100644
--- a/Core/Fitting/ObjectiveMetric.cpp
+++ b/Core/Fitting/ObjectiveMetric.cpp
@@ -19,13 +19,13 @@
 #include <cmath>
 #include <limits>
 
-namespace {
+namespace
+{
 const double double_max = std::numeric_limits<double>::max();
 const double double_min = std::numeric_limits<double>::min();
 const double ln10 = std::log(10.0);
 
-template<class T>
-T* copyMetric(const T& metric)
+template <class T> T* copyMetric(const T& metric)
 {
     std::unique_ptr<T> result(new T());
     result->setNorm(metric.norm());
@@ -37,8 +37,7 @@ void checkIntegrity(const std::vector<double>& sim_data, const std::vector<doubl
 {
     const size_t sim_size = sim_data.size();
     if (sim_size != exp_data.size() || sim_size != weight_factors.size())
-        throw std::runtime_error(
-            "Error in ObjectiveMetric: input arrays have different sizes");
+        throw std::runtime_error("Error in ObjectiveMetric: input arrays have different sizes");
 
     for (size_t i = 0; i < sim_size; ++i)
         if (sim_data[i] < 0.0)
@@ -51,16 +50,13 @@ void checkIntegrity(const std::vector<double>& sim_data, const std::vector<doubl
                     const std::vector<double>& weight_factors)
 {
     if (sim_data.size() != uncertainties.size())
-        throw std::runtime_error(
-            "Error in ObjectiveMetric: input arrays have different sizes");
+        throw std::runtime_error("Error in ObjectiveMetric: input arrays have different sizes");
 
     checkIntegrity(sim_data, exp_data, weight_factors);
 }
-}
+} // namespace
 
-ObjectiveMetric::ObjectiveMetric(std::function<double(double)> norm)
-    : m_norm(std::move(norm))
-{}
+ObjectiveMetric::ObjectiveMetric(std::function<double(double)> norm) : m_norm(std::move(norm)) {}
 
 double ObjectiveMetric::compute(const SimDataPair& data_pair, bool use_weights) const
 {
@@ -83,9 +79,7 @@ void ObjectiveMetric::setNorm(std::function<double(double)> norm)
 
 // ----------------------- Chi2 metric ---------------------------
 
-Chi2Metric::Chi2Metric()
-    : ObjectiveMetric(ObjectiveMetricUtils::l2Norm())
-{}
+Chi2Metric::Chi2Metric() : ObjectiveMetric(ObjectiveMetricUtils::l2Norm()) {}
 
 Chi2Metric* Chi2Metric::clone() const
 {
@@ -123,9 +117,7 @@ double Chi2Metric::computeFromArrays(std::vector<double> sim_data, std::vector<d
 
 // ----------------------- Poisson-like metric ---------------------------
 
-PoissonLikeMetric::PoissonLikeMetric()
-    : Chi2Metric()
-{}
+PoissonLikeMetric::PoissonLikeMetric() : Chi2Metric() {}
 
 PoissonLikeMetric* PoissonLikeMetric::clone() const
 {
@@ -140,8 +132,7 @@ double PoissonLikeMetric::computeFromArrays(std::vector<double> sim_data,
 
     double result = 0.0;
     auto norm_fun = norm();
-    for (size_t i = 0, sim_size = sim_data.size(); i < sim_size; ++i)
-    {
+    for (size_t i = 0, sim_size = sim_data.size(); i < sim_size; ++i) {
         if (weight_factors[i] <= 0.0 || exp_data[i] < 0.0)
             continue;
         const double variance = std::max(1.0, sim_data[i]);
@@ -154,9 +145,7 @@ double PoissonLikeMetric::computeFromArrays(std::vector<double> sim_data,
 
 // ----------------------- Log metric ---------------------------
 
-LogMetric::LogMetric()
-    : ObjectiveMetric(ObjectiveMetricUtils::l2Norm())
-{}
+LogMetric::LogMetric() : ObjectiveMetric(ObjectiveMetricUtils::l2Norm()) {}
 
 LogMetric* LogMetric::clone() const
 {
@@ -171,8 +160,7 @@ double LogMetric::computeFromArrays(std::vector<double> sim_data, std::vector<do
 
     double result = 0.0;
     auto norm_fun = norm();
-    for (size_t i = 0, sim_size = sim_data.size(); i < sim_size; ++i)
-    {
+    for (size_t i = 0, sim_size = sim_data.size(); i < sim_size; ++i) {
         if (weight_factors[i] <= 0.0 || exp_data[i] < 0.0 || uncertainties[i] <= 0.0)
             continue;
         const double sim_val = std::max(double_min, sim_data[i]);
@@ -192,8 +180,7 @@ double LogMetric::computeFromArrays(std::vector<double> sim_data, std::vector<do
 
     double result = 0.0;
     auto norm_fun = norm();
-    for (size_t i = 0, sim_size = sim_data.size(); i < sim_size; ++i)
-    {
+    for (size_t i = 0, sim_size = sim_data.size(); i < sim_size; ++i) {
         if (weight_factors[i] <= 0.0 || exp_data[i] < 0.0)
             continue;
         const double sim_val = std::max(double_min, sim_data[i]);
@@ -206,9 +193,7 @@ double LogMetric::computeFromArrays(std::vector<double> sim_data, std::vector<do
 
 // ----------------------- Relative difference ---------------------------
 
-RelativeDifferenceMetric::RelativeDifferenceMetric()
-    : Chi2Metric ()
-{}
+RelativeDifferenceMetric::RelativeDifferenceMetric() : Chi2Metric() {}
 
 RelativeDifferenceMetric* RelativeDifferenceMetric::clone() const
 {
@@ -223,8 +208,7 @@ double RelativeDifferenceMetric::computeFromArrays(std::vector<double> sim_data,
 
     double result = 0.0;
     auto norm_fun = norm();
-    for (size_t i = 0, sim_size = sim_data.size(); i < sim_size; ++i)
-    {
+    for (size_t i = 0, sim_size = sim_data.size(); i < sim_size; ++i) {
         if (weight_factors[i] <= 0.0 || exp_data[i] < 0.0)
             continue;
         const double sim_val = std::max(double_min, sim_data[i]);
@@ -237,9 +221,7 @@ double RelativeDifferenceMetric::computeFromArrays(std::vector<double> sim_data,
 
 // ----------------------- RQ4 metric ---------------------------
 
-RQ4Metric::RQ4Metric()
-    : Chi2Metric()
-{}
+RQ4Metric::RQ4Metric() : Chi2Metric() {}
 
 RQ4Metric* RQ4Metric::clone() const
 {
diff --git a/Core/Fitting/ObjectiveMetricUtils.cpp b/Core/Fitting/ObjectiveMetricUtils.cpp
index c5afa423e4d..a7feb7859fb 100644
--- a/Core/Fitting/ObjectiveMetricUtils.cpp
+++ b/Core/Fitting/ObjectiveMetricUtils.cpp
@@ -19,7 +19,8 @@
 #include <map>
 #include <sstream>
 
-namespace {
+namespace
+{
 const std::function<double(double)> l1_norm = [](double term) { return std::abs(term); };
 const std::function<double(double)> l2_norm = [](double term) { return term * term; };
 
@@ -28,20 +29,18 @@ const std::map<std::string, std::function<std::unique_ptr<ObjectiveMetric>()>> m
     {"poisson-like", []() { return std::make_unique<PoissonLikeMetric>(); }},
     {"log", []() { return std::make_unique<LogMetric>(); }},
     {"reldiff", []() { return std::make_unique<RelativeDifferenceMetric>(); }},
-    {"rq4", []() { return std::make_unique<RQ4Metric>(); }}
-};
+    {"rq4", []() { return std::make_unique<RQ4Metric>(); }}};
 const std::string default_metric_name = "poisson-like";
 
 const std::map<std::string, std::function<double(double)>> norm_factory = {{"l1", l1_norm},
                                                                            {"l2", l2_norm}};
 const std::string default_norm_name = "l2";
 
-template<class U>
-std::vector<std::string> keys(const std::map<std::string, U>& map)
+template <class U> std::vector<std::string> keys(const std::map<std::string, U>& map)
 {
     std::vector<std::string> result;
     result.reserve(map.size());
-    for (auto& item: map)
+    for (auto& item : map)
         result.push_back(item.first);
     return result;
 }
@@ -86,11 +85,11 @@ std::string ObjectiveMetricUtils::availableMetricOptions()
 {
     std::stringstream ss;
     ss << "Available metrics:\n";
-    for (auto& item: metricNames())
+    for (auto& item : metricNames())
         ss << "\t" << item << "\n";
     ss << "default metric: " << defaultMetricName() << "\n";
     ss << "Available norms:\n";
-    for (auto& item: normNames())
+    for (auto& item : normNames())
         ss << "\t" << item << "\n";
     ss << "default norm: " << defaultNormName() << "\n";
     return ss.str();
diff --git a/Core/Fitting/PyFittingCallbacks.h b/Core/Fitting/PyFittingCallbacks.h
index 50876a22ecc..ba3c7599e0f 100644
--- a/Core/Fitting/PyFittingCallbacks.h
+++ b/Core/Fitting/PyFittingCallbacks.h
@@ -17,8 +17,8 @@
 
 //! Collection of wrapper classes to call Python callable from C++.
 
-#include "WinDllMacros.h"
 #include "Parameters.h"
+#include "WinDllMacros.h"
 
 class Simulation;
 
@@ -33,7 +33,6 @@ public:
     virtual ~PyBuilderCallback();
 
     virtual Simulation* build_simulation(Fit::Parameters);
-
 };
 
 class FitObjective;
@@ -49,7 +48,6 @@ public:
     virtual ~PyObserverCallback();
 
     virtual void update(const FitObjective&);
-
 };
 
 #endif //  PYFITTINGCALLBACKS_H
diff --git a/Core/Fitting/SimDataPair.cpp b/Core/Fitting/SimDataPair.cpp
index 75fd39f834d..c7029b8ccef 100644
--- a/Core/Fitting/SimDataPair.cpp
+++ b/Core/Fitting/SimDataPair.cpp
@@ -19,8 +19,10 @@
 #include "Simulation.h"
 #include "UnitConverterUtils.h"
 
-namespace {
-[[noreturn]] void throwInitializationException(std::string method) {
+namespace
+{
+[[noreturn]] void throwInitializationException(std::string method)
+{
     std::stringstream ss;
     ss << "Error in SimDataPair::" << method << ": Trying access non-initialized data\n";
     throw std::runtime_error(ss.str());
@@ -33,13 +35,12 @@ std::unique_ptr<OutputData<double>> initUserWeights(const OutputData<double>& sh
     result->setAllTo(value);
     return result;
 }
-}
+} // namespace
 
 SimDataPair::SimDataPair(simulation_builder_t builder, const OutputData<double>& data,
                          std::unique_ptr<OutputData<double>> uncertainties, double user_weight)
-    : m_simulation_builder(builder)
-    , m_raw_data(data.clone())
-    , m_raw_uncertainties(std::move(uncertainties))
+    : m_simulation_builder(builder), m_raw_data(data.clone()),
+      m_raw_uncertainties(std::move(uncertainties))
 {
     m_raw_user_weights = initUserWeights(*m_raw_data, user_weight);
     validate();
@@ -48,10 +49,8 @@ SimDataPair::SimDataPair(simulation_builder_t builder, const OutputData<double>&
 SimDataPair::SimDataPair(simulation_builder_t builder, const OutputData<double>& data,
                          std::unique_ptr<OutputData<double>> uncertainties,
                          std::unique_ptr<OutputData<double>> user_weights)
-    : m_simulation_builder(builder)
-    , m_raw_data(data.clone())
-    , m_raw_uncertainties(std::move(uncertainties))
-    , m_raw_user_weights(std::move(user_weights))
+    : m_simulation_builder(builder), m_raw_data(data.clone()),
+      m_raw_uncertainties(std::move(uncertainties)), m_raw_user_weights(std::move(user_weights))
 {
     if (!m_raw_user_weights)
         m_raw_user_weights = initUserWeights(*m_raw_data, 1.0);
@@ -59,15 +58,12 @@ SimDataPair::SimDataPair(simulation_builder_t builder, const OutputData<double>&
 }
 
 SimDataPair::SimDataPair(SimDataPair&& other)
-    : m_simulation_builder(std::move(other.m_simulation_builder))
-    , m_simulation(std::move(other.m_simulation))
-    , m_sim_data(std::move(other.m_sim_data))
-    , m_exp_data(std::move(other.m_exp_data))
-    , m_uncertainties(std::move(other.m_uncertainties))
-    , m_user_weights(std::move(other.m_user_weights))
-    , m_raw_data(std::move(other.m_raw_data))
-    , m_raw_uncertainties(std::move(other.m_raw_uncertainties))
-    , m_raw_user_weights(std::move(other.m_raw_user_weights))
+    : m_simulation_builder(std::move(other.m_simulation_builder)),
+      m_simulation(std::move(other.m_simulation)), m_sim_data(std::move(other.m_sim_data)),
+      m_exp_data(std::move(other.m_exp_data)), m_uncertainties(std::move(other.m_uncertainties)),
+      m_user_weights(std::move(other.m_user_weights)), m_raw_data(std::move(other.m_raw_data)),
+      m_raw_uncertainties(std::move(other.m_raw_uncertainties)),
+      m_raw_user_weights(std::move(other.m_raw_user_weights))
 {
     validate();
 }
@@ -213,5 +209,5 @@ void SimDataPair::validate() const
 
     if (!m_raw_user_weights || !m_raw_user_weights->hasSameShape(*m_raw_data))
         throw std::runtime_error(
-                "Error in SimDataPair: user weights are not initialized or have invalid shape");
+            "Error in SimDataPair: user weights are not initialized or have invalid shape");
 }
diff --git a/Core/Fitting/SimDataPair.h b/Core/Fitting/SimDataPair.h
index 4e9751aae1c..652bf8461b5 100644
--- a/Core/Fitting/SimDataPair.h
+++ b/Core/Fitting/SimDataPair.h
@@ -18,7 +18,7 @@
 #include "FitTypes.h"
 #include "SimulationResult.h"
 
-template<class T> class OutputData;
+template <class T> class OutputData;
 
 //! Holds pair of simulation/experimental data to fit.
 
diff --git a/Core/HardParticle/FormFactorAnisoPyramid.cpp b/Core/HardParticle/FormFactorAnisoPyramid.cpp
index 738eed6fc35..cbab683362d 100644
--- a/Core/HardParticle/FormFactorAnisoPyramid.cpp
+++ b/Core/HardParticle/FormFactorAnisoPyramid.cpp
@@ -16,38 +16,33 @@
 #include "AnisoPyramid.h"
 #include "BornAgainNamespace.h"
 #include "Exceptions.h"
-#include "MathFunctions.h"
 #include "MathConstants.h"
+#include "MathFunctions.h"
 #include "RealParameter.h"
 
-const PolyhedralTopology FormFactorAnisoPyramid::topology = {
-    {
-        { { 3, 2, 1, 0 }, true },
-        { { 0, 1, 5, 4 }, false },
-        { { 1, 2, 6, 5 }, false },
-        { { 2, 3, 7, 6 }, false },
-        { { 3, 0, 4, 7 }, false },
-        { { 4, 5, 6, 7 }, true }
-    }, false };
+const PolyhedralTopology FormFactorAnisoPyramid::topology = {{{{3, 2, 1, 0}, true},
+                                                              {{0, 1, 5, 4}, false},
+                                                              {{1, 2, 6, 5}, false},
+                                                              {{2, 3, 7, 6}, false},
+                                                              {{3, 0, 4, 7}, false},
+                                                              {{4, 5, 6, 7}, true}},
+                                                             false};
 
 //! Constructor of a truncated pyramid with a rectangular base.
 //! @param length: length of the rectangular base in nm
 //! @param width: width of the rectangular base in nm
 //! @param height: height of pyramid in nm
 //! @param alpha: dihedral angle in radians between base and facet
-FormFactorAnisoPyramid::FormFactorAnisoPyramid(
-    double length, double width, double height, double alpha)
-    : FormFactorPolyhedron()
-    , m_length(length)
-    , m_width(width)
-    , m_height(height)
-    , m_alpha(alpha)
+FormFactorAnisoPyramid::FormFactorAnisoPyramid(double length, double width, double height,
+                                               double alpha)
+    : FormFactorPolyhedron(), m_length(length), m_width(width), m_height(height), m_alpha(alpha)
 {
     setName(BornAgain::FFAnisoPyramidType);
     registerParameter(BornAgain::Length, &m_length).setUnit(BornAgain::UnitsNm).setNonnegative();
     registerParameter(BornAgain::Width, &m_width).setUnit(BornAgain::UnitsNm).setNonnegative();
     registerParameter(BornAgain::Height, &m_height).setUnit(BornAgain::UnitsNm).setNonnegative();
-    registerParameter(BornAgain::Alpha, &m_alpha).setUnit(BornAgain::UnitsRad)
+    registerParameter(BornAgain::Alpha, &m_alpha)
+        .setUnit(BornAgain::UnitsRad)
         .setLimited(0., M_PI_2);
     onChange();
 }
@@ -56,7 +51,7 @@ IFormFactor* FormFactorAnisoPyramid::sliceFormFactor(ZLimits limits, const IRota
                                                      kvector_t translation) const
 {
     auto effects = computeSlicingEffects(limits, translation, m_height);
-    double dbase_edge = 2*effects.dz_bottom*MathFunctions::cot(m_alpha);
+    double dbase_edge = 2 * effects.dz_bottom * MathFunctions::cot(m_alpha);
     FormFactorAnisoPyramid slicedff(m_length - dbase_edge, m_width - dbase_edge,
                                     m_height - effects.dz_bottom - effects.dz_top, m_alpha);
     return CreateTransformedFormFactor(slicedff, rot, effects.position);
@@ -65,11 +60,11 @@ IFormFactor* FormFactorAnisoPyramid::sliceFormFactor(ZLimits limits, const IRota
 void FormFactorAnisoPyramid::onChange()
 {
     double cot_alpha = MathFunctions::cot(m_alpha);
-    if( !std::isfinite(cot_alpha) || cot_alpha<0 )
+    if (!std::isfinite(cot_alpha) || cot_alpha < 0)
         throw Exceptions::OutOfBoundsException("AnisoPyramid: angle alpha out of bounds");
-    double r = cot_alpha*2 * m_height / m_length;
-    double s = cot_alpha*2 * m_height / m_width;
-    if( r>1 || s>1 ) {
+    double r = cot_alpha * 2 * m_height / m_length;
+    double s = cot_alpha * 2 * m_height / m_width;
+    if (r > 1 || s > 1) {
         std::ostringstream ostr;
         ostr << "FormFactorAnisoPyramid() -> Error in class initialization with parameters";
         ostr << " length:" << m_length;
@@ -81,22 +76,23 @@ void FormFactorAnisoPyramid::onChange()
     }
     mP_shape.reset(new AnisoPyramid(m_length, m_width, m_height, m_alpha));
 
-    double D = m_length/2;
-    double d = m_length/2 * (1-r);
-    double W = m_width/2;
-    double w = m_width/2 * (1-s);
+    double D = m_length / 2;
+    double d = m_length / 2 * (1 - r);
+    double W = m_width / 2;
+    double w = m_width / 2 * (1 - s);
 
-    double zcom = m_height * ( .5 - (r+s)/3 + r*s/4 ) / ( 1 - (r+s)/2 + r*s/3 ); // center of mass
+    double zcom =
+        m_height * (.5 - (r + s) / 3 + r * s / 4) / (1 - (r + s) / 2 + r * s / 3); // center of mass
 
-    setPolyhedron( topology, -zcom, {
-        // base:
-        { -D, -W, -zcom },
-        {  D, -W, -zcom },
-        {  D,  W, -zcom },
-        { -D,  W, -zcom },
-        // top:
-        { -d, -w, m_height-zcom },
-        {  d, -w, m_height-zcom },
-        {  d,  w, m_height-zcom },
-        { -d,  w, m_height-zcom } } );
+    setPolyhedron(topology, -zcom,
+                  {// base:
+                   {-D, -W, -zcom},
+                   {D, -W, -zcom},
+                   {D, W, -zcom},
+                   {-D, W, -zcom},
+                   // top:
+                   {-d, -w, m_height - zcom},
+                   {d, -w, m_height - zcom},
+                   {d, w, m_height - zcom},
+                   {-d, w, m_height - zcom}});
 }
diff --git a/Core/HardParticle/FormFactorAnisoPyramid.h b/Core/HardParticle/FormFactorAnisoPyramid.h
index 35ac0ce1862..8f0a264e044 100644
--- a/Core/HardParticle/FormFactorAnisoPyramid.h
+++ b/Core/HardParticle/FormFactorAnisoPyramid.h
@@ -25,14 +25,16 @@ class BA_CORE_API_ FormFactorAnisoPyramid : public FormFactorPolyhedron
 public:
     FormFactorAnisoPyramid(double length, double width, double height, double alpha);
 
-    FormFactorAnisoPyramid* clone() const override final {
-        return new FormFactorAnisoPyramid(m_length, m_width, m_height, m_alpha); }
+    FormFactorAnisoPyramid* clone() const override final
+    {
+        return new FormFactorAnisoPyramid(m_length, m_width, m_height, m_alpha);
+    }
     void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     double getLength() const { return m_length; }
-    double getWidth()  const { return m_width; }
+    double getWidth() const { return m_width; }
     double getHeight() const { return m_height; }
-    double getAlpha()  const { return m_alpha; }
+    double getAlpha() const { return m_alpha; }
 
 protected:
     IFormFactor* sliceFormFactor(ZLimits limits, const IRotation& rot,
diff --git a/Core/HardParticle/FormFactorBox.cpp b/Core/HardParticle/FormFactorBox.cpp
index 75d7aa4c00a..5ea1bd8cd8e 100644
--- a/Core/HardParticle/FormFactorBox.cpp
+++ b/Core/HardParticle/FormFactorBox.cpp
@@ -27,21 +27,21 @@ FormFactorBox::FormFactorBox(double length, double width, double height)
 {
     setName(BornAgain::FFBoxType);
     registerParameter(BornAgain::Length, &m_length).setUnit(BornAgain::UnitsNm).setNonnegative();
-    registerParameter(BornAgain::Width,  &m_width).setUnit(BornAgain::UnitsNm).setNonnegative();
+    registerParameter(BornAgain::Width, &m_width).setUnit(BornAgain::UnitsNm).setNonnegative();
     registerParameter(BornAgain::Height, &m_height).setUnit(BornAgain::UnitsNm).setNonnegative();
     onChange();
 }
 
 complex_t FormFactorBox::evaluate_for_q(cvector_t q) const
 {
-    complex_t qzHdiv2 = m_height/2*q.z();
-    return m_height*m_length*m_width *
-        MathFunctions::sinc(m_length/2*q.x()) *  MathFunctions::sinc(m_width/2*q.y()) *
-            MathFunctions::sinc(qzHdiv2) * exp_I(qzHdiv2);
+    complex_t qzHdiv2 = m_height / 2 * q.z();
+    return m_height * m_length * m_width * MathFunctions::sinc(m_length / 2 * q.x())
+           * MathFunctions::sinc(m_width / 2 * q.y()) * MathFunctions::sinc(qzHdiv2)
+           * exp_I(qzHdiv2);
 }
 
 IFormFactor* FormFactorBox::sliceFormFactor(ZLimits limits, const IRotation& rot,
-                                           kvector_t translation) const
+                                            kvector_t translation) const
 {
     auto effects = computeSlicingEffects(limits, translation, m_height);
     FormFactorBox slicedff(m_length, m_width, m_height - effects.dz_bottom - effects.dz_top);
diff --git a/Core/HardParticle/FormFactorBox.h b/Core/HardParticle/FormFactorBox.h
index 4a7adfda834..de00ff51de0 100644
--- a/Core/HardParticle/FormFactorBox.h
+++ b/Core/HardParticle/FormFactorBox.h
@@ -23,10 +23,12 @@
 class BA_CORE_API_ FormFactorBox : public IFormFactorBorn
 {
 public:
-    FormFactorBox( double length, double width, double height);
+    FormFactorBox(double length, double width, double height);
 
-    FormFactorBox* clone() const override final {
-        return new FormFactorBox(m_length, m_width, m_height); }
+    FormFactorBox* clone() const override final
+    {
+        return new FormFactorBox(m_length, m_width, m_height);
+    }
 
     void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
@@ -34,7 +36,7 @@ public:
     double getHeight() const { return m_height; }
     double getWidth() const { return m_width; }
 
-    double radialExtension() const override final { return m_length/2.0; }
+    double radialExtension() const override final { return m_length / 2.0; }
 
     complex_t evaluate_for_q(cvector_t q) const override final;
 
diff --git a/Core/HardParticle/FormFactorCone.cpp b/Core/HardParticle/FormFactorCone.cpp
index c69a817df89..83726f3feab 100644
--- a/Core/HardParticle/FormFactorCone.cpp
+++ b/Core/HardParticle/FormFactorCone.cpp
@@ -16,8 +16,8 @@
 #include "BornAgainNamespace.h"
 #include "DoubleEllipse.h"
 #include "Exceptions.h"
-#include "MathFunctions.h"
 #include "MathConstants.h"
+#include "MathFunctions.h"
 #include "RealParameter.h"
 #include <limits>
 
@@ -30,9 +30,9 @@ FormFactorCone::FormFactorCone(double radius, double height, double alpha)
 {
     setName(BornAgain::FFConeType);
     m_cot_alpha = MathFunctions::cot(m_alpha);
-    if( !std::isfinite(m_cot_alpha) || m_cot_alpha<0 )
+    if (!std::isfinite(m_cot_alpha) || m_cot_alpha < 0)
         throw Exceptions::OutOfBoundsException("pyramid angle alpha out of bounds");
-    if(m_cot_alpha*m_height > m_radius) {
+    if (m_cot_alpha * m_height > m_radius) {
         std::ostringstream ostr;
         ostr << "FormFactorCone() -> Error in class initialization ";
         ostr << "with parameters radius:" << m_radius;
@@ -43,7 +43,8 @@ FormFactorCone::FormFactorCone(double radius, double height, double alpha)
     }
     registerParameter(BornAgain::Radius, &m_radius).setUnit(BornAgain::UnitsNm).setNonnegative();
     registerParameter(BornAgain::Height, &m_height).setUnit(BornAgain::UnitsNm).setNonnegative();
-    registerParameter(BornAgain::Alpha, &m_alpha).setUnit(BornAgain::UnitsRad)
+    registerParameter(BornAgain::Alpha, &m_alpha)
+        .setUnit(BornAgain::UnitsRad)
         .setLimited(0., M_PI_2);
 
     mP_integrator = make_integrator_complex(this, &FormFactorCone::Integrand);
@@ -53,33 +54,33 @@ FormFactorCone::FormFactorCone(double radius, double height, double alpha)
 //! Integrand for complex formfactor.
 complex_t FormFactorCone::Integrand(double Z) const
 {
-    double Rz = m_radius - Z*m_cot_alpha;
-    complex_t q_p = std::sqrt(m_q.x()*m_q.x()+m_q.y()*m_q.y()); // sqrt(x*x + y*y)
-    return Rz*Rz*MathFunctions::Bessel_J1c(q_p*Rz) * exp_I(m_q.z()*Z);
+    double Rz = m_radius - Z * m_cot_alpha;
+    complex_t q_p = std::sqrt(m_q.x() * m_q.x() + m_q.y() * m_q.y()); // sqrt(x*x + y*y)
+    return Rz * Rz * MathFunctions::Bessel_J1c(q_p * Rz) * exp_I(m_q.z() * Z);
 }
 
 complex_t FormFactorCone::evaluate_for_q(cvector_t q) const
 {
     m_q = q;
-    if ( std::abs(m_q.mag()) < std::numeric_limits<double>::epsilon()) {
+    if (std::abs(m_q.mag()) < std::numeric_limits<double>::epsilon()) {
         double R = m_radius;
         double H = m_height;
-        if (m_cot_alpha==0.0)
-            return M_PI*R*R*H;  // cylinder case
-        double R2 = R - H*m_cot_alpha;
-        double apex_height = R/m_cot_alpha;
-        return M_PI/3.*(R*R*H +(R*R - R2*R2)*(apex_height-H));
+        if (m_cot_alpha == 0.0)
+            return M_PI * R * R * H; // cylinder case
+        double R2 = R - H * m_cot_alpha;
+        double apex_height = R / m_cot_alpha;
+        return M_PI / 3. * (R * R * H + (R * R - R2 * R2) * (apex_height - H));
     } else {
         complex_t integral = mP_integrator->integrate(0., m_height);
-        return M_TWOPI*integral;
+        return M_TWOPI * integral;
     }
 }
 
 IFormFactor* FormFactorCone::sliceFormFactor(ZLimits limits, const IRotation& rot,
-                                            kvector_t translation) const
+                                             kvector_t translation) const
 {
     auto effects = computeSlicingEffects(limits, translation, m_height);
-    double dradius = effects.dz_bottom*m_cot_alpha;
+    double dradius = effects.dz_bottom * m_cot_alpha;
     FormFactorCone slicedff(m_radius - dradius, m_height - effects.dz_bottom - effects.dz_top,
                             m_alpha);
     return CreateTransformedFormFactor(slicedff, rot, effects.position);
@@ -88,6 +89,6 @@ IFormFactor* FormFactorCone::sliceFormFactor(ZLimits limits, const IRotation& ro
 void FormFactorCone::onChange()
 {
     m_cot_alpha = MathFunctions::cot(m_alpha);
-    double radius2 = m_radius - m_height*m_cot_alpha;
+    double radius2 = m_radius - m_height * m_cot_alpha;
     mP_shape.reset(new DoubleEllipse(m_radius, m_radius, m_height, radius2, radius2));
 }
diff --git a/Core/HardParticle/FormFactorCone.h b/Core/HardParticle/FormFactorCone.h
index 58bb2804d16..0fb384c7ae5 100644
--- a/Core/HardParticle/FormFactorCone.h
+++ b/Core/HardParticle/FormFactorCone.h
@@ -27,10 +27,12 @@ template <class T> class IntegratorComplex;
 class BA_CORE_API_ FormFactorCone : public IFormFactorBorn
 {
 public:
-    FormFactorCone(double radius, double height,  double alpha);
+    FormFactorCone(double radius, double height, double alpha);
 
-    FormFactorCone* clone() const override final {
-        return new FormFactorCone(m_radius, m_height, m_alpha); }
+    FormFactorCone* clone() const override final
+    {
+        return new FormFactorCone(m_radius, m_height, m_alpha);
+    }
     void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     double getHeight() const { return m_height; }
@@ -39,7 +41,7 @@ public:
 
     double radialExtension() const override final { return m_radius; }
 
-    complex_t evaluate_for_q (cvector_t q) const override final;
+    complex_t evaluate_for_q(cvector_t q) const override final;
 
 protected:
     IFormFactor* sliceFormFactor(ZLimits limits, const IRotation& rot,
diff --git a/Core/HardParticle/FormFactorCone6.cpp b/Core/HardParticle/FormFactorCone6.cpp
index 35bc5bd1f46..fea9204e1bd 100644
--- a/Core/HardParticle/FormFactorCone6.cpp
+++ b/Core/HardParticle/FormFactorCone6.cpp
@@ -15,48 +15,44 @@
 #include "FormFactorCone6.h"
 #include "BornAgainNamespace.h"
 #include "Exceptions.h"
-#include "MathFunctions.h"
 #include "MathConstants.h"
+#include "MathFunctions.h"
 #include "Pyramid6.h"
 #include "RealParameter.h"
 
-const PolyhedralTopology FormFactorCone6::topology = {
-    {
-        { {  5,  4,  3,  2,  1,  0 }, true },
-        { {  0,  1,  7,  6 }, false },
-        { {  1,  2,  8,  7 }, false },
-        { {  2,  3,  9,  8 }, false },
-        { {  3,  4, 10,  9 }, false },
-        { {  4,  5, 11, 10 }, false },
-        { {  5,  0,  6, 11 }, false },
-        { {  6,  7,  8,  9, 10, 11 }, true }
-    }, false };
+const PolyhedralTopology FormFactorCone6::topology = {{{{5, 4, 3, 2, 1, 0}, true},
+                                                       {{0, 1, 7, 6}, false},
+                                                       {{1, 2, 8, 7}, false},
+                                                       {{2, 3, 9, 8}, false},
+                                                       {{3, 4, 10, 9}, false},
+                                                       {{4, 5, 11, 10}, false},
+                                                       {{5, 0, 6, 11}, false},
+                                                       {{6, 7, 8, 9, 10, 11}, true}},
+                                                      false};
 
 //! Constructor of a truncated pyramid, based on a regular hexagon
 //! @param base_edge: Edge of the regular hexagonal base in nanometers
 //! @param height: height of a truncated pyramid in nanometers
 //! @param alpha: dihedral angle in radians between base and facet
 FormFactorCone6::FormFactorCone6(double base_edge, double height, double alpha)
-    : FormFactorPolyhedron()
-    , m_base_edge(base_edge)
-    , m_height(height)
-    , m_alpha(alpha)
+    : FormFactorPolyhedron(), m_base_edge(base_edge), m_height(height), m_alpha(alpha)
 {
     setName(BornAgain::FFCone6Type);
-    registerParameter(BornAgain::BaseEdge, &m_base_edge).setUnit(BornAgain::UnitsNm)
-        .setNonnegative();
-    registerParameter(BornAgain::Height, &m_height).setUnit(BornAgain::UnitsNm)
+    registerParameter(BornAgain::BaseEdge, &m_base_edge)
+        .setUnit(BornAgain::UnitsNm)
         .setNonnegative();
-    registerParameter(BornAgain::Alpha, &m_alpha).setUnit(BornAgain::UnitsRad)
+    registerParameter(BornAgain::Height, &m_height).setUnit(BornAgain::UnitsNm).setNonnegative();
+    registerParameter(BornAgain::Alpha, &m_alpha)
+        .setUnit(BornAgain::UnitsRad)
         .setLimited(0., M_PI_2);
     onChange();
 }
 
-IFormFactor*FormFactorCone6::sliceFormFactor(ZLimits limits, const IRotation& rot,
-                                             kvector_t translation) const
+IFormFactor* FormFactorCone6::sliceFormFactor(ZLimits limits, const IRotation& rot,
+                                              kvector_t translation) const
 {
     auto effects = computeSlicingEffects(limits, translation, m_height);
-    double dbase_edge = effects.dz_bottom*MathFunctions::cot(m_alpha);
+    double dbase_edge = effects.dz_bottom * MathFunctions::cot(m_alpha);
     FormFactorCone6 slicedff(m_base_edge - dbase_edge,
                              m_height - effects.dz_bottom - effects.dz_top, m_alpha);
     return CreateTransformedFormFactor(slicedff, rot, effects.position);
@@ -65,10 +61,10 @@ IFormFactor*FormFactorCone6::sliceFormFactor(ZLimits limits, const IRotation& ro
 void FormFactorCone6::onChange()
 {
     double cot_alpha = MathFunctions::cot(m_alpha);
-    if( !std::isfinite(cot_alpha) || cot_alpha<0 )
+    if (!std::isfinite(cot_alpha) || cot_alpha < 0)
         throw Exceptions::OutOfBoundsException("pyramid angle alpha out of bounds");
-    double r = cot_alpha*2/sqrt(3) * m_height / m_base_edge; // L(top)/L(base)
-    if ( r > 1 ) {
+    double r = cot_alpha * 2 / sqrt(3) * m_height / m_base_edge; // L(top)/L(base)
+    if (r > 1) {
         std::ostringstream ostr;
         ostr << "Incompatible parameters in Cone6 ";
         ostr << "(base_edge=" << m_base_edge;
@@ -79,27 +75,27 @@ void FormFactorCone6::onChange()
     mP_shape.reset(new Pyramid6(m_base_edge, m_height, m_alpha));
 
     double a = m_base_edge;
-    double as = a/2;
-    double ac = a*sqrt(3)/2;
-    double b = a * (1-r);
-    double bs = b/2;
-    double bc = b*sqrt(3)/2;
+    double as = a / 2;
+    double ac = a * sqrt(3) / 2;
+    double b = a * (1 - r);
+    double bs = b / 2;
+    double bc = b * sqrt(3) / 2;
 
-    double zcom = m_height * ( .5 - 2*r/3 + r*r/4 ) / ( 1 - r + r*r/3 ); // center of mass
+    double zcom = m_height * (.5 - 2 * r / 3 + r * r / 4) / (1 - r + r * r / 3); // center of mass
 
-    setPolyhedron( topology, -zcom, {
-        // base:
-        {  a,   0., -zcom },
-        {  as,  ac, -zcom },
-        { -as,  ac, -zcom },
-        { -a,   0., -zcom },
-        { -as, -ac, -zcom },
-        {  as, -ac, -zcom },
-        // top:
-        {  b,   0., m_height-zcom },
-        {  bs,  bc, m_height-zcom },
-        { -bs,  bc, m_height-zcom },
-        { -b,   0., m_height-zcom },
-        { -bs, -bc, m_height-zcom },
-        {  bs, -bc, m_height-zcom } } );
+    setPolyhedron(topology, -zcom,
+                  {// base:
+                   {a, 0., -zcom},
+                   {as, ac, -zcom},
+                   {-as, ac, -zcom},
+                   {-a, 0., -zcom},
+                   {-as, -ac, -zcom},
+                   {as, -ac, -zcom},
+                   // top:
+                   {b, 0., m_height - zcom},
+                   {bs, bc, m_height - zcom},
+                   {-bs, bc, m_height - zcom},
+                   {-b, 0., m_height - zcom},
+                   {-bs, -bc, m_height - zcom},
+                   {bs, -bc, m_height - zcom}});
 }
diff --git a/Core/HardParticle/FormFactorCone6.h b/Core/HardParticle/FormFactorCone6.h
index f4a3c7abd4e..9cac5b0627b 100644
--- a/Core/HardParticle/FormFactorCone6.h
+++ b/Core/HardParticle/FormFactorCone6.h
@@ -23,11 +23,13 @@
 class BA_CORE_API_ FormFactorCone6 : public FormFactorPolyhedron
 {
 public:
-    FormFactorCone6(double base_edge, double height,  double alpha);
+    FormFactorCone6(double base_edge, double height, double alpha);
 
-    FormFactorCone6* clone() const override final {
-        return new FormFactorCone6(m_base_edge, m_height, m_alpha); }
-    void accept(INodeVisitor *visitor) const override final { visitor->visit(this); }
+    FormFactorCone6* clone() const override final
+    {
+        return new FormFactorCone6(m_base_edge, m_height, m_alpha);
+    }
+    void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     double getBaseEdge() const { return m_base_edge; }
     double getHeight() const { return m_height; }
diff --git a/Core/HardParticle/FormFactorCuboctahedron.cpp b/Core/HardParticle/FormFactorCuboctahedron.cpp
index 2514fef53bc..3b5d68a6e26 100644
--- a/Core/HardParticle/FormFactorCuboctahedron.cpp
+++ b/Core/HardParticle/FormFactorCuboctahedron.cpp
@@ -17,23 +17,21 @@
 #include "BornAgainNamespace.h"
 #include "Exceptions.h"
 #include "FormFactorPyramid.h"
-#include "MathFunctions.h"
 #include "MathConstants.h"
+#include "MathFunctions.h"
 #include "RealParameter.h"
 
-const PolyhedralTopology FormFactorCuboctahedron::topology = {
-    {
-        { {  3,  2,  1,  0 }, true  },
-        { {  0,  1,  5,  4 }, false },
-        { {  1,  2,  6,  5 }, false },
-        { {  2,  3,  7,  6 }, false },
-        { {  3,  0,  4,  7 }, false },
-        { {  4,  5,  9,  8 }, false },
-        { {  5,  6, 10,  9 }, false },
-        { {  6,  7, 11, 10 }, false },
-        { {  7,  4,  8, 11 }, false },
-        { {  8,  9, 10, 11 }, true  }
-    }, false };
+const PolyhedralTopology FormFactorCuboctahedron::topology = {{{{3, 2, 1, 0}, true},
+                                                               {{0, 1, 5, 4}, false},
+                                                               {{1, 2, 6, 5}, false},
+                                                               {{2, 3, 7, 6}, false},
+                                                               {{3, 0, 4, 7}, false},
+                                                               {{4, 5, 9, 8}, false},
+                                                               {{5, 6, 10, 9}, false},
+                                                               {{6, 7, 11, 10}, false},
+                                                               {{7, 4, 8, 11}, false},
+                                                               {{8, 9, 10, 11}, true}},
+                                                              false};
 
 //! Constructor of cuboctahedron (compound of two truncated pyramids with a common square base
 //! and opposite orientations).
@@ -41,22 +39,19 @@ const PolyhedralTopology FormFactorCuboctahedron::topology = {
 //! @param height: height of the lower pyramid in nanometers
 //! @param height_ratio: ratio of heights of top to bottom pyramids
 //! @param alpha: dihedral angle in radians between base and facet
-FormFactorCuboctahedron::FormFactorCuboctahedron(
-    double length, double height, double height_ratio, double alpha)
-    : FormFactorPolyhedron()
-    , m_length(length)
-    , m_height(height)
-    , m_height_ratio(height_ratio)
-    , m_alpha(alpha)
+FormFactorCuboctahedron::FormFactorCuboctahedron(double length, double height, double height_ratio,
+                                                 double alpha)
+    : FormFactorPolyhedron(), m_length(length), m_height(height), m_height_ratio(height_ratio),
+      m_alpha(alpha)
 {
     setName(BornAgain::FFCuboctahedronType);
-    registerParameter(BornAgain::Length, &m_length).setUnit(BornAgain::UnitsNm)
-        .setNonnegative();
-    registerParameter(BornAgain::Height, &m_height).setUnit(BornAgain::UnitsNm)
-        .setNonnegative();
-    registerParameter(BornAgain::HeightRatio, &m_height_ratio).setUnit(BornAgain::UnitsNm)
+    registerParameter(BornAgain::Length, &m_length).setUnit(BornAgain::UnitsNm).setNonnegative();
+    registerParameter(BornAgain::Height, &m_height).setUnit(BornAgain::UnitsNm).setNonnegative();
+    registerParameter(BornAgain::HeightRatio, &m_height_ratio)
+        .setUnit(BornAgain::UnitsNm)
         .setNonnegative();
-    registerParameter(BornAgain::Alpha, &m_alpha).setUnit(BornAgain::UnitsRad)
+    registerParameter(BornAgain::Alpha, &m_alpha)
+        .setUnit(BornAgain::UnitsRad)
         .setLimited(0., M_PI_2);
     onChange();
 }
@@ -64,20 +59,22 @@ FormFactorCuboctahedron::FormFactorCuboctahedron(
 IFormFactor* FormFactorCuboctahedron::sliceFormFactor(ZLimits limits, const IRotation& rot,
                                                       kvector_t translation) const
 {
-    auto effects = computeSlicingEffects(limits, translation, m_height*(1+m_height_ratio));
-    if (effects.dz_bottom>m_height) {
-        double dbase_edge = 2*(effects.dz_bottom-m_height)*MathFunctions::cot(m_alpha);
-        FormFactorPyramid slicedff(m_length - dbase_edge, m_height*(1+m_height_ratio)
-                                   - effects.dz_bottom - effects.dz_top, m_alpha);
+    auto effects = computeSlicingEffects(limits, translation, m_height * (1 + m_height_ratio));
+    if (effects.dz_bottom > m_height) {
+        double dbase_edge = 2 * (effects.dz_bottom - m_height) * MathFunctions::cot(m_alpha);
+        FormFactorPyramid slicedff(
+            m_length - dbase_edge,
+            m_height * (1 + m_height_ratio) - effects.dz_bottom - effects.dz_top, m_alpha);
         return CreateTransformedFormFactor(slicedff, rot, effects.position);
-    } else if (effects.dz_top>m_height_ratio*m_height) {
-        double dbase_edge = 2*(m_height-effects.dz_bottom)*MathFunctions::cot(m_alpha);
-        FormFactorPyramid slicedff(m_length - dbase_edge, m_height*(1+m_height_ratio)
-                                   - effects.dz_bottom - effects.dz_top, M_PI - m_alpha);
+    } else if (effects.dz_top > m_height_ratio * m_height) {
+        double dbase_edge = 2 * (m_height - effects.dz_bottom) * MathFunctions::cot(m_alpha);
+        FormFactorPyramid slicedff(
+            m_length - dbase_edge,
+            m_height * (1 + m_height_ratio) - effects.dz_bottom - effects.dz_top, M_PI - m_alpha);
         return CreateTransformedFormFactor(slicedff, rot, effects.position);
     } else {
         FormFactorCuboctahedron slicedff(m_length, m_height - effects.dz_bottom,
-                                         m_height_ratio*m_height - effects.dz_top, m_alpha);
+                                         m_height_ratio * m_height - effects.dz_top, m_alpha);
         return CreateTransformedFormFactor(slicedff, rot, effects.position);
     }
 }
@@ -85,11 +82,11 @@ IFormFactor* FormFactorCuboctahedron::sliceFormFactor(ZLimits limits, const IRot
 void FormFactorCuboctahedron::onChange()
 {
     double cot_alpha = MathFunctions::cot(m_alpha);
-    if( !std::isfinite(cot_alpha) || cot_alpha<0 )
+    if (!std::isfinite(cot_alpha) || cot_alpha < 0)
         throw Exceptions::OutOfBoundsException("pyramid angle alpha out of bounds");
     double x = m_height_ratio;
-    double r = cot_alpha*2 * m_height / m_length;
-    if ( std::max(1.,x)*r > 1 ) {
+    double r = cot_alpha * 2 * m_height / m_length;
+    if (std::max(1., x) * r > 1) {
         std::ostringstream ostr;
         ostr << "FormFactorCuboctahedron() -> Error in class initialization with parameters";
         ostr << " height:" << m_height;
@@ -101,31 +98,31 @@ void FormFactorCuboctahedron::onChange()
     }
     mP_shape.reset(new BiPyramid(m_length, m_height, m_height_ratio, m_alpha));
 
-    double a = m_length/2 * (1-r);
-    double b = m_length/2;
-    double c = m_length/2 * (1-r*x);
+    double a = m_length / 2 * (1 - r);
+    double b = m_length / 2;
+    double c = m_length / 2 * (1 - r * x);
 
-    double dzcom = m_height *
-        ( (x*x-1)/2 - 2*r*(x*x*x-1)/3 + r*r*(x*x*x*x-1)/4 ) /
-        ( (x  +1)   -   r*(x*x  +1)   + r*r*(x*x*x  +1)/3 );
-    double za = -dzcom-m_height;
+    double dzcom =
+        m_height * ((x * x - 1) / 2 - 2 * r * (x * x * x - 1) / 3 + r * r * (x * x * x * x - 1) / 4)
+        / ((x + 1) - r * (x * x + 1) + r * r * (x * x * x + 1) / 3);
+    double za = -dzcom - m_height;
     double zb = -dzcom;
-    double zc = -dzcom+x*m_height;
+    double zc = -dzcom + x * m_height;
 
-    setPolyhedron( topology, za, {
-            // base:
-            { -a, -a, za },
-            {  a, -a, za },
-            {  a,  a, za },
-            { -a,  a, za },
-            // middle
-            { -b, -b, zb },
-            {  b, -b, zb },
-            {  b,  b, zb },
-            { -b,  b, zb },
-            // top
-            { -c, -c, zc },
-            {  c, -c, zc },
-            {  c,  c, zc },
-            { -c,  c, zc } } );
+    setPolyhedron(topology, za,
+                  {// base:
+                   {-a, -a, za},
+                   {a, -a, za},
+                   {a, a, za},
+                   {-a, a, za},
+                   // middle
+                   {-b, -b, zb},
+                   {b, -b, zb},
+                   {b, b, zb},
+                   {-b, b, zb},
+                   // top
+                   {-c, -c, zc},
+                   {c, -c, zc},
+                   {c, c, zc},
+                   {-c, c, zc}});
 }
diff --git a/Core/HardParticle/FormFactorCuboctahedron.h b/Core/HardParticle/FormFactorCuboctahedron.h
index 5c46b3700b3..9a93bc14203 100644
--- a/Core/HardParticle/FormFactorCuboctahedron.h
+++ b/Core/HardParticle/FormFactorCuboctahedron.h
@@ -25,9 +25,11 @@ class BA_CORE_API_ FormFactorCuboctahedron : public FormFactorPolyhedron
 public:
     FormFactorCuboctahedron(double length, double height, double height_ratio, double alpha);
 
-    FormFactorCuboctahedron *clone() const override final {
-        return new FormFactorCuboctahedron(m_length, m_height, m_height_ratio, m_alpha); }
-    void accept(INodeVisitor *visitor) const override final { visitor->visit(this); }
+    FormFactorCuboctahedron* clone() const override final
+    {
+        return new FormFactorCuboctahedron(m_length, m_height, m_height_ratio, m_alpha);
+    }
+    void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     double getLength() const { return m_length; }
     double getHeight() const { return m_height; }
diff --git a/Core/HardParticle/FormFactorCylinder.cpp b/Core/HardParticle/FormFactorCylinder.cpp
index 0de0290b62e..85f4b5f9169 100644
--- a/Core/HardParticle/FormFactorCylinder.cpp
+++ b/Core/HardParticle/FormFactorCylinder.cpp
@@ -15,8 +15,8 @@
 #include "FormFactorCylinder.h"
 #include "BornAgainNamespace.h"
 #include "DoubleEllipse.h"
-#include "MathFunctions.h"
 #include "MathConstants.h"
+#include "MathFunctions.h"
 #include "RealParameter.h"
 
 //! Constructor of a cylinder with a circular base.
diff --git a/Core/HardParticle/FormFactorCylinder.h b/Core/HardParticle/FormFactorCylinder.h
index 109fd360269..2831e80223f 100644
--- a/Core/HardParticle/FormFactorCylinder.h
+++ b/Core/HardParticle/FormFactorCylinder.h
@@ -25,8 +25,10 @@ class BA_CORE_API_ FormFactorCylinder : public IFormFactorBorn
 public:
     FormFactorCylinder(double radius, double height);
 
-    FormFactorCylinder* clone() const override final {
-        return new FormFactorCylinder(m_radius, m_height); }
+    FormFactorCylinder* clone() const override final
+    {
+        return new FormFactorCylinder(m_radius, m_height);
+    }
     void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     double getHeight() const { return m_height; }
diff --git a/Core/HardParticle/FormFactorDodecahedron.cpp b/Core/HardParticle/FormFactorDodecahedron.cpp
index 9fe39017403..37f0aa76f11 100644
--- a/Core/HardParticle/FormFactorDodecahedron.cpp
+++ b/Core/HardParticle/FormFactorDodecahedron.cpp
@@ -17,32 +17,27 @@
 #include "Dodecahedron.h"
 #include "RealParameter.h"
 
-const PolyhedralTopology FormFactorDodecahedron::topology = {
-    {
-        // bottom:
-        { {  0,  4,  3,  2,  1 }, false },
-        // lower ring:
-        { {  0,  5, 12,  9,  4 }, false },
-        { {  4,  9, 11,  8,  3 }, false },
-        { {  3,  8, 10,  7,  2 }, false },
-        { {  2,  7, 14,  6,  1 }, false },
-        { {  1,  6, 13,  5,  0 }, false },
-        // upper ring:
-        { {  8, 11, 16, 15, 10 }, false },
-        { {  9, 12, 17, 16, 11 }, false },
-        { {  5, 13, 18, 17, 12 }, false },
-        { {  6, 14, 19, 18, 13 }, false },
-        { {  7, 10, 15, 19, 14 }, false },
-        // top:
-        { { 15, 16, 17, 18, 19 }, false }
-    }, true };
-
+const PolyhedralTopology FormFactorDodecahedron::topology = {{// bottom:
+                                                              {{0, 4, 3, 2, 1}, false},
+                                                              // lower ring:
+                                                              {{0, 5, 12, 9, 4}, false},
+                                                              {{4, 9, 11, 8, 3}, false},
+                                                              {{3, 8, 10, 7, 2}, false},
+                                                              {{2, 7, 14, 6, 1}, false},
+                                                              {{1, 6, 13, 5, 0}, false},
+                                                              // upper ring:
+                                                              {{8, 11, 16, 15, 10}, false},
+                                                              {{9, 12, 17, 16, 11}, false},
+                                                              {{5, 13, 18, 17, 12}, false},
+                                                              {{6, 14, 19, 18, 13}, false},
+                                                              {{7, 10, 15, 19, 14}, false},
+                                                              // top:
+                                                              {{15, 16, 17, 18, 19}, false}},
+                                                             true};
 
 //! Constructor of a dodecahedron.
 //! @param edge: length of the edge in nanometers
-FormFactorDodecahedron::FormFactorDodecahedron(double edge)
-    : FormFactorPolyhedron()
-    , m_edge(edge)
+FormFactorDodecahedron::FormFactorDodecahedron(double edge) : FormFactorPolyhedron(), m_edge(edge)
 {
     setName(BornAgain::FFDodecahedronType);
     registerParameter(BornAgain::Edge, &m_edge).setUnit(BornAgain::UnitsNm).setNonnegative();
@@ -53,26 +48,26 @@ void FormFactorDodecahedron::onChange()
 {
     mP_shape.reset(new Dodecahedron(m_edge));
     double a = m_edge;
-    setPolyhedron( topology, -1.113516364411607*a, {
-        {  0.8506508083520399*a,                   0*a,  -1.113516364411607*a},
-        {  0.2628655560595668*a,  0.8090169943749473*a,  -1.113516364411607*a},
-        { -0.6881909602355868*a,                 0.5*a,  -1.113516364411607*a},
-        { -0.6881909602355868*a,                -0.5*a,  -1.113516364411607*a},
-        {  0.2628655560595668*a, -0.8090169943749473*a,  -1.113516364411607*a},
-        {   1.376381920471174*a,                   0*a, -0.2628655560595667*a},
-        {    0.42532540417602*a,   1.309016994374947*a, -0.2628655560595667*a},
-        {  -1.113516364411607*a,  0.8090169943749475*a, -0.2628655560595667*a},
-        {  -1.113516364411607*a, -0.8090169943749475*a, -0.2628655560595667*a},
-        {    0.42532540417602*a,  -1.309016994374947*a, -0.2628655560595667*a},
-        {  -1.376381920471174*a,                   0*a,  0.2628655560595667*a},
-        {   -0.42532540417602*a,  -1.309016994374947*a,  0.2628655560595667*a},
-        {   1.113516364411607*a, -0.8090169943749475*a,  0.2628655560595667*a},
-        {   1.113516364411607*a,  0.8090169943749475*a,  0.2628655560595667*a},
-        {   -0.42532540417602*a,   1.309016994374947*a,  0.2628655560595667*a},
-        { -0.8506508083520399*a,                   0*a,   1.113516364411607*a},
-        { -0.2628655560595668*a, -0.8090169943749473*a,   1.113516364411607*a},
-        {  0.6881909602355868*a,                -0.5*a,   1.113516364411607*a},
-        {  0.6881909602355868*a,                 0.5*a,   1.113516364411607*a},
-        { -0.2628655560595668*a,  0.8090169943749473*a,   1.113516364411607*a} } );
+    setPolyhedron(topology, -1.113516364411607 * a,
+                  {{0.8506508083520399 * a, 0 * a, -1.113516364411607 * a},
+                   {0.2628655560595668 * a, 0.8090169943749473 * a, -1.113516364411607 * a},
+                   {-0.6881909602355868 * a, 0.5 * a, -1.113516364411607 * a},
+                   {-0.6881909602355868 * a, -0.5 * a, -1.113516364411607 * a},
+                   {0.2628655560595668 * a, -0.8090169943749473 * a, -1.113516364411607 * a},
+                   {1.376381920471174 * a, 0 * a, -0.2628655560595667 * a},
+                   {0.42532540417602 * a, 1.309016994374947 * a, -0.2628655560595667 * a},
+                   {-1.113516364411607 * a, 0.8090169943749475 * a, -0.2628655560595667 * a},
+                   {-1.113516364411607 * a, -0.8090169943749475 * a, -0.2628655560595667 * a},
+                   {0.42532540417602 * a, -1.309016994374947 * a, -0.2628655560595667 * a},
+                   {-1.376381920471174 * a, 0 * a, 0.2628655560595667 * a},
+                   {-0.42532540417602 * a, -1.309016994374947 * a, 0.2628655560595667 * a},
+                   {1.113516364411607 * a, -0.8090169943749475 * a, 0.2628655560595667 * a},
+                   {1.113516364411607 * a, 0.8090169943749475 * a, 0.2628655560595667 * a},
+                   {-0.42532540417602 * a, 1.309016994374947 * a, 0.2628655560595667 * a},
+                   {-0.8506508083520399 * a, 0 * a, 1.113516364411607 * a},
+                   {-0.2628655560595668 * a, -0.8090169943749473 * a, 1.113516364411607 * a},
+                   {0.6881909602355868 * a, -0.5 * a, 1.113516364411607 * a},
+                   {0.6881909602355868 * a, 0.5 * a, 1.113516364411607 * a},
+                   {-0.2628655560595668 * a, 0.8090169943749473 * a, 1.113516364411607 * a}});
     assert_platonic();
 }
diff --git a/Core/HardParticle/FormFactorDodecahedron.h b/Core/HardParticle/FormFactorDodecahedron.h
index 3524df76596..597836e9431 100644
--- a/Core/HardParticle/FormFactorDodecahedron.h
+++ b/Core/HardParticle/FormFactorDodecahedron.h
@@ -27,9 +27,11 @@ public:
     //! @param edge length
     FormFactorDodecahedron(double edge);
 
-    FormFactorDodecahedron *clone() const override final {
-        return new FormFactorDodecahedron(m_edge); }
-    void accept(INodeVisitor *visitor) const override final { visitor->visit(this); }
+    FormFactorDodecahedron* clone() const override final
+    {
+        return new FormFactorDodecahedron(m_edge);
+    }
+    void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     double getEdge() const { return m_edge; }
 
diff --git a/Core/HardParticle/FormFactorDot.cpp b/Core/HardParticle/FormFactorDot.cpp
index 4c50b1c88ab..e3b29867788 100644
--- a/Core/HardParticle/FormFactorDot.cpp
+++ b/Core/HardParticle/FormFactorDot.cpp
@@ -17,7 +17,6 @@
 #include "Dot.h"
 #include "RealParameter.h"
 
-
 FormFactorDot::FormFactorDot()
 {
     setName(BornAgain::FFDotType);
@@ -26,8 +25,9 @@ FormFactorDot::FormFactorDot()
 
 IFormFactor* FormFactorDot::sliceFormFactor(ZLimits, const IRotation&, kvector_t) const
 {
-    throw std::runtime_error(getName() + "::sliceFormFactor error: "
-                             "this shape should never be sliced!");
+    throw std::runtime_error(getName()
+                             + "::sliceFormFactor error: "
+                               "this shape should never be sliced!");
 }
 
 void FormFactorDot::onChange()
diff --git a/Core/HardParticle/FormFactorEllipsoidalCylinder.cpp b/Core/HardParticle/FormFactorEllipsoidalCylinder.cpp
index 3afe0da0e4f..9079d4befec 100644
--- a/Core/HardParticle/FormFactorEllipsoidalCylinder.cpp
+++ b/Core/HardParticle/FormFactorEllipsoidalCylinder.cpp
@@ -15,44 +15,41 @@
 #include "FormFactorEllipsoidalCylinder.h"
 #include "BornAgainNamespace.h"
 #include "DoubleEllipse.h"
-#include "MathFunctions.h"
 #include "MathConstants.h"
+#include "MathFunctions.h"
 #include "RealParameter.h"
 
 //! Constructor of a cylinder with an ellipse cross section.
 //! @param radius_x: radius of the ellipse base in the x-direction, in nanometers
 //! @param radius_y: radius of the ellipse base in the y-direction, in nanometers
 //! @param height: height of the ellipsoidal cylinder in nanometers
-FormFactorEllipsoidalCylinder::FormFactorEllipsoidalCylinder(
-    double radius_x, double radius_y, double height)
+FormFactorEllipsoidalCylinder::FormFactorEllipsoidalCylinder(double radius_x, double radius_y,
+                                                             double height)
     : m_radius_x(radius_x), m_radius_y(radius_y), m_height(height)
 {
     setName(BornAgain::FFEllipsoidalCylinderType);
-    registerParameter(BornAgain::RadiusX, &m_radius_x).setUnit(BornAgain::UnitsNm)
-        .setNonnegative();
-    registerParameter(BornAgain::RadiusY, & m_radius_y).setUnit(BornAgain::UnitsNm)
-        .setNonnegative();
-    registerParameter(BornAgain::Height, &m_height).setUnit(BornAgain::UnitsNm)
-        .setNonnegative();
+    registerParameter(BornAgain::RadiusX, &m_radius_x).setUnit(BornAgain::UnitsNm).setNonnegative();
+    registerParameter(BornAgain::RadiusY, &m_radius_y).setUnit(BornAgain::UnitsNm).setNonnegative();
+    registerParameter(BornAgain::Height, &m_height).setUnit(BornAgain::UnitsNm).setNonnegative();
     onChange();
 }
 
 double FormFactorEllipsoidalCylinder::radialExtension() const
 {
-    return ( m_radius_x + m_radius_y ) / 2.0;
+    return (m_radius_x + m_radius_y) / 2.0;
 }
 
 complex_t FormFactorEllipsoidalCylinder::evaluate_for_q(cvector_t q) const
 {
-    complex_t qxRa = q.x()*m_radius_x;
-    complex_t qyRb = q.y()*m_radius_y;
-    complex_t qzHdiv2 = m_height/2*q.z();
+    complex_t qxRa = q.x() * m_radius_x;
+    complex_t qyRb = q.y() * m_radius_y;
+    complex_t qzHdiv2 = m_height / 2 * q.z();
 
     complex_t Fz = exp_I(qzHdiv2) * MathFunctions::sinc(qzHdiv2);
-    complex_t gamma  = std::sqrt((qxRa)*(qxRa) + (qyRb)*(qyRb));
+    complex_t gamma = std::sqrt((qxRa) * (qxRa) + (qyRb) * (qyRb));
     complex_t J1_gamma_div_gamma = MathFunctions::Bessel_J1c(gamma);
 
-    return M_TWOPI *m_radius_x*m_radius_y*m_height * Fz*J1_gamma_div_gamma;
+    return M_TWOPI * m_radius_x * m_radius_y * m_height * Fz * J1_gamma_div_gamma;
 }
 
 IFormFactor* FormFactorEllipsoidalCylinder::sliceFormFactor(ZLimits limits, const IRotation& rot,
diff --git a/Core/HardParticle/FormFactorEllipsoidalCylinder.h b/Core/HardParticle/FormFactorEllipsoidalCylinder.h
index 2b167f9101f..f572be11ef0 100644
--- a/Core/HardParticle/FormFactorEllipsoidalCylinder.h
+++ b/Core/HardParticle/FormFactorEllipsoidalCylinder.h
@@ -25,8 +25,10 @@ class BA_CORE_API_ FormFactorEllipsoidalCylinder : public IFormFactorBorn
 public:
     FormFactorEllipsoidalCylinder(double radius_x, double radius_y, double height);
 
-    FormFactorEllipsoidalCylinder* clone() const override final {
-        return new FormFactorEllipsoidalCylinder(m_radius_x, m_radius_y, m_height); }
+    FormFactorEllipsoidalCylinder* clone() const override final
+    {
+        return new FormFactorEllipsoidalCylinder(m_radius_x, m_radius_y, m_height);
+    }
     void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     double getRadiusX() const { return m_radius_x; }
diff --git a/Core/HardParticle/FormFactorFullSphere.cpp b/Core/HardParticle/FormFactorFullSphere.cpp
index d0af46dd0df..e908943c71e 100644
--- a/Core/HardParticle/FormFactorFullSphere.cpp
+++ b/Core/HardParticle/FormFactorFullSphere.cpp
@@ -13,9 +13,9 @@
 // ************************************************************************** //
 
 #include "FormFactorFullSphere.h"
+#include "BornAgainNamespace.h"
 #include "FormFactorTruncatedSphere.h"
 #include "FormFactorWeighted.h"
-#include "BornAgainNamespace.h"
 #include "MathConstants.h"
 #include "RealParameter.h"
 #include "Rotations.h"
@@ -52,23 +52,23 @@ double FormFactorFullSphere::topZ(const IRotation& rotation) const
 complex_t FormFactorFullSphere::evaluate_for_q(cvector_t q) const
 {
     double R = m_radius;
-    complex_t q1 = sqrt( q.x()*q.x() + q.y()*q.y() + q.z()*q.z() ); // NO sesquilinear dot product!
-    complex_t qR = q1*R;
+    complex_t q1 =
+        sqrt(q.x() * q.x() + q.y() * q.y() + q.z() * q.z()); // NO sesquilinear dot product!
+    complex_t qR = q1 * R;
 
     complex_t ret;
     if (std::abs(qR) < 1e-4) { // relative error is O(qR^4) with small prefactor
 #ifdef POLYHEDRAL_DIAGNOSTIC
-        diagnosis = { 0, 1 };
+        diagnosis = {0, 1};
 #endif
-        ret = 4*M_PI/3*pow(R,3) * ( 1. - 0.1*pow(qR,2) );
-    }
-    else {
+        ret = 4 * M_PI / 3 * pow(R, 3) * (1. - 0.1 * pow(qR, 2));
+    } else {
 #ifdef POLYHEDRAL_DIAGNOSTIC
-        diagnosis = { 0, 0 };
+        diagnosis = {0, 0};
 #endif
-        ret = 4*M_PI*pow(q1,-3)*(sin(qR) - qR*cos(qR));
+        ret = 4 * M_PI * pow(q1, -3) * (sin(qR) - qR * cos(qR));
     }
-    auto prefactor = m_position_at_center ? 1.0 : exp_I(q.z()*R);
+    auto prefactor = m_position_at_center ? 1.0 : exp_I(q.z() * R);
     return prefactor * ret;
 }
 
@@ -76,12 +76,12 @@ IFormFactor* FormFactorFullSphere::sliceFormFactor(ZLimits limits, const IRotati
                                                    kvector_t translation) const
 {
     kvector_t center(0.0, 0.0, m_radius);
-    kvector_t rotation_offset = m_position_at_center ? kvector_t(0.0, 0.0, 0.0)
-                                                     : rot.getTransform3D().transformed(center)
-                                                       - center;
+    kvector_t rotation_offset = m_position_at_center
+                                    ? kvector_t(0.0, 0.0, 0.0)
+                                    : rot.getTransform3D().transformed(center) - center;
     kvector_t new_translation = translation + rotation_offset;
     std::unique_ptr<IRotation> P_identity(IRotation::createIdentity());
-    double height = 2.0*m_radius;
+    double height = 2.0 * m_radius;
     auto effects = computeSlicingEffects(limits, new_translation, height);
     FormFactorTruncatedSphere slicedff(m_radius, height - effects.dz_bottom, effects.dz_top);
     return CreateTransformedFormFactor(slicedff, *P_identity, effects.position);
diff --git a/Core/HardParticle/FormFactorFullSphere.h b/Core/HardParticle/FormFactorFullSphere.h
index 848ad735cc6..fba565b2936 100644
--- a/Core/HardParticle/FormFactorFullSphere.h
+++ b/Core/HardParticle/FormFactorFullSphere.h
@@ -23,10 +23,12 @@
 class BA_CORE_API_ FormFactorFullSphere : public IFormFactorBorn
 {
 public:
-    FormFactorFullSphere(double radius, bool position_at_center=false);
+    FormFactorFullSphere(double radius, bool position_at_center = false);
 
-    FormFactorFullSphere* clone() const override final {
-        return new FormFactorFullSphere(m_radius, m_position_at_center); }
+    FormFactorFullSphere* clone() const override final
+    {
+        return new FormFactorFullSphere(m_radius, m_position_at_center);
+    }
     void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     double getRadius() const { return m_radius; }
diff --git a/Core/HardParticle/FormFactorFullSpheroid.cpp b/Core/HardParticle/FormFactorFullSpheroid.cpp
index 2395b9d034a..bcbca83ff1b 100644
--- a/Core/HardParticle/FormFactorFullSpheroid.cpp
+++ b/Core/HardParticle/FormFactorFullSpheroid.cpp
@@ -15,8 +15,8 @@
 #include "FormFactorFullSpheroid.h"
 #include "BornAgainNamespace.h"
 #include "FormFactorTruncatedSpheroid.h"
-#include "MathFunctions.h"
 #include "MathConstants.h"
+#include "MathFunctions.h"
 #include "RealParameter.h"
 #include "TruncatedEllipsoid.h"
 #include <limits>
@@ -24,7 +24,7 @@
 //! Constructor of full spheroid.
 //! @param radius: radius of the circular cross section in nanometers
 //! @param height: height of the full spheroid in nanometers
-FormFactorFullSpheroid::FormFactorFullSpheroid(double radius, double height )
+FormFactorFullSpheroid::FormFactorFullSpheroid(double radius, double height)
     : m_radius(radius), m_height(height)
 {
     setName(BornAgain::FFFullSpheroidType);
@@ -40,12 +40,12 @@ complex_t FormFactorFullSpheroid::Integrand(double Z) const
     double R = m_radius;
     double H = m_height;
 
-    double Rz  = R*std::sqrt(1-4.0*Z*Z/(H*H));
-    complex_t qxy = std::sqrt(m_q.x()*m_q.x()+m_q.y()*m_q.y());
-    complex_t qrRz = qxy*Rz;
+    double Rz = R * std::sqrt(1 - 4.0 * Z * Z / (H * H));
+    complex_t qxy = std::sqrt(m_q.x() * m_q.x() + m_q.y() * m_q.y());
+    complex_t qrRz = qxy * Rz;
     complex_t J1_qrRz_div_qrRz = MathFunctions::Bessel_J1c(qrRz);
 
-    return Rz*Rz* J1_qrRz_div_qrRz *std::cos(m_q.z()*Z);
+    return Rz * Rz * J1_qrRz_div_qrRz * std::cos(m_q.z() * Z);
 }
 
 complex_t FormFactorFullSpheroid::evaluate_for_q(cvector_t q) const
@@ -55,22 +55,22 @@ complex_t FormFactorFullSpheroid::evaluate_for_q(cvector_t q) const
     m_q = q;
 
     if (std::abs(m_q.mag()) <= std::numeric_limits<double>::epsilon())
-        return M_TWOPI*R*R*H/3.;
-    complex_t qzH_half = H/2*q.z();
-    return 4 * M_PI * mP_integrator->integrate(0.0, H/2.0) * exp_I(qzH_half);
+        return M_TWOPI * R * R * H / 3.;
+    complex_t qzH_half = H / 2 * q.z();
+    return 4 * M_PI * mP_integrator->integrate(0.0, H / 2.0) * exp_I(qzH_half);
 }
 
-IFormFactor*FormFactorFullSpheroid:: sliceFormFactor(ZLimits limits, const IRotation& rot,
+IFormFactor* FormFactorFullSpheroid::sliceFormFactor(ZLimits limits, const IRotation& rot,
                                                      kvector_t translation) const
 {
-    double flattening = m_height/(2.0*m_radius);
+    double flattening = m_height / (2.0 * m_radius);
     auto effects = computeSlicingEffects(limits, translation, m_height);
-    FormFactorTruncatedSpheroid slicedff(m_radius, m_height - effects.dz_bottom,
-                                         flattening, effects.dz_top);
+    FormFactorTruncatedSpheroid slicedff(m_radius, m_height - effects.dz_bottom, flattening,
+                                         effects.dz_top);
     return CreateTransformedFormFactor(slicedff, rot, effects.position);
 }
 
 void FormFactorFullSpheroid::onChange()
 {
-    mP_shape.reset(new TruncatedEllipsoid(m_radius, m_radius, m_height/2.0, m_height, 0.0));
+    mP_shape.reset(new TruncatedEllipsoid(m_radius, m_radius, m_height / 2.0, m_height, 0.0));
 }
diff --git a/Core/HardParticle/FormFactorFullSpheroid.h b/Core/HardParticle/FormFactorFullSpheroid.h
index cc95429da22..300dc619684 100644
--- a/Core/HardParticle/FormFactorFullSpheroid.h
+++ b/Core/HardParticle/FormFactorFullSpheroid.h
@@ -26,8 +26,10 @@ class BA_CORE_API_ FormFactorFullSpheroid : public IFormFactorBorn
 public:
     FormFactorFullSpheroid(double radius, double height);
 
-    FormFactorFullSpheroid* clone() const override final {
-        return new FormFactorFullSpheroid(m_radius, m_height); }
+    FormFactorFullSpheroid* clone() const override final
+    {
+        return new FormFactorFullSpheroid(m_radius, m_height);
+    }
     void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     double getHeight() const { return m_height; }
diff --git a/Core/HardParticle/FormFactorHemiEllipsoid.cpp b/Core/HardParticle/FormFactorHemiEllipsoid.cpp
index 477d77a7726..4335bec97f2 100644
--- a/Core/HardParticle/FormFactorHemiEllipsoid.cpp
+++ b/Core/HardParticle/FormFactorHemiEllipsoid.cpp
@@ -14,8 +14,8 @@
 
 #include "FormFactorHemiEllipsoid.h"
 #include "BornAgainNamespace.h"
-#include "MathFunctions.h"
 #include "MathConstants.h"
+#include "MathFunctions.h"
 #include "RealParameter.h"
 #include "TruncatedEllipsoid.h"
 #include <limits>
@@ -28,19 +28,16 @@ FormFactorHemiEllipsoid::FormFactorHemiEllipsoid(double radius_x, double radius_
     : m_radius_x(radius_x), m_radius_y(radius_y), m_height(height)
 {
     setName(BornAgain::FFHemiEllipsoidType);
-    registerParameter(BornAgain::RadiusX, &m_radius_x).setUnit(BornAgain::UnitsNm)
-        .setNonnegative();
-    registerParameter(BornAgain::RadiusY, & m_radius_y).setUnit(BornAgain::UnitsNm)
-        .setNonnegative();
-    registerParameter(BornAgain::Height, &m_height).setUnit(BornAgain::UnitsNm)
-        .setNonnegative();
+    registerParameter(BornAgain::RadiusX, &m_radius_x).setUnit(BornAgain::UnitsNm).setNonnegative();
+    registerParameter(BornAgain::RadiusY, &m_radius_y).setUnit(BornAgain::UnitsNm).setNonnegative();
+    registerParameter(BornAgain::Height, &m_height).setUnit(BornAgain::UnitsNm).setNonnegative();
     mP_integrator = make_integrator_complex(this, &FormFactorHemiEllipsoid::Integrand);
     onChange();
 }
 
 double FormFactorHemiEllipsoid::radialExtension() const
 {
-    return ( m_radius_x + m_radius_y ) / 2.0;
+    return (m_radius_x + m_radius_y) / 2.0;
 }
 
 //! Integrand for complex formfactor.
@@ -50,28 +47,28 @@ complex_t FormFactorHemiEllipsoid::Integrand(double Z) const
     double W = m_radius_y;
     double H = m_height;
 
-    double Rz = R * std::sqrt(1.0 - Z*Z/(H*H));
-    double Wz = W * std::sqrt(1.0 - Z*Z/(H*H));
+    double Rz = R * std::sqrt(1.0 - Z * Z / (H * H));
+    double Wz = W * std::sqrt(1.0 - Z * Z / (H * H));
 
-    complex_t qxRz = m_q.x()*Rz;
-    complex_t qyWz = m_q.y()*Wz;
+    complex_t qxRz = m_q.x() * Rz;
+    complex_t qyWz = m_q.y() * Wz;
 
-    complex_t gamma = std::sqrt(qxRz*qxRz + qyWz*qyWz);
+    complex_t gamma = std::sqrt(qxRz * qxRz + qyWz * qyWz);
     complex_t J1_gamma_div_gamma = MathFunctions::Bessel_J1c(gamma);
 
-    return Rz * Wz * J1_gamma_div_gamma * exp_I(m_q.z()*Z);
+    return Rz * Wz * J1_gamma_div_gamma * exp_I(m_q.z() * Z);
 }
 
 complex_t FormFactorHemiEllipsoid::evaluate_for_q(cvector_t q) const
 {
-     m_q = q;
-     double R = m_radius_x;
-     double W = m_radius_y;
-     double H = m_height;
+    m_q = q;
+    double R = m_radius_x;
+    double W = m_radius_y;
+    double H = m_height;
 
-     if (std::abs(m_q.mag()) <= std::numeric_limits<double>::epsilon())
-         return M_TWOPI*R*W*H/3.;
-     return M_TWOPI*mP_integrator->integrate(0.,H );
+    if (std::abs(m_q.mag()) <= std::numeric_limits<double>::epsilon())
+        return M_TWOPI * R * W * H / 3.;
+    return M_TWOPI * mP_integrator->integrate(0., H);
 }
 
 void FormFactorHemiEllipsoid::onChange()
diff --git a/Core/HardParticle/FormFactorHemiEllipsoid.h b/Core/HardParticle/FormFactorHemiEllipsoid.h
index dc3005a23c9..f59e69e7482 100644
--- a/Core/HardParticle/FormFactorHemiEllipsoid.h
+++ b/Core/HardParticle/FormFactorHemiEllipsoid.h
@@ -28,9 +28,11 @@ public:
     FormFactorHemiEllipsoid(double radius_x, double radius_y, double height);
     virtual ~FormFactorHemiEllipsoid() {}
 
-    FormFactorHemiEllipsoid* clone() const override final {
-        return new FormFactorHemiEllipsoid(m_radius_x, m_radius_y, m_height); }
-    void accept(INodeVisitor *visitor) const override final { visitor->visit(this); }
+    FormFactorHemiEllipsoid* clone() const override final
+    {
+        return new FormFactorHemiEllipsoid(m_radius_x, m_radius_y, m_height);
+    }
+    void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     double getHeight() const { return m_height; }
     double getRadiusX() const { return m_radius_x; }
@@ -38,7 +40,7 @@ public:
 
     double radialExtension() const override final;
 
-    complex_t evaluate_for_q (cvector_t q) const override final;
+    complex_t evaluate_for_q(cvector_t q) const override final;
 
 protected:
     void onChange() override final;
diff --git a/Core/HardParticle/FormFactorIcosahedron.cpp b/Core/HardParticle/FormFactorIcosahedron.cpp
index ae2b3a261ee..33d8ff439e8 100644
--- a/Core/HardParticle/FormFactorIcosahedron.cpp
+++ b/Core/HardParticle/FormFactorIcosahedron.cpp
@@ -17,42 +17,37 @@
 #include "Icosahedron.h"
 #include "RealParameter.h"
 
-const PolyhedralTopology FormFactorIcosahedron::topology = {
-    {
-        // bottom:
-        { {  0,  2,  1 }, false },
-        // 1st row:
-        { {  0,  5,  2 }, false },
-        { {  2,  3,  1 }, false },
-        { {  1,  4,  0 }, false },
-        // 2nd row:
-        { {  0,  6,  5 }, false },
-        { {  2,  5,  8 }, false },
-        { {  2,  8,  3 }, false },
-        { {  1,  3,  7 }, false },
-        { {  1,  7,  4 }, false },
-        { {  0,  4,  6 }, false },
-        // 3rd row:
-        { {  3,  8,  9 }, false },
-        { {  5, 11,  8 }, false },
-        { {  5,  6, 11 }, false },
-        { {  4, 10,  6 }, false },
-        { {  4,  7, 10 }, false },
-        { {  3,  9,  7 }, false },
-        // 4th row:
-        { {  8, 11,  9 }, false },
-        { {  6, 10, 11 }, false },
-        { {  7,  9, 10 }, false },
-        // top:
-        { {  9, 11, 10 }, false }
-    }, true };
-
+const PolyhedralTopology FormFactorIcosahedron::topology = {{// bottom:
+                                                             {{0, 2, 1}, false},
+                                                             // 1st row:
+                                                             {{0, 5, 2}, false},
+                                                             {{2, 3, 1}, false},
+                                                             {{1, 4, 0}, false},
+                                                             // 2nd row:
+                                                             {{0, 6, 5}, false},
+                                                             {{2, 5, 8}, false},
+                                                             {{2, 8, 3}, false},
+                                                             {{1, 3, 7}, false},
+                                                             {{1, 7, 4}, false},
+                                                             {{0, 4, 6}, false},
+                                                             // 3rd row:
+                                                             {{3, 8, 9}, false},
+                                                             {{5, 11, 8}, false},
+                                                             {{5, 6, 11}, false},
+                                                             {{4, 10, 6}, false},
+                                                             {{4, 7, 10}, false},
+                                                             {{3, 9, 7}, false},
+                                                             // 4th row:
+                                                             {{8, 11, 9}, false},
+                                                             {{6, 10, 11}, false},
+                                                             {{7, 9, 10}, false},
+                                                             // top:
+                                                             {{9, 11, 10}, false}},
+                                                            true};
 
 //! Constructor of a icosahedron.
 //! @param edge: length of the edge in nanometers
-FormFactorIcosahedron::FormFactorIcosahedron(double edge)
-    : FormFactorPolyhedron()
-    , m_edge(edge)
+FormFactorIcosahedron::FormFactorIcosahedron(double edge) : FormFactorPolyhedron(), m_edge(edge)
 {
     setName(BornAgain::FFIcosahedronType);
     registerParameter(BornAgain::Edge, &m_edge).setUnit(BornAgain::UnitsNm).setNonnegative();
@@ -63,18 +58,18 @@ void FormFactorIcosahedron::onChange()
 {
     mP_shape.reset(new Icosahedron(m_edge));
     double a = m_edge;
-    setPolyhedron( topology, -0.7557613140761708*a, {
-        {  0.5773502691896258*a,                   0*a, -0.7557613140761708*a},
-        {  -0.288675134594813*a,                 0.5*a, -0.7557613140761708*a},
-        {  -0.288675134594813*a,                -0.5*a, -0.7557613140761708*a},
-        { -0.9341723589627158*a,                   0*a, -0.1784110448865449*a},
-        {   0.467086179481358*a,  0.8090169943749475*a, -0.1784110448865449*a},
-        {   0.467086179481358*a, -0.8090169943749475*a, -0.1784110448865449*a},
-        {  0.9341723589627158*a,                   0*a,  0.1784110448865449*a},
-        {  -0.467086179481358*a,  0.8090169943749475*a,  0.1784110448865449*a},
-        {  -0.467086179481358*a, -0.8090169943749475*a,  0.1784110448865449*a},
-        { -0.5773502691896258*a,                   0*a,  0.7557613140761708*a},
-        {   0.288675134594813*a,                 0.5*a,  0.7557613140761708*a},
-        {   0.288675134594813*a,                -0.5*a,  0.7557613140761708*a} } );
+    setPolyhedron(topology, -0.7557613140761708 * a,
+                  {{0.5773502691896258 * a, 0 * a, -0.7557613140761708 * a},
+                   {-0.288675134594813 * a, 0.5 * a, -0.7557613140761708 * a},
+                   {-0.288675134594813 * a, -0.5 * a, -0.7557613140761708 * a},
+                   {-0.9341723589627158 * a, 0 * a, -0.1784110448865449 * a},
+                   {0.467086179481358 * a, 0.8090169943749475 * a, -0.1784110448865449 * a},
+                   {0.467086179481358 * a, -0.8090169943749475 * a, -0.1784110448865449 * a},
+                   {0.9341723589627158 * a, 0 * a, 0.1784110448865449 * a},
+                   {-0.467086179481358 * a, 0.8090169943749475 * a, 0.1784110448865449 * a},
+                   {-0.467086179481358 * a, -0.8090169943749475 * a, 0.1784110448865449 * a},
+                   {-0.5773502691896258 * a, 0 * a, 0.7557613140761708 * a},
+                   {0.288675134594813 * a, 0.5 * a, 0.7557613140761708 * a},
+                   {0.288675134594813 * a, -0.5 * a, 0.7557613140761708 * a}});
     assert_platonic();
 }
diff --git a/Core/HardParticle/FormFactorIcosahedron.h b/Core/HardParticle/FormFactorIcosahedron.h
index 04c204c4274..55c77d372f6 100644
--- a/Core/HardParticle/FormFactorIcosahedron.h
+++ b/Core/HardParticle/FormFactorIcosahedron.h
@@ -25,9 +25,11 @@ class BA_CORE_API_ FormFactorIcosahedron : public FormFactorPolyhedron
 public:
     FormFactorIcosahedron(double edge);
 
-    FormFactorIcosahedron *clone() const override final {
-        return new FormFactorIcosahedron(m_edge); }
-    void accept(INodeVisitor *visitor) const override final { visitor->visit(this); }
+    FormFactorIcosahedron* clone() const override final
+    {
+        return new FormFactorIcosahedron(m_edge);
+    }
+    void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     double getEdge() const { return m_edge; }
 
diff --git a/Core/HardParticle/FormFactorLongBox.cpp b/Core/HardParticle/FormFactorLongBox.cpp
index ed32b36b338..d9e01211f60 100644
--- a/Core/HardParticle/FormFactorLongBox.cpp
+++ b/Core/HardParticle/FormFactorLongBox.cpp
@@ -34,13 +34,12 @@ complex_t FormFactorLongBox::evaluate_for_q(cvector_t q) const
     complex_t qyWdiv2 = m_width * q.y() / 2.0;
     complex_t qzHdiv2 = m_height * q.z() / 2.0;
 
-    return m_height * m_length * m_width * exp_I(qzHdiv2)
-            * MathFunctions::sinc(qyWdiv2) * MathFunctions::sinc(qzHdiv2)
-            / std::sqrt(1.0 + qxL2);
+    return m_height * m_length * m_width * exp_I(qzHdiv2) * MathFunctions::sinc(qyWdiv2)
+           * MathFunctions::sinc(qzHdiv2) / std::sqrt(1.0 + qxL2);
 }
 
 IFormFactor* FormFactorLongBox::sliceFormFactor(ZLimits limits, const IRotation& rot,
-                                                     kvector_t translation) const
+                                                kvector_t translation) const
 {
     auto effects = computeSlicingEffects(limits, translation, m_height);
     FormFactorLongBox slicedff(m_length, m_width, m_height - effects.dz_bottom - effects.dz_top);
diff --git a/Core/HardParticle/FormFactorLongBox.h b/Core/HardParticle/FormFactorLongBox.h
index 24323725eef..2ad1204e8f3 100644
--- a/Core/HardParticle/FormFactorLongBox.h
+++ b/Core/HardParticle/FormFactorLongBox.h
@@ -28,16 +28,18 @@ public:
     //! @param length of Box's base
     //! @param width of Box's base
     //! @param height of Box
-    FormFactorLongBox( double length, double width, double height);
+    FormFactorLongBox(double length, double width, double height);
 
-    FormFactorLongBox *clone() const override final {
-        return new FormFactorLongBox(m_length, m_width, m_height); }
-    void accept(INodeVisitor *visitor) const override final { visitor->visit(this); }
+    FormFactorLongBox* clone() const override final
+    {
+        return new FormFactorLongBox(m_length, m_width, m_height);
+    }
+    void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     double getLength() const { return m_length; }
     double getHeight() const { return m_height; }
     double getWidth() const { return m_width; }
-    double radialExtension() const override final{ return m_length/2.0; }
+    double radialExtension() const override final { return m_length / 2.0; }
 
     complex_t evaluate_for_q(cvector_t q) const override final;
 
diff --git a/Core/HardParticle/FormFactorLongBoxGauss.cpp b/Core/HardParticle/FormFactorLongBoxGauss.cpp
index 07dde847e0b..325877891b8 100644
--- a/Core/HardParticle/FormFactorLongBoxGauss.cpp
+++ b/Core/HardParticle/FormFactorLongBoxGauss.cpp
@@ -35,7 +35,7 @@ complex_t FormFactorLongBoxGauss::evaluate_for_q(cvector_t q) const
     complex_t qzHdiv2 = m_height * q.z() / 2.0;
 
     return m_height * m_length * m_width * exp_I(qzHdiv2) * std::exp(-qxL2)
-            * MathFunctions::sinc(qyWdiv2) * MathFunctions::sinc(qzHdiv2);
+           * MathFunctions::sinc(qyWdiv2) * MathFunctions::sinc(qzHdiv2);
 }
 
 IFormFactor* FormFactorLongBoxGauss::sliceFormFactor(ZLimits limits, const IRotation& rot,
diff --git a/Core/HardParticle/FormFactorLongBoxGauss.h b/Core/HardParticle/FormFactorLongBoxGauss.h
index 8f183d19288..24b193f8619 100644
--- a/Core/HardParticle/FormFactorLongBoxGauss.h
+++ b/Core/HardParticle/FormFactorLongBoxGauss.h
@@ -27,16 +27,18 @@ public:
     //! @param length of Box's base
     //! @param width of Box's base
     //! @param height of Box
-    FormFactorLongBoxGauss( double length, double width, double height);
+    FormFactorLongBoxGauss(double length, double width, double height);
 
-    FormFactorLongBoxGauss *clone() const override final {
-        return new FormFactorLongBoxGauss(m_length, m_width, m_height); }
-    void accept(INodeVisitor *visitor) const override final { visitor->visit(this); }
+    FormFactorLongBoxGauss* clone() const override final
+    {
+        return new FormFactorLongBoxGauss(m_length, m_width, m_height);
+    }
+    void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     double getLength() const { return m_length; }
     double getHeight() const { return m_height; }
     double getWidth() const { return m_width; }
-    double radialExtension() const override final{ return m_length/2.0; }
+    double radialExtension() const override final { return m_length / 2.0; }
 
     complex_t evaluate_for_q(cvector_t q) const override final;
 
diff --git a/Core/HardParticle/FormFactorLongBoxLorentz.cpp b/Core/HardParticle/FormFactorLongBoxLorentz.cpp
index 9119dc148bb..236f4521111 100644
--- a/Core/HardParticle/FormFactorLongBoxLorentz.cpp
+++ b/Core/HardParticle/FormFactorLongBoxLorentz.cpp
@@ -30,12 +30,12 @@ FormFactorLongBoxLorentz::FormFactorLongBoxLorentz(double length, double width,
 
 complex_t FormFactorLongBoxLorentz::evaluate_for_q(cvector_t q) const
 {
-    complex_t qxL2 = 2.5*std::pow(m_length * q.x(), 2);
+    complex_t qxL2 = 2.5 * std::pow(m_length * q.x(), 2);
     complex_t qyWdiv2 = m_width * q.y() / 2.0;
     complex_t qzHdiv2 = m_height * q.z() / 2.0;
 
     return m_height * m_length * m_width * std::exp(complex_t(0., 1.) * qzHdiv2) / (1.0 + qxL2)
-            * MathFunctions::sinc(qyWdiv2) * MathFunctions::sinc(qzHdiv2);
+           * MathFunctions::sinc(qyWdiv2) * MathFunctions::sinc(qzHdiv2);
 }
 
 IFormFactor* FormFactorLongBoxLorentz::sliceFormFactor(ZLimits limits, const IRotation& rot,
diff --git a/Core/HardParticle/FormFactorLongBoxLorentz.h b/Core/HardParticle/FormFactorLongBoxLorentz.h
index 3654ee0bc61..29401665ae5 100644
--- a/Core/HardParticle/FormFactorLongBoxLorentz.h
+++ b/Core/HardParticle/FormFactorLongBoxLorentz.h
@@ -27,17 +27,19 @@ public:
     //! @param length of Box's base
     //! @param width of Box's base
     //! @param height of Box
-    FormFactorLongBoxLorentz( double length, double width, double height);
+    FormFactorLongBoxLorentz(double length, double width, double height);
 
-    FormFactorLongBoxLorentz* clone() const override final {
-        return new FormFactorLongBoxLorentz(m_length, m_width, m_height); }
-    void accept(INodeVisitor *visitor) const override final { visitor->visit(this); }
+    FormFactorLongBoxLorentz* clone() const override final
+    {
+        return new FormFactorLongBoxLorentz(m_length, m_width, m_height);
+    }
+    void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     double getLength() const { return m_length; }
     double getHeight() const { return m_height; }
     double getWidth() const { return m_width; }
 
-    double radialExtension() const override final { return m_length/2.0; }
+    double radialExtension() const override final { return m_length / 2.0; }
 
     complex_t evaluate_for_q(cvector_t q) const override final;
 
diff --git a/Core/HardParticle/FormFactorLongRipple1Gauss.cpp b/Core/HardParticle/FormFactorLongRipple1Gauss.cpp
index 18aae875f4d..790def7cfa0 100644
--- a/Core/HardParticle/FormFactorLongRipple1Gauss.cpp
+++ b/Core/HardParticle/FormFactorLongRipple1Gauss.cpp
@@ -16,9 +16,9 @@
 #include "BornAgainNamespace.h"
 #include "Box.h"
 #include "Exceptions.h"
-#include "RealLimits.h"
-#include "MathFunctions.h"
 #include "MathConstants.h"
+#include "MathFunctions.h"
+#include "RealLimits.h"
 #include "RealParameter.h"
 
 FormFactorLongRipple1Gauss::FormFactorLongRipple1Gauss(double length, double width, double height)
@@ -36,7 +36,7 @@ FormFactorLongRipple1Gauss::FormFactorLongRipple1Gauss(double length, double wid
 bool FormFactorLongRipple1Gauss::check_initialization() const
 {
     bool result(true);
-    if(m_height <=0.0 || m_width<=0.0 || m_length<=0.0) {
+    if (m_height <= 0.0 || m_width <= 0.0 || m_length <= 0.0) {
         std::ostringstream ostr;
         ostr << "FormFactorLongRipple1Gauss() -> Error in class initialization with parameters ";
         ostr << " height:" << m_height;
@@ -50,37 +50,38 @@ bool FormFactorLongRipple1Gauss::check_initialization() const
 
 double FormFactorLongRipple1Gauss::radialExtension() const
 {
-    return ( m_width + m_length ) / 4.0;
+    return (m_width + m_length) / 4.0;
 }
 
 //! Integrand for complex formfactor.
 complex_t FormFactorLongRipple1Gauss::Integrand(double u) const
 {
-    return sin(u) * exp(m_az*std::cos(u)) * ( m_ay==0. ? u : sin(m_ay*u)/m_ay );
+    return sin(u) * exp(m_az * std::cos(u)) * (m_ay == 0. ? u : sin(m_ay * u) / m_ay);
 }
 
 //! Complex formfactor.
 complex_t FormFactorLongRipple1Gauss::evaluate_for_q(cvector_t q) const
 {
     complex_t qxL2 = std::pow(m_length * q.x(), 2) / 2.0;
-    complex_t factor = m_length*std::exp(-qxL2)*m_width/M_PI;
+    complex_t factor = m_length * std::exp(-qxL2) * m_width / M_PI;
 
     // analytical expressions for some particular cases
-    if ( q.z()==0. ) {
-        if( q.y()==0. )
-            return factor*M_PI_2*m_height;
-        complex_t aaa = q.y()*m_width/(M_TWOPI);
-        complex_t aaa2 = aaa*aaa;
-        if ( aaa2==1. )
-            return factor*M_PI_4*m_height;
-        return factor*M_PI_2*m_height*MathFunctions::sinc(q.y()*m_width*0.5)/(1.0-aaa2);
+    if (q.z() == 0.) {
+        if (q.y() == 0.)
+            return factor * M_PI_2 * m_height;
+        complex_t aaa = q.y() * m_width / (M_TWOPI);
+        complex_t aaa2 = aaa * aaa;
+        if (aaa2 == 1.)
+            return factor * M_PI_4 * m_height;
+        return factor * M_PI_2 * m_height * MathFunctions::sinc(q.y() * m_width * 0.5)
+               / (1.0 - aaa2);
     }
 
     // numerical integration otherwise
     m_ay = q.y() * m_width / M_TWOPI;
-    m_az = complex_t(0,1) * q.z() * (m_height/2);
+    m_az = complex_t(0, 1) * q.z() * (m_height / 2);
     complex_t integral = mP_integrator->integrate(0, M_PI);
-    return factor * integral * exp(m_az) * (m_height/2);
+    return factor * integral * exp(m_az) * (m_height / 2);
 }
 
 void FormFactorLongRipple1Gauss::onChange()
diff --git a/Core/HardParticle/FormFactorLongRipple1Gauss.h b/Core/HardParticle/FormFactorLongRipple1Gauss.h
index 7c2e9a7ff1a..84a03498702 100644
--- a/Core/HardParticle/FormFactorLongRipple1Gauss.h
+++ b/Core/HardParticle/FormFactorLongRipple1Gauss.h
@@ -30,8 +30,10 @@ public:
     //! @param height of cosine cross section
     FormFactorLongRipple1Gauss(double length, double width, double height);
 
-    FormFactorLongRipple1Gauss* clone() const override final {
-        return new FormFactorLongRipple1Gauss(m_length, m_width, m_height); }
+    FormFactorLongRipple1Gauss* clone() const override final
+    {
+        return new FormFactorLongRipple1Gauss(m_length, m_width, m_height);
+    }
     void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     double getHeight() const { return m_height; }
diff --git a/Core/HardParticle/FormFactorLongRipple1Lorentz.cpp b/Core/HardParticle/FormFactorLongRipple1Lorentz.cpp
index 4bc7d1b949e..cb838305c77 100644
--- a/Core/HardParticle/FormFactorLongRipple1Lorentz.cpp
+++ b/Core/HardParticle/FormFactorLongRipple1Lorentz.cpp
@@ -16,12 +16,12 @@
 #include "BornAgainNamespace.h"
 #include "Box.h"
 #include "Exceptions.h"
-#include "MathFunctions.h"
 #include "MathConstants.h"
+#include "MathFunctions.h"
 #include "RealParameter.h"
 
-FormFactorLongRipple1Lorentz::FormFactorLongRipple1Lorentz(
-    double length, double width, double height)
+FormFactorLongRipple1Lorentz::FormFactorLongRipple1Lorentz(double length, double width,
+                                                           double height)
     : m_length(length), m_width(width), m_height(height)
 {
     setName(BornAgain::FFLongRipple1LorentzType);
@@ -36,7 +36,7 @@ FormFactorLongRipple1Lorentz::FormFactorLongRipple1Lorentz(
 bool FormFactorLongRipple1Lorentz::check_initialization() const
 {
     bool result(true);
-    if(m_height <=0.0 || m_width<=0.0 || m_length<=0.0) {
+    if (m_height <= 0.0 || m_width <= 0.0 || m_length <= 0.0) {
         std::ostringstream ostr;
         ostr << "FormFactorLongRipple1Lorentz() -> Error in class initialization with parameters ";
         ostr << " height:" << m_height;
@@ -50,37 +50,38 @@ bool FormFactorLongRipple1Lorentz::check_initialization() const
 
 double FormFactorLongRipple1Lorentz::radialExtension() const
 {
-    return ( m_width + m_length ) / 4.0;
+    return (m_width + m_length) / 4.0;
 }
 
 //! Integrand for complex formfactor.
 complex_t FormFactorLongRipple1Lorentz::Integrand(double u) const
 {
-    return sin(u) * exp(m_az*std::cos(u)) * ( m_ay==0. ? u : sin(m_ay*u)/m_ay );
+    return sin(u) * exp(m_az * std::cos(u)) * (m_ay == 0. ? u : sin(m_ay * u) / m_ay);
 }
 
 //! Complex formfactor.
 complex_t FormFactorLongRipple1Lorentz::evaluate_for_q(cvector_t q) const
 {
-    complex_t qxL2 = 2.5*std::pow(m_length * q.x(), 2);
-    complex_t factor = m_length/(1.0 + qxL2)*m_width/M_PI;
+    complex_t qxL2 = 2.5 * std::pow(m_length * q.x(), 2);
+    complex_t factor = m_length / (1.0 + qxL2) * m_width / M_PI;
 
     // analytical expressions for some particular cases
-    if ( q.z()==0. ) {
-        if( q.y()==0. )
-            return factor*M_PI_2*m_height;
-        complex_t aaa = q.y()*m_width/(M_TWOPI);
-        complex_t aaa2 = aaa*aaa;
-        if ( aaa2==1. )
-            return factor*M_PI_4*m_height;
-        return factor*M_PI_2*m_height*MathFunctions::sinc(q.y()*m_width*0.5)/(1.0-aaa2);
+    if (q.z() == 0.) {
+        if (q.y() == 0.)
+            return factor * M_PI_2 * m_height;
+        complex_t aaa = q.y() * m_width / (M_TWOPI);
+        complex_t aaa2 = aaa * aaa;
+        if (aaa2 == 1.)
+            return factor * M_PI_4 * m_height;
+        return factor * M_PI_2 * m_height * MathFunctions::sinc(q.y() * m_width * 0.5)
+               / (1.0 - aaa2);
     }
 
     // numerical integration otherwise
     m_ay = q.y() * m_width / M_TWOPI;
-    m_az = complex_t(0,1) * q.z() * (m_height/2);
+    m_az = complex_t(0, 1) * q.z() * (m_height / 2);
     complex_t integral = mP_integrator->integrate(0, M_PI);
-    return factor * integral * exp(m_az) * (m_height/2);
+    return factor * integral * exp(m_az) * (m_height / 2);
 }
 
 void FormFactorLongRipple1Lorentz::onChange()
diff --git a/Core/HardParticle/FormFactorLongRipple1Lorentz.h b/Core/HardParticle/FormFactorLongRipple1Lorentz.h
index 802963e8f5f..02a4aea217a 100644
--- a/Core/HardParticle/FormFactorLongRipple1Lorentz.h
+++ b/Core/HardParticle/FormFactorLongRipple1Lorentz.h
@@ -30,8 +30,10 @@ public:
     //! @param height of cosine cross section
     FormFactorLongRipple1Lorentz(double length, double width, double height);
 
-    FormFactorLongRipple1Lorentz* clone() const override final {
-        return new FormFactorLongRipple1Lorentz(m_length, m_width, m_height); }
+    FormFactorLongRipple1Lorentz* clone() const override final
+    {
+        return new FormFactorLongRipple1Lorentz(m_length, m_width, m_height);
+    }
     void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     double radialExtension() const override final;
diff --git a/Core/HardParticle/FormFactorLongRipple2Gauss.cpp b/Core/HardParticle/FormFactorLongRipple2Gauss.cpp
index beab1781b3b..c5d19f93538 100644
--- a/Core/HardParticle/FormFactorLongRipple2Gauss.cpp
+++ b/Core/HardParticle/FormFactorLongRipple2Gauss.cpp
@@ -18,12 +18,9 @@
 #include "Exceptions.h"
 #include "RealParameter.h"
 
-FormFactorLongRipple2Gauss::FormFactorLongRipple2Gauss(
-    double length, double width, double height, double asymmetry)
-    : m_width(width)
-    , m_height(height)
-    , m_length(length)
-    , m_d(asymmetry)
+FormFactorLongRipple2Gauss::FormFactorLongRipple2Gauss(double length, double width, double height,
+                                                       double asymmetry)
+    : m_width(width), m_height(height), m_length(length), m_d(asymmetry)
 {
     setName(BornAgain::FFLongRipple2GaussType);
     check_initialization();
@@ -38,20 +35,20 @@ bool FormFactorLongRipple2Gauss::check_initialization() const
 {
     bool result(true);
     std::string message;
-    if(-1*m_width > 2.*m_d) {
+    if (-1 * m_width > 2. * m_d) {
         result = false;
         message = std::string("Check for '-1*width <= 2.*asymmetry' failed.");
     }
-    if(m_width < 2.*m_d) {
+    if (m_width < 2. * m_d) {
         result = false;
         message = std::string("Check for 'width >= 2.*asymmetry' failed.");
     }
-    if(m_height <=0) {
+    if (m_height <= 0) {
         result = false;
         message = std::string("Check for 'height > 0' failed.");
     }
 
-    if(!result) {
+    if (!result) {
         std::ostringstream ostr;
         ostr << "FormFactorLongRipple2Gauss() -> Error in class initialization with parameters ";
         ostr << " width:" << m_width;
@@ -66,7 +63,7 @@ bool FormFactorLongRipple2Gauss::check_initialization() const
 
 double FormFactorLongRipple2Gauss::radialExtension() const
 {
-    return ( m_width + m_length ) / 4.0;
+    return (m_width + m_length) / 4.0;
 }
 
 //! Complex formfactor.
@@ -77,8 +74,8 @@ complex_t FormFactorLongRipple2Gauss::evaluate_for_q(cvector_t q) const
     complex_t qxL2 = std::pow(m_length * q.x(), 2) / 2.0;
     complex_t factor = m_length * std::exp(-qxL2) * m_width;
     complex_t result = 0;
-    complex_t iqzH = mul_I( q.z() * m_height );
-    complex_t iqyW = mul_I( q.y() * m_width );
+    complex_t iqzH = mul_I(q.z() * m_height);
+    complex_t iqyW = mul_I(q.y() * m_width);
     complex_t aaa = 2.0 * (m_d * q.y() + m_height * q.z());
 
     if (0.0 == q.y() && 0.0 == q.z())
diff --git a/Core/HardParticle/FormFactorLongRipple2Gauss.h b/Core/HardParticle/FormFactorLongRipple2Gauss.h
index c386ee277dd..c88de5eb3a7 100644
--- a/Core/HardParticle/FormFactorLongRipple2Gauss.h
+++ b/Core/HardParticle/FormFactorLongRipple2Gauss.h
@@ -30,9 +30,10 @@ public:
     //! @param asymmetry length of triangular cross section
     FormFactorLongRipple2Gauss(double length, double width, double height, double asymmetry);
 
-
-    FormFactorLongRipple2Gauss* clone() const override final {
-        return new FormFactorLongRipple2Gauss(m_length, m_width, m_height, m_d); }
+    FormFactorLongRipple2Gauss* clone() const override final
+    {
+        return new FormFactorLongRipple2Gauss(m_length, m_width, m_height, m_d);
+    }
     void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     double getHeight() const { return m_height; }
diff --git a/Core/HardParticle/FormFactorLongRipple2Lorentz.cpp b/Core/HardParticle/FormFactorLongRipple2Lorentz.cpp
index 492eb1aa7c8..3e07c1b9317 100644
--- a/Core/HardParticle/FormFactorLongRipple2Lorentz.cpp
+++ b/Core/HardParticle/FormFactorLongRipple2Lorentz.cpp
@@ -22,8 +22,8 @@
 //! @param width of triangular cross section
 //! @param height of triangular cross section
 //! @param asymmetry length of triangular cross section
-FormFactorLongRipple2Lorentz::FormFactorLongRipple2Lorentz(
-    double length, double width, double height, double asymetry)
+FormFactorLongRipple2Lorentz::FormFactorLongRipple2Lorentz(double length, double width,
+                                                           double height, double asymetry)
     : m_length(length), m_width(width), m_height(height), m_d(asymetry)
 {
     setName(BornAgain::FFLongRipple2LorentzType);
@@ -38,20 +38,20 @@ void FormFactorLongRipple2Lorentz::check_parameters() const
 {
     bool ok = true;
     std::string message;
-    if(-1*m_width > 2.*m_d) {
+    if (-1 * m_width > 2. * m_d) {
         ok = false;
         message = std::string("Check for '-1*width <= 2.*asymmetry' failed.");
     }
-    if(m_width < 2.*m_d) {
+    if (m_width < 2. * m_d) {
         ok = false;
         message = std::string("Check for 'width >= 2.*asymmetry' failed.");
     }
-    if(m_height <=0) {
+    if (m_height <= 0) {
         ok = false;
         message = std::string("Check for 'height > 0' failed.");
     }
 
-    if(ok)
+    if (ok)
         return;
 
     std::ostringstream ostr;
@@ -66,7 +66,7 @@ void FormFactorLongRipple2Lorentz::check_parameters() const
 
 double FormFactorLongRipple2Lorentz::radialExtension() const
 {
-    return ( m_width + m_length ) / 4.0;
+    return (m_width + m_length) / 4.0;
 }
 
 //! Complex formfactor.
@@ -76,12 +76,12 @@ complex_t FormFactorLongRipple2Lorentz::evaluate_for_q(cvector_t q) const
 
     m_q = q;
 
-    complex_t qxL2 = 2.5*std::pow(m_length * q.x(), 2);
+    complex_t qxL2 = 2.5 * std::pow(m_length * q.x(), 2);
     complex_t factor = m_length / (1.0 + qxL2) * m_width;
 
     complex_t result = 0;
-    complex_t iqzH = mul_I( q.z() * m_height );
-    complex_t iqyW = mul_I( q.y() * m_width );
+    complex_t iqzH = mul_I(q.z() * m_height);
+    complex_t iqyW = mul_I(q.y() * m_width);
     complex_t aaa = 2.0 * (m_d * q.y() + m_height * q.z());
 
     if (0.0 == q.y() && 0.0 == q.z())
diff --git a/Core/HardParticle/FormFactorLongRipple2Lorentz.h b/Core/HardParticle/FormFactorLongRipple2Lorentz.h
index 0bf697da643..f73ffb2b199 100644
--- a/Core/HardParticle/FormFactorLongRipple2Lorentz.h
+++ b/Core/HardParticle/FormFactorLongRipple2Lorentz.h
@@ -25,9 +25,11 @@ class BA_CORE_API_ FormFactorLongRipple2Lorentz : public IFormFactorBorn
 public:
     FormFactorLongRipple2Lorentz(double length, double width, double height, double asymmetry);
 
-    FormFactorLongRipple2Lorentz *clone() const override final {
-        return new FormFactorLongRipple2Lorentz(m_length, m_width, m_height, m_d); }
-    void accept(INodeVisitor *visitor) const override final { visitor->visit(this); }
+    FormFactorLongRipple2Lorentz* clone() const override final
+    {
+        return new FormFactorLongRipple2Lorentz(m_length, m_width, m_height, m_d);
+    }
+    void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     double getHeight() const { return m_height; }
     double getWidth() const { return m_width; }
diff --git a/Core/HardParticle/FormFactorPolyhedron.cpp b/Core/HardParticle/FormFactorPolyhedron.cpp
index 9ae68cbea92..56dbe632383 100644
--- a/Core/HardParticle/FormFactorPolyhedron.cpp
+++ b/Core/HardParticle/FormFactorPolyhedron.cpp
@@ -23,11 +23,12 @@
 #include <iomanip>
 #include <stdexcept> // need overlooked by g++ 5.4
 
-namespace {
-    const complex_t I = {0.,1.};
-    const double eps = 2e-16;
-    constexpr auto ReciprocalFactorialArray = Precomputed::GenerateReciprocalFactorialArray<171>();
-}
+namespace
+{
+const complex_t I = {0., 1.};
+const double eps = 2e-16;
+constexpr auto ReciprocalFactorialArray = Precomputed::GenerateReciprocalFactorialArray<171>();
+} // namespace
 
 double PolyhedralFace::qpa_limit_series = 3e-2;
 int PolyhedralFace::n_limit_series = 20;
@@ -39,11 +40,10 @@ int FormFactorPolyhedron::n_limit_series = 20;
 //  PolyhedralEdge implementation
 //**************************************************************************************************
 
-PolyhedralEdge::PolyhedralEdge(kvector_t _Vlow, kvector_t _Vhig )
-    : m_E((_Vhig-_Vlow)/2)
-    , m_R((_Vhig+_Vlow)/2)
+PolyhedralEdge::PolyhedralEdge(kvector_t _Vlow, kvector_t _Vhig)
+    : m_E((_Vhig - _Vlow) / 2), m_R((_Vhig + _Vlow) / 2)
 {
-    if( m_E.mag2()==0 )
+    if (m_E.mag2() == 0)
         throw std::invalid_argument("At least one edge has zero length");
 };
 
@@ -56,47 +56,43 @@ complex_t PolyhedralEdge::contrib(int M, cvector_t qpa, complex_t qrperp) const
     complex_t v1 = qrperp;
     complex_t v = v2 + v1;
 #ifdef POLYHEDRAL_DIAGNOSTIC
-    if( diagnosis.debmsg>=5 )
-        std::cout<<std::scientific<<std::showpos<<std::setprecision(16)<<"contrib: u="<<u<<
-            " v1="<<v1<<" v2="<<v2<<"\n";
+    if (diagnosis.debmsg >= 5)
+        std::cout << std::scientific << std::showpos << std::setprecision(16) << "contrib: u=" << u
+                  << " v1=" << v1 << " v2=" << v2 << "\n";
 #endif
-    if( v==0. ) { // only 2l=M contributes
-        if( M&1 ) // M is odd
+    if (v == 0.) { // only 2l=M contributes
+        if (M & 1) // M is odd
             return 0.;
         else
-            return ReciprocalFactorialArray[M] * ( pow(u, M)/(M+1.) - pow(v1, M) );
+            return ReciprocalFactorialArray[M] * (pow(u, M) / (M + 1.) - pow(v1, M));
     }
     complex_t ret = 0;
     // the l=0 term, minus (qperp.R)^M, which cancels under the sum over E*contrib()
-    if        ( v1==0. ) {
+    if (v1 == 0.) {
         ret = ReciprocalFactorialArray[M] * pow(v2, M);
-    } else if ( v2==0. ) {
+    } else if (v2 == 0.) {
         ; // leave ret=0
     } else {
         // binomial expansion
-        for( int mm=1; mm<=M; ++mm ) {
-            complex_t term =
-                ReciprocalFactorialArray[mm] *
-                ReciprocalFactorialArray[M-mm] *
-                pow(v2, mm) * pow(v1, M-mm);
+        for (int mm = 1; mm <= M; ++mm) {
+            complex_t term = ReciprocalFactorialArray[mm] * ReciprocalFactorialArray[M - mm]
+                             * pow(v2, mm) * pow(v1, M - mm);
             ret += term;
 #ifdef POLYHEDRAL_DIAGNOSTIC
-            if( diagnosis.debmsg>=6 )
-                std::cout<<"contrib mm="<<mm<<" t="<<term<<" s="<<ret<<"\n";
+            if (diagnosis.debmsg >= 6)
+                std::cout << "contrib mm=" << mm << " t=" << term << " s=" << ret << "\n";
 #endif
         }
     }
-    if( u==0. )
+    if (u == 0.)
         return ret;
-    for( int l=1; l<=M/2; ++l ) {
-        complex_t term =
-            ReciprocalFactorialArray[M-2*l] *
-            ReciprocalFactorialArray[2*l+1] *
-            pow(u, 2*l) * pow(v, M-2*l);
+    for (int l = 1; l <= M / 2; ++l) {
+        complex_t term = ReciprocalFactorialArray[M - 2 * l] * ReciprocalFactorialArray[2 * l + 1]
+                         * pow(u, 2 * l) * pow(v, M - 2 * l);
         ret += term;
 #ifdef POLYHEDRAL_DIAGNOSTIC
-        if( diagnosis.debmsg>=6 )
-            std::cout<<"contrib l="<<l<<" t="<<term<<" s="<<ret<<"\n";
+        if (diagnosis.debmsg >= 6)
+            std::cout << "contrib l=" << l << " t=" << term << " s=" << ret << "\n";
 #endif
     }
     return ret;
@@ -108,17 +104,21 @@ complex_t PolyhedralEdge::contrib(int M, cvector_t qpa, complex_t qrperp) const
 
 //! Static method, returns diameter of circle that contains all vertices.
 
-double PolyhedralFace::diameter( const std::vector<kvector_t>& V )
+double PolyhedralFace::diameter(const std::vector<kvector_t>& V)
 {
     double diameterFace = 0;
-    for ( size_t j=0; j<V.size(); ++j )
-        for ( size_t jj=j+1; jj<V.size(); ++jj )
-            diameterFace = std::max( diameterFace, (V[j]-V[jj]).mag() );
+    for (size_t j = 0; j < V.size(); ++j)
+        for (size_t jj = j + 1; jj < V.size(); ++jj)
+            diameterFace = std::max(diameterFace, (V[j] - V[jj]).mag());
     return diameterFace;
 }
 
 #ifdef POLYHEDRAL_DIAGNOSTIC
-void PolyhedralFace::setLimits( double _qpa, int _n ) { qpa_limit_series=_qpa; n_limit_series=_n; }
+void PolyhedralFace::setLimits(double _qpa, int _n)
+{
+    qpa_limit_series = _qpa;
+    n_limit_series = _n;
+}
 #endif
 
 //! Sets internal variables for given vertex chain.
@@ -126,113 +126,114 @@ void PolyhedralFace::setLimits( double _qpa, int _n ) { qpa_limit_series=_qpa; n
 //! @param V oriented vertex list
 //! @param _sym_S2 true if face has a perpedicular two-fold symmetry axis
 
-PolyhedralFace::PolyhedralFace( const std::vector<kvector_t>& V, bool _sym_S2 )
-    : sym_S2( _sym_S2 )
+PolyhedralFace::PolyhedralFace(const std::vector<kvector_t>& V, bool _sym_S2) : sym_S2(_sym_S2)
 {
     size_t NV = V.size();
-    if( !NV )
+    if (!NV)
         throw std::logic_error("Face with no edges");
-    if( NV<3 )
+    if (NV < 3)
         throw std::logic_error("Face with less than three edges");
 
     // compute radius in 2d and 3d
-    m_radius_2d = diameter( V )/2;
+    m_radius_2d = diameter(V) / 2;
     m_radius_3d = 0;
-    for( const kvector_t& v: V )
-        m_radius_3d = std::max( m_radius_3d, v.mag() );
+    for (const kvector_t& v : V)
+        m_radius_3d = std::max(m_radius_3d, v.mag());
 
     // Initialize list of 'edges'.
     // Do not create an edge if two vertices are too close to each other.
     // TODO This is implemented in a somewhat sloppy way: we just skip an edge if it would
     //      be too short. This leaves tiny open edges. In a clean implementation, we
     //      rather should merge adjacent vertices before generating edges.
-    for ( size_t j=0; j<NV; ++j ) {
-        size_t jj = (j+1)%NV;
-        if( (V[j]-V[jj]).mag() < 1e-14*m_radius_2d )
+    for (size_t j = 0; j < NV; ++j) {
+        size_t jj = (j + 1) % NV;
+        if ((V[j] - V[jj]).mag() < 1e-14 * m_radius_2d)
             continue; // distance too short -> skip this edge
-        edges.push_back( PolyhedralEdge(V[j], V[jj]) );
+        edges.push_back(PolyhedralEdge(V[j], V[jj]));
     }
     size_t NE = edges.size();
-    if( NE<3 )
+    if (NE < 3)
         throw std::invalid_argument("Face has less than three non-vanishing edges");
 
     // compute n_k, rperp
     m_normal = kvector_t();
-    for( size_t j=0; j<NE; ++j ){
-        size_t jj = (j+1)%NE;
-        kvector_t ee = edges[j].E().cross( edges[jj].E() );
-        if( ee.mag2()==0 ) {
+    for (size_t j = 0; j < NE; ++j) {
+        size_t jj = (j + 1) % NE;
+        kvector_t ee = edges[j].E().cross(edges[jj].E());
+        if (ee.mag2() == 0) {
             throw std::logic_error("Two adjacent edges are parallel");
         }
         m_normal += ee.unit();
     }
     m_normal /= NE;
     m_rperp = 0;
-    for( size_t j=0; j<NV; ++j )
+    for (size_t j = 0; j < NV; ++j)
         m_rperp += V[j].dot(m_normal);
     m_rperp /= NV;
     // assert that the vertices lay in a plane
-    for ( size_t j=1; j<NV; ++j )
-        if( std::abs(V[j].dot(m_normal) - m_rperp) > 1e-14*m_radius_3d )
+    for (size_t j = 1; j < NV; ++j)
+        if (std::abs(V[j].dot(m_normal) - m_rperp) > 1e-14 * m_radius_3d)
             throw std::logic_error("Face is not planar");
     // compute m_area
     m_area = 0;
-    for ( size_t j=0; j<NV; ++j ) {
-        size_t jj = (j+1)%NV;
-        m_area += m_normal.dot( V[j].cross( V[jj] ) ) / 2;
+    for (size_t j = 0; j < NV; ++j) {
+        size_t jj = (j + 1) % NV;
+        m_area += m_normal.dot(V[j].cross(V[jj])) / 2;
     }
     // only now deal with inversion symmetry
-    if( sym_S2 ) {
-        if( NE&1 )
+    if (sym_S2) {
+        if (NE & 1)
             throw std::logic_error("Odd #edges violates symmetry S2");
         NE /= 2;
-        for( size_t j=0; j<NE; ++j ){
-            if( ((edges[j].R()-m_rperp*m_normal)+
-                 (edges[j+NE].R()-m_rperp*m_normal)).mag() > 1e-12*m_radius_2d )
+        for (size_t j = 0; j < NE; ++j) {
+            if (((edges[j].R() - m_rperp * m_normal) + (edges[j + NE].R() - m_rperp * m_normal))
+                    .mag()
+                > 1e-12 * m_radius_2d)
                 throw std::logic_error("Edge centers violate symmetry S2");
-            if( (edges[j].E()+edges[j+NE].E()).mag() > 1e-12*m_radius_2d )
+            if ((edges[j].E() + edges[j + NE].E()).mag() > 1e-12 * m_radius_2d)
                 throw std::logic_error("Edge vectors violate symmetry S2");
         }
         // keep only half of the egdes
-        edges.erase( edges.begin()+NE, edges.end() );
+        edges.erase(edges.begin() + NE, edges.end());
     }
 }
 
 //! Sets qperp and qpa according to argument q and to this polygon's normal.
 
-void PolyhedralFace::decompose_q(cvector_t q, complex_t& qperp, cvector_t& qpa ) const
+void PolyhedralFace::decompose_q(cvector_t q, complex_t& qperp, cvector_t& qpa) const
 {
     qperp = m_normal.dot(q);
-    qpa = q - qperp*m_normal;
+    qpa = q - qperp * m_normal;
     // improve numeric accuracy:
-    qpa -= m_normal.dot(qpa)*m_normal;
-    if( qpa.mag()<eps*std::abs(qperp) )
-        qpa = cvector_t(0.,0.,0.);
+    qpa -= m_normal.dot(qpa) * m_normal;
+    if (qpa.mag() < eps * std::abs(qperp))
+        qpa = cvector_t(0., 0., 0.);
 }
 
 //! Returns core contribution to f_n
 
-complex_t PolyhedralFace::ff_n_core( int m, cvector_t qpa, complex_t qperp ) const
+complex_t PolyhedralFace::ff_n_core(int m, cvector_t qpa, complex_t qperp) const
 {
-    cvector_t prevec = 2.*m_normal.cross( qpa ); // complex conjugation will take place in .dot
+    cvector_t prevec = 2. * m_normal.cross(qpa); // complex conjugation will take place in .dot
     complex_t ret = 0;
     complex_t vfacsum = 0;
     complex_t qrperp = qperp * m_rperp;
-    for( size_t i=0; i<edges.size(); ++i ) {
+    for (size_t i = 0; i < edges.size(); ++i) {
         const PolyhedralEdge& e = edges[i];
         complex_t vfac;
-        if( sym_S2 || i<edges.size()-1 ) {
+        if (sym_S2 || i < edges.size() - 1) {
             vfac = prevec.dot(e.E());
             vfacsum += vfac;
         } else {
-            vfac = - vfacsum; // to improve numeric accuracy: qcE_J = - sum_{j=0}^{J-1} qcE_j
+            vfac = -vfacsum; // to improve numeric accuracy: qcE_J = - sum_{j=0}^{J-1} qcE_j
         }
-        complex_t tmp = e.contrib(m+1, qpa, qrperp);
+        complex_t tmp = e.contrib(m + 1, qpa, qrperp);
         ret += vfac * tmp;
 #ifdef POLYHEDRAL_DIAGNOSTIC
-        if( diagnosis.debmsg>=4 )
-            std::cout<<std::scientific<<std::showpos<<std::setprecision(16)<<"DBX ff_n_core "<<m<<
-                " "<<vfac<<" "<<tmp<<" term="<<vfac*tmp<<" sum="<<ret<<"\n";
+        if (diagnosis.debmsg >= 4)
+            std::cout << std::scientific << std::showpos << std::setprecision(16)
+                      << "DBX ff_n_core " << m << " " << vfac << " " << tmp
+                      << " term=" << vfac * tmp << " sum=" << ret << "\n";
 #endif
     }
     return ret;
@@ -240,24 +241,24 @@ complex_t PolyhedralFace::ff_n_core( int m, cvector_t qpa, complex_t qperp ) con
 
 //! Returns contribution qn*f_n [of order q^(n+1)] from this face to the polyhedral form factor.
 
-complex_t PolyhedralFace::ff_n( int n, cvector_t q ) const
+complex_t PolyhedralFace::ff_n(int n, cvector_t q) const
 {
     complex_t qn = q.dot(m_normal); // conj(q)*normal (dot is antilinear in 'this' argument)
-    if ( std::abs(qn)<eps*q.mag() )
+    if (std::abs(qn) < eps * q.mag())
         return 0.;
     complex_t qperp;
     cvector_t qpa;
-    decompose_q( q, qperp, qpa );
+    decompose_q(q, qperp, qpa);
     double qpa_mag2 = qpa.mag2();
-    if ( qpa_mag2==0. ) {
-        return qn * pow(qperp*m_rperp, n) * m_area * ReciprocalFactorialArray[n];
-    } else if ( sym_S2 ) {
-        return qn * ( ff_n_core( n, qpa, qperp ) + ff_n_core( n, -qpa, qperp ) ) / qpa_mag2;
+    if (qpa_mag2 == 0.) {
+        return qn * pow(qperp * m_rperp, n) * m_area * ReciprocalFactorialArray[n];
+    } else if (sym_S2) {
+        return qn * (ff_n_core(n, qpa, qperp) + ff_n_core(n, -qpa, qperp)) / qpa_mag2;
     } else {
-        complex_t tmp = ff_n_core( n, qpa, qperp );
+        complex_t tmp = ff_n_core(n, qpa, qperp);
 #ifdef POLYHEDRAL_DIAGNOSTIC
-        if( diagnosis.debmsg>=3 )
-            std::cout<<"DBX ff_n "<<n<<" "<<qn<<" "<<tmp<<" "<<qpa_mag2<<"\n";
+        if (diagnosis.debmsg >= 3)
+            std::cout << "DBX ff_n " << n << " " << qn << " " << tmp << " " << qpa_mag2 << "\n";
 #endif
         return qn * tmp / qpa_mag2;
     }
@@ -265,8 +266,8 @@ complex_t PolyhedralFace::ff_n( int n, cvector_t q ) const
 
 //! Returns sum of n>=1 terms of qpa expansion of 2d form factor
 
-complex_t PolyhedralFace::expansion(
-    complex_t fac_even, complex_t fac_odd, cvector_t qpa, double abslevel ) const
+complex_t PolyhedralFace::expansion(complex_t fac_even, complex_t fac_odd, cvector_t qpa,
+                                    double abslevel) const
 {
 #ifdef POLYHEDRAL_DIAGNOSTIC
     diagnosis.nExpandedFaces += 1;
@@ -274,26 +275,26 @@ complex_t PolyhedralFace::expansion(
     complex_t sum = 0;
     complex_t n_fac = I;
     int count_return_condition = 0;
-    for( int n=1; n<n_limit_series; ++n ) {
+    for (int n = 1; n < n_limit_series; ++n) {
 #ifdef POLYHEDRAL_DIAGNOSTIC
-        diagnosis.maxOrder = std::max( diagnosis.maxOrder, n );
+        diagnosis.maxOrder = std::max(diagnosis.maxOrder, n);
 #endif
-        complex_t term = n_fac * ( n&1 ? fac_odd : fac_even ) * ff_n_core(n, qpa, 0) / qpa.mag2();
+        complex_t term = n_fac * (n & 1 ? fac_odd : fac_even) * ff_n_core(n, qpa, 0) / qpa.mag2();
 #ifdef POLYHEDRAL_DIAGNOSTIC
-        if( diagnosis.debmsg>=2 )
-            std::cout<<std::setprecision(16)<<"    sum="<<sum<<" +term="<<term<<"\n";
+        if (diagnosis.debmsg >= 2)
+            std::cout << std::setprecision(16) << "    sum=" << sum << " +term=" << term << "\n";
 #endif
         sum += term;
-        if( std::abs(term)<=eps*std::abs(sum) || std::abs(sum)<eps*abslevel )
+        if (std::abs(term) <= eps * std::abs(sum) || std::abs(sum) < eps * abslevel)
             ++count_return_condition;
         else
             count_return_condition = 0;
-        if( count_return_condition>2 )
+        if (count_return_condition > 2)
             return sum; // regular exit
         n_fac = mul_I(n_fac);
     }
 #ifdef POLYHEDRAL_DIAGNOSTIC
-    if( !diagnosis.request_convergence )
+    if (!diagnosis.request_convergence)
         return sum;
 #endif
     throw std::runtime_error("Series f(q_pa) not converged");
@@ -301,30 +302,31 @@ complex_t PolyhedralFace::expansion(
 
 //! Returns core contribution to analytic 2d form factor.
 
-complex_t PolyhedralFace::edge_sum_ff( cvector_t q, cvector_t qpa, bool sym_Ci ) const
+complex_t PolyhedralFace::edge_sum_ff(cvector_t q, cvector_t qpa, bool sym_Ci) const
 {
-    cvector_t prevec = m_normal.cross( qpa ); // complex conjugation will take place in .dot
+    cvector_t prevec = m_normal.cross(qpa); // complex conjugation will take place in .dot
     complex_t sum = 0;
     complex_t vfacsum = 0;
-    for( size_t i=0; i<edges.size(); ++i ) {
+    for (size_t i = 0; i < edges.size(); ++i) {
         const PolyhedralEdge& e = edges[i];
         complex_t qE = e.qE(qpa);
         complex_t qR = e.qR(qpa);
-        complex_t Rfac = sym_S2 ? sin(qR) : ( sym_Ci ? cos(e.qR(q)) : exp_I(qR) );
+        complex_t Rfac = sym_S2 ? sin(qR) : (sym_Ci ? cos(e.qR(q)) : exp_I(qR));
         complex_t vfac;
-        if( sym_S2 || i<edges.size()-1 ) {
+        if (sym_S2 || i < edges.size() - 1) {
             vfac = prevec.dot(e.E());
             vfacsum += vfac;
         } else {
-            vfac = - vfacsum; // to improve numeric accuracy: qcE_J = - sum_{j=0}^{J-1} qcE_j
+            vfac = -vfacsum; // to improve numeric accuracy: qcE_J = - sum_{j=0}^{J-1} qcE_j
         }
         complex_t term = vfac * MathFunctions::sinc(qE) * Rfac;
         sum += term;
 #ifdef POLYHEDRAL_DIAGNOSTIC
-        if( diagnosis.debmsg>=2 )
-            std::cout<<std::scientific<<std::showpos<<std::setprecision(16)<<"    sum="<<sum<<
-                " term="<<term<<" vf="<<vfac<<" qE="<<qE<<" qR="<<qR<<
-                " sinc="<<MathFunctions::sinc(qE)<<" Rfac="<<Rfac<<"\n";
+        if (diagnosis.debmsg >= 2)
+            std::cout << std::scientific << std::showpos << std::setprecision(16)
+                      << "    sum=" << sum << " term=" << term << " vf=" << vfac << " qE=" << qE
+                      << " qR=" << qR << " sinc=" << MathFunctions::sinc(qE) << " Rfac=" << Rfac
+                      << "\n";
 #endif
     }
     return sum;
@@ -332,62 +334,62 @@ complex_t PolyhedralFace::edge_sum_ff( cvector_t q, cvector_t qpa, bool sym_Ci )
 
 //! Returns the contribution ff(q) of this face to the polyhedral form factor.
 
-complex_t PolyhedralFace::ff(cvector_t q, bool sym_Ci ) const
+complex_t PolyhedralFace::ff(cvector_t q, bool sym_Ci) const
 {
     complex_t qperp;
     cvector_t qpa;
-    decompose_q( q, qperp, qpa );
+    decompose_q(q, qperp, qpa);
     double qpa_red = m_radius_2d * qpa.mag();
-    complex_t qr_perp = qperp*m_rperp;
-    complex_t ff0 = (sym_Ci ? 2.*I*sin(qr_perp) : exp_I(qr_perp)) * m_area;
-    if ( qpa_red==0 ) {
+    complex_t qr_perp = qperp * m_rperp;
+    complex_t ff0 = (sym_Ci ? 2. * I * sin(qr_perp) : exp_I(qr_perp)) * m_area;
+    if (qpa_red == 0) {
         return ff0;
-    } else if ( qpa_red < qpa_limit_series && !sym_S2 ) {
+    } else if (qpa_red < qpa_limit_series && !sym_S2) {
         // summation of power series
         complex_t fac_even;
         complex_t fac_odd;
-        if( sym_Ci ) {
-            fac_even = 2. * mul_I( sin(qr_perp) );
+        if (sym_Ci) {
+            fac_even = 2. * mul_I(sin(qr_perp));
             fac_odd = 2. * cos(qr_perp);
         } else {
             fac_even = exp_I(qr_perp);
             fac_odd = fac_even;
         }
-        return ff0 + expansion( fac_even, fac_odd, qpa, std::abs(ff0) );
+        return ff0 + expansion(fac_even, fac_odd, qpa, std::abs(ff0));
     } else {
         // direct evaluation of analytic formula
         complex_t prefac;
-        if( sym_S2 )
-            prefac = sym_Ci ? -8.*sin(qr_perp) : 4.*mul_I( exp_I(qr_perp) );
+        if (sym_S2)
+            prefac = sym_Ci ? -8. * sin(qr_perp) : 4. * mul_I(exp_I(qr_perp));
         else
-            prefac = sym_Ci ? 4. : 2.*exp_I(qr_perp);
+            prefac = sym_Ci ? 4. : 2. * exp_I(qr_perp);
 #ifdef POLYHEDRAL_DIAGNOSTIC
-        if( diagnosis.debmsg>=2 )
-            std::cout<<"       qrperp="<<qr_perp<<" => prefac="<<prefac<<"\n";
+        if (diagnosis.debmsg >= 2)
+            std::cout << "       qrperp=" << qr_perp << " => prefac=" << prefac << "\n";
 #endif
-        return prefac * edge_sum_ff( q, qpa, sym_Ci ) / mul_I( qpa.mag2() );
+        return prefac * edge_sum_ff(q, qpa, sym_Ci) / mul_I(qpa.mag2());
     }
 }
 
 //! Returns the two-dimensional form factor of this face, for use in a prism.
 
-complex_t PolyhedralFace::ff_2D(cvector_t qpa ) const
+complex_t PolyhedralFace::ff_2D(cvector_t qpa) const
 {
-    if ( std::abs(qpa.dot(m_normal))>eps*qpa.mag() )
+    if (std::abs(qpa.dot(m_normal)) > eps * qpa.mag())
         throw std::logic_error("ff_2D called with perpendicular q component");
     double qpa_red = m_radius_2d * qpa.mag();
-    if ( qpa_red==0 ) {
+    if (qpa_red == 0) {
         return m_area;
-    } else if ( qpa_red < qpa_limit_series && !sym_S2 ) {
+    } else if (qpa_red < qpa_limit_series && !sym_S2) {
         // summation of power series
-        return m_area + expansion( 1., 1., qpa, std::abs(m_area) );
+        return m_area + expansion(1., 1., qpa, std::abs(m_area));
     } else {
         // direct evaluation of analytic formula
-        complex_t ff = edge_sum_ff( qpa, qpa, false );
-        complex_t ret = (sym_S2 ? 4. : 2./I ) * ff / qpa.mag2();
+        complex_t ff = edge_sum_ff(qpa, qpa, false);
+        complex_t ret = (sym_S2 ? 4. : 2. / I) * ff / qpa.mag2();
 #ifdef POLYHEDRAL_DIAGNOSTIC
-        if( diagnosis.debmsg>=2 )
-            std::cout<<std::setprecision(16)<<"    ret="<<ret<<" ff="<<ff<<"\n";
+        if (diagnosis.debmsg >= 2)
+            std::cout << std::setprecision(16) << "    ret=" << ret << " ff=" << ff << "\n";
 #endif
         return ret;
     }
@@ -395,13 +397,13 @@ complex_t PolyhedralFace::ff_2D(cvector_t qpa ) const
 
 //! Throws if deviation from inversion symmetry is detected. Does not check vertices.
 
-void PolyhedralFace::assert_Ci( const PolyhedralFace& other ) const
+void PolyhedralFace::assert_Ci(const PolyhedralFace& other) const
 {
-    if( std::abs(m_rperp-other.m_rperp)>1e-15*(m_rperp+other.m_rperp) )
+    if (std::abs(m_rperp - other.m_rperp) > 1e-15 * (m_rperp + other.m_rperp))
         throw std::logic_error("Faces with different distance from origin violate symmetry Ci");
-    if( std::abs(m_area-other.m_area)>1e-15*(m_area+other.m_area) )
+    if (std::abs(m_area - other.m_area) > 1e-15 * (m_area + other.m_area))
         throw std::logic_error("Faces with different areas violate symmetry Ci");
-    if( (m_normal+other.m_normal).mag()>1e-14 )
+    if ((m_normal + other.m_normal).mag() > 1e-14)
         throw std::logic_error("Faces do not have opposite orientation, violating symmetry Ci");
 }
 
@@ -410,146 +412,151 @@ void PolyhedralFace::assert_Ci( const PolyhedralFace& other ) const
 //**************************************************************************************************
 
 #ifdef POLYHEDRAL_DIAGNOSTIC
-void FormFactorPolyhedron::setLimits( double _q, int _n ) { q_limit_series=_q; n_limit_series=_n; }
+void FormFactorPolyhedron::setLimits(double _q, int _n)
+{
+    q_limit_series = _q;
+    n_limit_series = _n;
+}
 #endif
 
 //! Called by child classes to set faces and other internal variables.
 
-void FormFactorPolyhedron::setPolyhedron(
-    const PolyhedralTopology& topology, double z_origin, const std::vector<kvector_t>& vertices )
+void FormFactorPolyhedron::setPolyhedron(const PolyhedralTopology& topology, double z_origin,
+                                         const std::vector<kvector_t>& vertices)
 {
     try {
         m_z_origin = z_origin;
         m_sym_Ci = topology.symmetry_Ci;
 
         double diameter = 0;
-        for ( size_t j=0; j<vertices.size(); ++j )
-            for ( size_t jj=j+1; jj<vertices.size(); ++jj )
-                diameter = std::max( diameter, (vertices[j]-vertices[jj]).mag() );
+        for (size_t j = 0; j < vertices.size(); ++j)
+            for (size_t jj = j + 1; jj < vertices.size(); ++jj)
+                diameter = std::max(diameter, (vertices[j] - vertices[jj]).mag());
 
         m_faces.clear();
-        for( const PolygonalTopology& tf: topology.faces ) {
+        for (const PolygonalTopology& tf : topology.faces) {
             std::vector<kvector_t> corners; // of one face
-            for( int i: tf.vertexIndices )
-                corners.push_back( vertices[i] );
-            if( PolyhedralFace::diameter( corners )<= 1e-14*diameter )
+            for (int i : tf.vertexIndices)
+                corners.push_back(vertices[i]);
+            if (PolyhedralFace::diameter(corners) <= 1e-14 * diameter)
                 continue; // skip ridiculously small face
-            m_faces.push_back( PolyhedralFace( corners, tf.symmetry_S2 ) );
+            m_faces.push_back(PolyhedralFace(corners, tf.symmetry_S2));
         }
-        if( m_faces.size() < 4 )
-            throw std::logic_error("Less than four non-vanishing faces" );
+        if (m_faces.size() < 4)
+            throw std::logic_error("Less than four non-vanishing faces");
 
         m_radius = 0;
         m_volume = 0;
-        for( const PolyhedralFace& Gk: m_faces ) {
-            m_radius = std::max( m_radius, Gk.radius3d() );
+        for (const PolyhedralFace& Gk : m_faces) {
+            m_radius = std::max(m_radius, Gk.radius3d());
             m_volume += Gk.pyramidalVolume();
         }
-        if( m_sym_Ci ) {
-            if( m_faces.size()&1 )
+        if (m_sym_Ci) {
+            if (m_faces.size() & 1)
                 throw std::logic_error("Odd #faces violates symmetry Ci");
-            size_t N = m_faces.size()/2;
+            size_t N = m_faces.size() / 2;
             // for this tests, m_faces must be in a specific order
-            for( size_t k=0; k<N; ++k )
-                m_faces[k].assert_Ci( m_faces[2*N-1-k] );
+            for (size_t k = 0; k < N; ++k)
+                m_faces[k].assert_Ci(m_faces[2 * N - 1 - k]);
             // keep only half of the faces
-            m_faces.erase( m_faces.begin()+N, m_faces.end() );
+            m_faces.erase(m_faces.begin() + N, m_faces.end());
         }
     } catch (std::invalid_argument& e) {
-        throw std::invalid_argument( "Invalid parameterization of "+getName()+": "+e.what());
+        throw std::invalid_argument("Invalid parameterization of " + getName() + ": " + e.what());
     } catch (std::logic_error& e) {
-        throw std::logic_error( "Bug in "+getName()+": "+e.what()+
-            " [please report to the maintainers]");
+        throw std::logic_error("Bug in " + getName() + ": " + e.what()
+                               + " [please report to the maintainers]");
     } catch (std::exception& e) {
-        throw std::runtime_error( "Unexpected exception in "+getName()+": "+e.what()+
-            " [please report to the maintainers]");
+        throw std::runtime_error("Unexpected exception in " + getName() + ": " + e.what()
+                                 + " [please report to the maintainers]");
     }
 }
 
 //! Returns the form factor F(q) of this polyhedron, respecting the offset z_origin.
 
-complex_t FormFactorPolyhedron::evaluate_for_q(cvector_t q ) const
+complex_t FormFactorPolyhedron::evaluate_for_q(cvector_t q) const
 {
     try {
-        return exp_I(-m_z_origin*q.z()) * evaluate_centered(q);
+        return exp_I(-m_z_origin * q.z()) * evaluate_centered(q);
     } catch (std::logic_error& e) {
-        throw std::logic_error( "Bug in "+getName()+": "+e.what()+
-            " [please report to the maintainers]");
+        throw std::logic_error("Bug in " + getName() + ": " + e.what()
+                               + " [please report to the maintainers]");
     } catch (std::runtime_error& e) {
-        throw std::runtime_error( "Numeric computation failed in "+getName()+": "+e.what()+
-            " [please report to the maintainers]");
+        throw std::runtime_error("Numeric computation failed in " + getName() + ": " + e.what()
+                                 + " [please report to the maintainers]");
     } catch (std::exception& e) {
-        throw std::runtime_error( "Unexpected exception in "+getName()+": "+e.what()+
-            " [please report to the maintainers]");
+        throw std::runtime_error("Unexpected exception in " + getName() + ": " + e.what()
+                                 + " [please report to the maintainers]");
     }
 }
 
 //! Returns the form factor F(q) of this polyhedron, with origin at z=0.
 
-complex_t FormFactorPolyhedron::evaluate_centered(cvector_t q ) const
+complex_t FormFactorPolyhedron::evaluate_centered(cvector_t q) const
 {
     double q_red = m_radius * q.mag();
 #ifdef POLYHEDRAL_DIAGNOSTIC
     diagnosis.maxOrder = 0;
     diagnosis.nExpandedFaces = 0;
 #endif
-    if( q_red==0 ) {
+    if (q_red == 0) {
         return m_volume;
-    } else if ( q_red < q_limit_series ) {
+    } else if (q_red < q_limit_series) {
         // summation of power series
         complex_t sum = 0;
-        complex_t n_fac = ( m_sym_Ci ? -2 : -1 ) / q.mag2();
+        complex_t n_fac = (m_sym_Ci ? -2 : -1) / q.mag2();
         int count_return_condition = 0;
-        for( int n=2; n<n_limit_series; ++n ) {
-            if( m_sym_Ci && n&1 )
+        for (int n = 2; n < n_limit_series; ++n) {
+            if (m_sym_Ci && n & 1)
                 continue;
 #ifdef POLYHEDRAL_DIAGNOSTIC
-            diagnosis.maxOrder = std::max( diagnosis.maxOrder, n );
+            diagnosis.maxOrder = std::max(diagnosis.maxOrder, n);
 #endif
             complex_t term = 0;
-            for( const PolyhedralFace& Gk: m_faces ) {
-                complex_t tmp = Gk.ff_n( n+1, q );
+            for (const PolyhedralFace& Gk : m_faces) {
+                complex_t tmp = Gk.ff_n(n + 1, q);
                 term += tmp;
 #ifdef POLYHEDRAL_DIAGNOSTIC
-                if( diagnosis.debmsg>=2 )
-                    std::cout<<"Gkffn sum="<<term<<" incr="<<tmp<<"\n";
+                if (diagnosis.debmsg >= 2)
+                    std::cout << "Gkffn sum=" << term << " incr=" << tmp << "\n";
 #endif
             }
             term *= n_fac;
 #ifdef POLYHEDRAL_DIAGNOSTIC
-            if( diagnosis.debmsg>=1 )
-                std::cout<<std::scientific<<std::showpos<<std::setprecision(16)<<
-                    "  SUM="<<m_volume+sum<<" +TERM="<<term<<"\n";
+            if (diagnosis.debmsg >= 1)
+                std::cout << std::scientific << std::showpos << std::setprecision(16)
+                          << "  SUM=" << m_volume + sum << " +TERM=" << term << "\n";
 #endif
             sum += term;
-            if( std::abs(term)<=eps*std::abs(sum) || std::abs(sum)<eps*m_volume )
+            if (std::abs(term) <= eps * std::abs(sum) || std::abs(sum) < eps * m_volume)
                 ++count_return_condition;
             else
                 count_return_condition = 0;
-            if( count_return_condition>2 )
+            if (count_return_condition > 2)
                 return m_volume + sum; // regular exit
             n_fac = m_sym_Ci ? -n_fac : mul_I(n_fac);
         }
 #ifdef POLYHEDRAL_DIAGNOSTIC
-        if( !diagnosis.request_convergence ) {
-            std::cout<<"series F(q) not converged\n";
-            return m_volume+sum;
+        if (!diagnosis.request_convergence) {
+            std::cout << "series F(q) not converged\n";
+            return m_volume + sum;
         }
 #endif
         throw std::runtime_error("Series F(q) not converged");
     } else {
         // direct evaluation of analytic formula (coefficients may involve series)
         complex_t sum = 0;
-        for( const PolyhedralFace& Gk: m_faces ) {
-            complex_t qn = Gk.normalProjectionConj( q ); // conj(q)*normal
-            if ( std::abs(qn)<eps*q.mag() )
+        for (const PolyhedralFace& Gk : m_faces) {
+            complex_t qn = Gk.normalProjectionConj(q); // conj(q)*normal
+            if (std::abs(qn) < eps * q.mag())
                 continue;
-            complex_t ff = Gk.ff(q, m_sym_Ci );
+            complex_t ff = Gk.ff(q, m_sym_Ci);
             sum += qn * ff;
 #ifdef POLYHEDRAL_DIAGNOSTIC
-            if( diagnosis.debmsg>=1 )
-                std::cout<<std::scientific<<std::showpos<<std::setprecision(16)<<"  SUM="<<sum<<
-                    " TERM="<<qn*ff<<" qn="<<qn.real()<<" ff="<<ff<<"\n";
+            if (diagnosis.debmsg >= 1)
+                std::cout << std::scientific << std::showpos << std::setprecision(16)
+                          << "  SUM=" << sum << " TERM=" << qn * ff << " qn=" << qn.real()
+                          << " ff=" << ff << "\n";
 #endif
         }
         return sum / (I * q.mag2());
@@ -562,85 +569,87 @@ void FormFactorPolyhedron::assert_platonic() const
 {
     // just one test; one could do much more ...
     double pyramidal_volume = 0;
-    for( const auto& Gk: m_faces )
+    for (const auto& Gk : m_faces)
         pyramidal_volume += Gk.pyramidalVolume();
     pyramidal_volume /= m_faces.size();
-    for( const auto& Gk: m_faces )
-        if (std::abs(Gk.pyramidalVolume()-pyramidal_volume) > 160*eps*pyramidal_volume) {
-            std::cerr<<std::setprecision(16)<<"Bug: pyr_volume(this face)="<<
-                Gk.pyramidalVolume()<<" vs pyr_volume(avge)="<<pyramidal_volume<<"\n";
-            throw std::runtime_error("Deviant pyramidal volume in "+getName());
+    for (const auto& Gk : m_faces)
+        if (std::abs(Gk.pyramidalVolume() - pyramidal_volume) > 160 * eps * pyramidal_volume) {
+            std::cerr << std::setprecision(16)
+                      << "Bug: pyr_volume(this face)=" << Gk.pyramidalVolume()
+                      << " vs pyr_volume(avge)=" << pyramidal_volume << "\n";
+            throw std::runtime_error("Deviant pyramidal volume in " + getName());
         }
 }
 
-
 //**************************************************************************************************
 //  FormFactorPolygonalPrism implementation
 //**************************************************************************************************
 
-void FormFactorPolygonalPrism::setPrism( bool symmetry_Ci, const std::vector<kvector_t>& vertices )
+void FormFactorPolygonalPrism::setPrism(bool symmetry_Ci, const std::vector<kvector_t>& vertices)
 {
     try {
-        m_base = std::unique_ptr<PolyhedralFace>( new PolyhedralFace( vertices, symmetry_Ci ) );
+        m_base = std::unique_ptr<PolyhedralFace>(new PolyhedralFace(vertices, symmetry_Ci));
     } catch (std::invalid_argument& e) {
-        throw std::invalid_argument( "Invalid parameterization of "+getName()+": "+e.what());
+        throw std::invalid_argument("Invalid parameterization of " + getName() + ": " + e.what());
     } catch (std::logic_error& e) {
-        throw std::logic_error( "Bug in "+getName()+": "+e.what()+
-            " [please report to the maintainers]");
+        throw std::logic_error("Bug in " + getName() + ": " + e.what()
+                               + " [please report to the maintainers]");
     } catch (std::exception& e) {
-        throw std::runtime_error( "Unexpected exception in "+getName()+": "+e.what()+
-            " [please report to the maintainers]");
+        throw std::runtime_error("Unexpected exception in " + getName() + ": " + e.what()
+                                 + " [please report to the maintainers]");
     }
 }
 
 //! Returns the volume of this prism.
-double FormFactorPolygonalPrism::volume() const { return m_height * m_base->area(); }
+double FormFactorPolygonalPrism::volume() const
+{
+    return m_height * m_base->area();
+}
 
 //! Returns the form factor F(q) of this polyhedron, respecting the offset height/2.
 
-complex_t FormFactorPolygonalPrism::evaluate_for_q(cvector_t q ) const
+complex_t FormFactorPolygonalPrism::evaluate_for_q(cvector_t q) const
 {
     try {
 #ifdef POLYHEDRAL_DIAGNOSTIC
         diagnosis.maxOrder = 0;
         diagnosis.nExpandedFaces = 0;
 #endif
-        cvector_t qxy( q.x(), q.y(), 0. );
-        return m_height * exp_I(m_height/2*q.z()) * MathFunctions::sinc(m_height/2*q.z()) *
-            m_base->ff_2D( qxy );
+        cvector_t qxy(q.x(), q.y(), 0.);
+        return m_height * exp_I(m_height / 2 * q.z()) * MathFunctions::sinc(m_height / 2 * q.z())
+               * m_base->ff_2D(qxy);
     } catch (std::logic_error& e) {
-        throw std::logic_error( "Bug in "+getName()+": "+e.what()+
-            " [please report to the maintainers]");
+        throw std::logic_error("Bug in " + getName() + ": " + e.what()
+                               + " [please report to the maintainers]");
     } catch (std::runtime_error& e) {
-        throw std::runtime_error( "Numeric computation failed in "+getName()+": "+e.what()+
-            " [please report to the maintainers]");
+        throw std::runtime_error("Numeric computation failed in " + getName() + ": " + e.what()
+                                 + " [please report to the maintainers]");
     } catch (std::exception& e) {
-        throw std::runtime_error( "Unexpected exception in "+getName()+": "+e.what()+
-            " [please report to the maintainers]");
+        throw std::runtime_error("Unexpected exception in " + getName() + ": " + e.what()
+                                 + " [please report to the maintainers]");
     }
 }
 
-
 //**************************************************************************************************
 //  FormFactorPolygonalSurface implementation
 //**************************************************************************************************
 
-complex_t FormFactorPolygonalSurface::evaluate_for_q(cvector_t q ) const
+complex_t FormFactorPolygonalSurface::evaluate_for_q(cvector_t q) const
 {
     try {
 #ifdef POLYHEDRAL_DIAGNOSTIC
         diagnosis.maxOrder = 0;
         diagnosis.nExpandedFaces = 0;
 #endif
-        return m_base->ff( q, false );
+        return m_base->ff(q, false);
     } catch (std::logic_error& e) {
-        throw std::logic_error( "Bug in "+getName()+": "+e.what()+
-            " [please report to the maintainers]");
+        throw std::logic_error("Bug in " + getName() + ": " + e.what()
+                               + " [please report to the maintainers]");
     } catch (std::runtime_error& e) {
-        throw std::runtime_error( "Numeric computation failed in "+getName()+": "+e.what()+
-            " [please report to the maintainers]");
+        throw std::runtime_error("Numeric computation failed in " + getName() + ": " + e.what()
+                                 + " [please report to the maintainers]");
     } catch (std::exception& e) {
-        throw std::runtime_error( "Unexpected exception in "+getName()+": "+e.what()+
-            " [please report to the maintainers]");
+        throw std::runtime_error("Unexpected exception in " + getName() + ": " + e.what()
+                                 + " [please report to the maintainers]");
     }
 }
diff --git a/Core/HardParticle/FormFactorPolyhedron.h b/Core/HardParticle/FormFactorPolyhedron.h
index 76a553b3c1b..0b575727991 100644
--- a/Core/HardParticle/FormFactorPolyhedron.h
+++ b/Core/HardParticle/FormFactorPolyhedron.h
@@ -19,14 +19,16 @@
 #include <memory>
 
 //! For internal use in PolyhedralFace.
-class PolygonalTopology {
+class PolygonalTopology
+{
 public:
     std::vector<int> vertexIndices;
     bool symmetry_S2;
 };
 
 //! For internal use in FormFactorPolyhedron.
-class PolyhedralTopology {
+class PolyhedralTopology
+{
 public:
     std::vector<PolygonalTopology> faces;
     bool symmetry_Ci;
@@ -34,14 +36,15 @@ public:
 
 //! One edge of a polygon, for form factor computation.
 
-class PolyhedralEdge {
+class PolyhedralEdge
+{
 public:
     PolyhedralEdge(const kvector_t _Vlow, const kvector_t _Vhig);
 
     kvector_t E() const { return m_E; }
     kvector_t R() const { return m_R; }
-    complex_t qE( cvector_t q ) const { return m_E.dot(q); }
-    complex_t qR( cvector_t q ) const { return m_R.dot(q); }
+    complex_t qE(cvector_t q) const { return m_E.dot(q); }
+    complex_t qR(cvector_t q) const { return m_R.dot(q); }
 
     complex_t contrib(int m, cvector_t qpa, complex_t qrperp) const;
 
@@ -50,21 +53,22 @@ private:
     kvector_t m_R; //!< position vector of edge midpoint
 };
 
-
 //! A polygon, for form factor computation.
 
-class PolyhedralFace {
+class PolyhedralFace
+{
 public:
     static double diameter(const std::vector<kvector_t>& V);
 #ifdef POLYHEDRAL_DIAGNOSTIC
     static void setLimits(double _qpa, int _n);
 #endif
 
-    PolyhedralFace( const std::vector<kvector_t>& _V=std::vector<kvector_t>(), bool _sym_S2=false );
+    PolyhedralFace(const std::vector<kvector_t>& _V = std::vector<kvector_t>(),
+                   bool _sym_S2 = false);
 
     double area() const { return m_area; }
     kvector_t center() const { return m_center; }
-    double pyramidalVolume() const { return m_rperp*m_area/3; }
+    double pyramidalVolume() const { return m_rperp * m_area / 3; }
     double radius3d() const { return m_radius_3d; }
     //! Returns conj(q)*normal [BasicVector3D::dot is antilinear in 'this' argument]
     complex_t normalProjectionConj(cvector_t q) const { return q.dot(m_normal); }
@@ -81,7 +85,7 @@ private:
     std::vector<PolyhedralEdge> edges;
     double m_area;
     kvector_t m_normal; //!< normal vector of this polygon's plane
-    double m_rperp; //!< distance of this polygon's plane from the origin, along 'm_normal'
+    double m_rperp;     //!< distance of this polygon's plane from the origin, along 'm_normal'
     double m_radius_2d; //!< radius of enclosing cylinder
     double m_radius_3d; //!< radius of enclosing sphere
     kvector_t m_center; //!< center of mass
@@ -89,17 +93,17 @@ private:
     void decompose_q(cvector_t q, complex_t& qperp, cvector_t& qpa) const;
     complex_t ff_n_core(int m, cvector_t qpa, complex_t qperp) const;
     complex_t edge_sum_ff(cvector_t q, cvector_t qpa, bool sym_Ci) const;
-    complex_t expansion(
-        complex_t fac_even, complex_t fac_odd, cvector_t qpa, double abslevel ) const;
+    complex_t expansion(complex_t fac_even, complex_t fac_odd, cvector_t qpa,
+                        double abslevel) const;
 };
 
-
 //! A polyhedron, for form factor computation.
 
-class BA_CORE_API_ FormFactorPolyhedron : public IFormFactorBorn {
+class BA_CORE_API_ FormFactorPolyhedron : public IFormFactorBorn
+{
 public:
 #ifdef POLYHEDRAL_DIAGNOSTIC
-    static void setLimits( double _q, int _n );
+    static void setLimits(double _q, int _n);
 #endif
 
     FormFactorPolyhedron() {}
@@ -127,10 +131,10 @@ private:
     double m_volume;
 };
 
-
 //! A prism with a polygonal base, for form factor computation.
 
-class BA_CORE_API_ FormFactorPolygonalPrism : public IFormFactorBorn {
+class BA_CORE_API_ FormFactorPolygonalPrism : public IFormFactorBorn
+{
 public:
     FormFactorPolygonalPrism(double height) : m_height(height) {}
 
@@ -142,13 +146,13 @@ public:
 protected:
     std::unique_ptr<PolyhedralFace> m_base;
     double m_height;
-    void setPrism( bool symmetry_Ci, const std::vector<kvector_t>& vertices );
+    void setPrism(bool symmetry_Ci, const std::vector<kvector_t>& vertices);
 };
 
-
 //! A polygonal surface, for testing form factor computations.
 
-class BA_CORE_API_ FormFactorPolygonalSurface : public IFormFactorBorn {
+class BA_CORE_API_ FormFactorPolygonalSurface : public IFormFactorBorn
+{
 public:
     FormFactorPolygonalSurface() {}
 
diff --git a/Core/HardParticle/FormFactorPrism3.cpp b/Core/HardParticle/FormFactorPrism3.cpp
index 49d8448aeac..11b0a7b9697 100644
--- a/Core/HardParticle/FormFactorPrism3.cpp
+++ b/Core/HardParticle/FormFactorPrism3.cpp
@@ -22,13 +22,13 @@
 //! @param base_edge: length of the base edge in nanometers
 //! @param height: height in nanometers
 FormFactorPrism3::FormFactorPrism3(double base_edge, double height)
-    : FormFactorPolygonalPrism( height ), m_base_edge( base_edge )
+    : FormFactorPolygonalPrism(height), m_base_edge(base_edge)
 {
     setName(BornAgain::FFPrism3Type);
-    registerParameter(BornAgain::BaseEdge, &m_base_edge).setUnit(BornAgain::UnitsNm)
-        .setNonnegative();
-    registerParameter(BornAgain::Height, &m_height).setUnit(BornAgain::UnitsNm)
+    registerParameter(BornAgain::BaseEdge, &m_base_edge)
+        .setUnit(BornAgain::UnitsNm)
         .setNonnegative();
+    registerParameter(BornAgain::Height, &m_height).setUnit(BornAgain::UnitsNm).setNonnegative();
     onChange();
 }
 
@@ -38,19 +38,15 @@ IFormFactor* FormFactorPrism3::sliceFormFactor(ZLimits limits, const IRotation&
     auto effects = computeSlicingEffects(limits, translation, m_height);
     FormFactorPrism3 slicedff(m_base_edge, m_height - effects.dz_bottom - effects.dz_top);
     return CreateTransformedFormFactor(slicedff, rot, effects.position);
-
 }
 
 void FormFactorPrism3::onChange()
 {
     mP_shape.reset(new Pyramid3(m_base_edge, m_height, M_PI_2));
     double a = m_base_edge;
-    double as = a/2;
-    double ac = a/sqrt(3)/2;
-    double ah = a/sqrt(3);
-    std::vector<kvector_t> V {
-        { -ac,  as, 0. },
-        { -ac, -as, 0. },
-        {  ah,  0., 0. } };
-    setPrism( false, V );
+    double as = a / 2;
+    double ac = a / sqrt(3) / 2;
+    double ah = a / sqrt(3);
+    std::vector<kvector_t> V{{-ac, as, 0.}, {-ac, -as, 0.}, {ah, 0., 0.}};
+    setPrism(false, V);
 }
diff --git a/Core/HardParticle/FormFactorPrism3.h b/Core/HardParticle/FormFactorPrism3.h
index a7bc01be023..22950cbc58b 100644
--- a/Core/HardParticle/FormFactorPrism3.h
+++ b/Core/HardParticle/FormFactorPrism3.h
@@ -24,9 +24,11 @@ class BA_CORE_API_ FormFactorPrism3 : public FormFactorPolygonalPrism
 public:
     FormFactorPrism3(double base_edge, double height);
 
-    FormFactorPrism3 *clone() const override final {
-        return new FormFactorPrism3(m_base_edge, m_height); }
-    void accept(INodeVisitor *visitor) const override final { visitor->visit(this); }
+    FormFactorPrism3* clone() const override final
+    {
+        return new FormFactorPrism3(m_base_edge, m_height);
+    }
+    void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     double getBaseEdge() const { return m_base_edge; }
 
diff --git a/Core/HardParticle/FormFactorPrism6.cpp b/Core/HardParticle/FormFactorPrism6.cpp
index eda881bda31..885e0e698dd 100644
--- a/Core/HardParticle/FormFactorPrism6.cpp
+++ b/Core/HardParticle/FormFactorPrism6.cpp
@@ -21,14 +21,13 @@
 //! @param base_edge: length of the hexagonal base in nanometers
 //! @param height: height in nanometers
 FormFactorPrism6::FormFactorPrism6(double base_edge, double height)
-    : FormFactorPolygonalPrism( height )
-    , m_base_edge(base_edge)
+    : FormFactorPolygonalPrism(height), m_base_edge(base_edge)
 {
     setName(BornAgain::FFPrism6Type);
-    registerParameter(BornAgain::BaseEdge, &m_base_edge).setUnit(BornAgain::UnitsNm)
-        .setNonnegative();
-    registerParameter(BornAgain::Height, &m_height).setUnit(BornAgain::UnitsNm)
+    registerParameter(BornAgain::BaseEdge, &m_base_edge)
+        .setUnit(BornAgain::UnitsNm)
         .setNonnegative();
+    registerParameter(BornAgain::Height, &m_height).setUnit(BornAgain::UnitsNm).setNonnegative();
     onChange();
 }
 
@@ -44,14 +43,9 @@ void FormFactorPrism6::onChange()
 {
     mP_shape.reset(new Pyramid6(m_base_edge, m_height, M_PI_2));
     double a = m_base_edge;
-    double as = a*sqrt(3)/2;
-    double ac = a/2;
-    std::vector<kvector_t> V {
-        {  a,   0., 0. },
-        {  ac,  as, 0. },
-        { -ac,  as, 0. },
-        { -a,   0., 0. },
-        { -ac, -as, 0. },
-        {  ac, -as, 0. } };
-    setPrism( true, V );
+    double as = a * sqrt(3) / 2;
+    double ac = a / 2;
+    std::vector<kvector_t> V{{a, 0., 0.},  {ac, as, 0.},   {-ac, as, 0.},
+                             {-a, 0., 0.}, {-ac, -as, 0.}, {ac, -as, 0.}};
+    setPrism(true, V);
 }
diff --git a/Core/HardParticle/FormFactorPrism6.h b/Core/HardParticle/FormFactorPrism6.h
index bb246ee7e8e..0cd0861d3fe 100644
--- a/Core/HardParticle/FormFactorPrism6.h
+++ b/Core/HardParticle/FormFactorPrism6.h
@@ -24,9 +24,11 @@ class BA_CORE_API_ FormFactorPrism6 : public FormFactorPolygonalPrism
 public:
     FormFactorPrism6(double base_edge, double height);
 
-    FormFactorPrism6 *clone() const override final {
-        return new FormFactorPrism6(m_base_edge, m_height); }
-    void accept(INodeVisitor *visitor) const override final { visitor->visit(this); }
+    FormFactorPrism6* clone() const override final
+    {
+        return new FormFactorPrism6(m_base_edge, m_height);
+    }
+    void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     double getBaseEdge() const { return m_base_edge; }
 
diff --git a/Core/HardParticle/FormFactorPyramid.cpp b/Core/HardParticle/FormFactorPyramid.cpp
index 370853d6213..e525e4f37a8 100644
--- a/Core/HardParticle/FormFactorPyramid.cpp
+++ b/Core/HardParticle/FormFactorPyramid.cpp
@@ -16,36 +16,33 @@
 #include "AnisoPyramid.h"
 #include "BornAgainNamespace.h"
 #include "Exceptions.h"
-#include "MathFunctions.h"
 #include "MathConstants.h"
+#include "MathFunctions.h"
 #include "RealParameter.h"
 
-const PolyhedralTopology FormFactorPyramid::topology = {
-    {
-        { { 3, 2, 1, 0 }, true  }, // TODO -> true
-        { { 0, 1, 5, 4 }, false },
-        { { 1, 2, 6, 5 }, false },
-        { { 2, 3, 7, 6 }, false },
-        { { 3, 0, 4, 7 }, false },
-        { { 4, 5, 6, 7 }, true  }  // TODO -> true
-    }, false };
+const PolyhedralTopology FormFactorPyramid::topology = {{
+                                                            {{3, 2, 1, 0}, true}, // TODO -> true
+                                                            {{0, 1, 5, 4}, false},
+                                                            {{1, 2, 6, 5}, false},
+                                                            {{2, 3, 7, 6}, false},
+                                                            {{3, 0, 4, 7}, false},
+                                                            {{4, 5, 6, 7}, true} // TODO -> true
+                                                        },
+                                                        false};
 
 //! Constructor of a truncated pyramid with a square base
 //! @param base_edge: length of the square base in nanometers
 //! @param height: height of the pyramid in nanometers
 //! @param alpha: dihedral angle between the base and a side face in radians
 FormFactorPyramid::FormFactorPyramid(double base_edge, double height, double alpha)
-    : FormFactorPolyhedron()
-    , m_base_edge(base_edge)
-    , m_height(height)
-    , m_alpha(alpha)
+    : FormFactorPolyhedron(), m_base_edge(base_edge), m_height(height), m_alpha(alpha)
 {
     setName(BornAgain::FFPyramidType);
-    registerParameter(BornAgain::BaseEdge, &m_base_edge).setUnit(BornAgain::UnitsNm)
+    registerParameter(BornAgain::BaseEdge, &m_base_edge)
+        .setUnit(BornAgain::UnitsNm)
         .setNonnegative();
     registerParameter(BornAgain::Height, &m_height).setUnit(BornAgain::UnitsNm).setNonnegative();
-    registerParameter(BornAgain::Alpha, & m_alpha).setUnit(BornAgain::UnitsRad)
-        .setLimited(0., M_PI);
+    registerParameter(BornAgain::Alpha, &m_alpha).setUnit(BornAgain::UnitsRad).setLimited(0., M_PI);
     onChange();
 }
 
@@ -53,7 +50,7 @@ IFormFactor* FormFactorPyramid::sliceFormFactor(ZLimits limits, const IRotation&
                                                 kvector_t translation) const
 {
     auto effects = computeSlicingEffects(limits, translation, m_height);
-    double dbase_edge = 2*effects.dz_bottom*MathFunctions::cot(m_alpha);
+    double dbase_edge = 2 * effects.dz_bottom * MathFunctions::cot(m_alpha);
     FormFactorPyramid slicedff(m_base_edge - dbase_edge,
                                m_height - effects.dz_bottom - effects.dz_top, m_alpha);
     return CreateTransformedFormFactor(slicedff, rot, effects.position);
@@ -62,10 +59,10 @@ IFormFactor* FormFactorPyramid::sliceFormFactor(ZLimits limits, const IRotation&
 void FormFactorPyramid::onChange()
 {
     double cot_alpha = MathFunctions::cot(m_alpha);
-    if( !std::isfinite(cot_alpha) )
+    if (!std::isfinite(cot_alpha))
         throw Exceptions::OutOfBoundsException("pyramid angle alpha out of bounds");
-    double r = cot_alpha*2 * m_height / m_base_edge; // [L(base)-L(top)]/L(base)
-    if ( r > 1 ) {
+    double r = cot_alpha * 2 * m_height / m_base_edge; // [L(base)-L(top)]/L(base)
+    if (r > 1) {
         std::ostringstream ostr;
         ostr << "FormFactorPyramid() -> Error in class initialization with parameters";
         ostr << " base_edge:" << m_base_edge;
@@ -76,20 +73,20 @@ void FormFactorPyramid::onChange()
     }
     mP_shape.reset(new AnisoPyramid(m_base_edge, m_base_edge, m_height, m_alpha));
 
-    double a = m_base_edge/2;
-    double b = a * (1-r);
+    double a = m_base_edge / 2;
+    double b = a * (1 - r);
 
-    double zcom = m_height * ( .5 - 2*r/3 + r*r/4 ) / ( 1 - r + r*r/3 ); // center of mass
+    double zcom = m_height * (.5 - 2 * r / 3 + r * r / 4) / (1 - r + r * r / 3); // center of mass
 
-    setPolyhedron( topology, -zcom, {
-            // base:
-            { -a, -a, -zcom },
-            {  a, -a, -zcom },
-            {  a,  a, -zcom },
-            { -a,  a, -zcom },
-            // top:
-            { -b, -b, m_height-zcom },
-            {  b, -b, m_height-zcom },
-            {  b,  b, m_height-zcom },
-            { -b,  b, m_height-zcom } } );
+    setPolyhedron(topology, -zcom,
+                  {// base:
+                   {-a, -a, -zcom},
+                   {a, -a, -zcom},
+                   {a, a, -zcom},
+                   {-a, a, -zcom},
+                   // top:
+                   {-b, -b, m_height - zcom},
+                   {b, -b, m_height - zcom},
+                   {b, b, m_height - zcom},
+                   {-b, b, m_height - zcom}});
 }
diff --git a/Core/HardParticle/FormFactorPyramid.h b/Core/HardParticle/FormFactorPyramid.h
index 94bd8453afd..acac74706e5 100644
--- a/Core/HardParticle/FormFactorPyramid.h
+++ b/Core/HardParticle/FormFactorPyramid.h
@@ -25,9 +25,11 @@ class BA_CORE_API_ FormFactorPyramid : public FormFactorPolyhedron
 public:
     FormFactorPyramid(double base_edge, double height, double alpha);
 
-    FormFactorPyramid* clone() const override final {
-        return new FormFactorPyramid(m_base_edge, m_height, m_alpha); }
-    void accept(INodeVisitor *visitor) const override final { visitor->visit(this); }
+    FormFactorPyramid* clone() const override final
+    {
+        return new FormFactorPyramid(m_base_edge, m_height, m_alpha);
+    }
+    void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     double getHeight() const { return m_height; }
     double getBaseEdge() const { return m_base_edge; }
diff --git a/Core/HardParticle/FormFactorRipple1.cpp b/Core/HardParticle/FormFactorRipple1.cpp
index 8b1b2dc83be..3246a0a1817 100644
--- a/Core/HardParticle/FormFactorRipple1.cpp
+++ b/Core/HardParticle/FormFactorRipple1.cpp
@@ -15,9 +15,9 @@
 #include "FormFactorRipple1.h"
 #include "BornAgainNamespace.h"
 #include "Exceptions.h"
-#include "RealLimits.h"
-#include "MathFunctions.h"
 #include "MathConstants.h"
+#include "MathFunctions.h"
+#include "RealLimits.h"
 #include "RealParameter.h"
 #include "RippleCosine.h"
 
@@ -40,7 +40,7 @@ FormFactorRipple1::FormFactorRipple1(double length, double width, double height)
 bool FormFactorRipple1::check_initialization() const
 {
     bool result(true);
-    if(m_height <=0.0 || m_width<=0.0 || m_length<=0.0) {
+    if (m_height <= 0.0 || m_width <= 0.0 || m_length <= 0.0) {
         std::ostringstream ostr;
         ostr << "FormFactorRipple1() -> Error in class initialization with parameters ";
         ostr << " height:" << m_height;
@@ -54,36 +54,37 @@ bool FormFactorRipple1::check_initialization() const
 
 double FormFactorRipple1::radialExtension() const
 {
-    return ( m_width + m_length ) / 4.0;
+    return (m_width + m_length) / 4.0;
 }
 
 //! Integrand for complex formfactor.
 complex_t FormFactorRipple1::Integrand(double u) const
 {
-    return sin(u) * exp(m_az*std::cos(u)) * ( m_ay==0. ? u : sin(m_ay*u)/m_ay );
+    return sin(u) * exp(m_az * std::cos(u)) * (m_ay == 0. ? u : sin(m_ay * u) / m_ay);
 }
 
 //! Complex formfactor.
 complex_t FormFactorRipple1::evaluate_for_q(cvector_t q) const
 {
-    complex_t factor = m_length*MathFunctions::sinc(q.x()*m_length*0.5)*m_width/M_PI;
+    complex_t factor = m_length * MathFunctions::sinc(q.x() * m_length * 0.5) * m_width / M_PI;
 
     // analytical expressions for some particular cases
-    if ( q.z()==0. ) {
-        if( q.y()==0. )
-            return factor*M_PI_2*m_height;
-        complex_t aaa = q.y()*m_width/(M_TWOPI);
-        complex_t aaa2 = aaa*aaa;
-        if ( aaa2==1. )
-            return factor*M_PI_4*m_height;
-        return factor*M_PI_2*m_height*MathFunctions::sinc(q.y()*m_width*0.5)/(1.0-aaa2);
+    if (q.z() == 0.) {
+        if (q.y() == 0.)
+            return factor * M_PI_2 * m_height;
+        complex_t aaa = q.y() * m_width / (M_TWOPI);
+        complex_t aaa2 = aaa * aaa;
+        if (aaa2 == 1.)
+            return factor * M_PI_4 * m_height;
+        return factor * M_PI_2 * m_height * MathFunctions::sinc(q.y() * m_width * 0.5)
+               / (1.0 - aaa2);
     }
 
     // numerical integration otherwise
     m_ay = q.y() * m_width / M_TWOPI;
-    m_az = complex_t(0,1) * q.z() * (m_height/2);
+    m_az = complex_t(0, 1) * q.z() * (m_height / 2);
     complex_t integral = mP_integrator->integrate(0, M_PI);
-    return factor * integral * exp(m_az) * (m_height/2);
+    return factor * integral * exp(m_az) * (m_height / 2);
 }
 
 void FormFactorRipple1::onChange()
diff --git a/Core/HardParticle/FormFactorRipple1.h b/Core/HardParticle/FormFactorRipple1.h
index 4ec8684d8c4..8ed565a067d 100644
--- a/Core/HardParticle/FormFactorRipple1.h
+++ b/Core/HardParticle/FormFactorRipple1.h
@@ -26,8 +26,10 @@ class BA_CORE_API_ FormFactorRipple1 : public IFormFactorBorn
 public:
     FormFactorRipple1(double length, double width, double height);
 
-    FormFactorRipple1* clone() const override final {
-        return new FormFactorRipple1(m_length, m_width, m_height); }
+    FormFactorRipple1* clone() const override final
+    {
+        return new FormFactorRipple1(m_length, m_width, m_height);
+    }
     void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     double getLength() const { return m_length; }
diff --git a/Core/HardParticle/FormFactorRipple2.cpp b/Core/HardParticle/FormFactorRipple2.cpp
index f8c2ad9acac..91c569e6474 100644
--- a/Core/HardParticle/FormFactorRipple2.cpp
+++ b/Core/HardParticle/FormFactorRipple2.cpp
@@ -38,13 +38,13 @@ FormFactorRipple2::FormFactorRipple2(double length, double width, double height,
 
 double FormFactorRipple2::radialExtension() const
 {
-    return ( m_width + m_length ) / 4.0;
+    return (m_width + m_length) / 4.0;
 }
 
 //! Complex formfactor.
 complex_t FormFactorRipple2::evaluate_for_q(cvector_t q) const
 {
-    complex_t factor = m_length * MathFunctions::sinc(q.x()*m_length/2.) * m_height * m_width;
+    complex_t factor = m_length * MathFunctions::sinc(q.x() * m_length / 2.) * m_height * m_width;
     complex_t result;
     const complex_t qyW2 = q.y() * m_width * 0.5;
     const complex_t qyd = q.y() * m_d;
@@ -54,20 +54,20 @@ complex_t FormFactorRipple2::evaluate_for_q(cvector_t q) const
     const double a_scale = std::abs(a);
     const double w_scale = std::abs(qyW2);
 
-    if (w_scale < 1.e-5) { // |q_y*W| << 1
+    if (w_scale < 1.e-5) {    // |q_y*W| << 1
         if (a_scale < 1e-5) { // |q_y*W| << 1 && |q_z*H + q_y*d| << 1
             // relative error is O((q_y*W)^2) and O((q_z*H + q_y*d)^2)
-            result = exp_I(-qyd)*(0.5 + mul_I(a)/6.);
+            result = exp_I(-qyd) * (0.5 + mul_I(a) / 6.);
         } else {
             // relative error is O((q_y*W)^2)
-            result = exp_I(-qyd)*(1.0 + mul_I(a) - exp_I(a)) / (a * a);
+            result = exp_I(-qyd) * (1.0 + mul_I(a) - exp_I(a)) / (a * a);
         }
     } else {
         const complex_t gamma_p = (a + qyW2) * 0.5;
         const complex_t gamma_m = (a - qyW2) * 0.5;
         result = exp_I(gamma_m) * MathFunctions::sinc(gamma_p)
-               - exp_I(gamma_p) * MathFunctions::sinc(gamma_m);
-        result = mul_I(exp_I(-qyd)*result / (qyW2*2.));
+                 - exp_I(gamma_p) * MathFunctions::sinc(gamma_m);
+        result = mul_I(exp_I(-qyd) * result / (qyW2 * 2.));
     }
     return factor * result;
 }
@@ -81,20 +81,20 @@ bool FormFactorRipple2::check_initialization() const
 {
     bool result(true);
     std::string message;
-    if(-1*m_width > 2.*m_d) {
+    if (-1 * m_width > 2. * m_d) {
         result = false;
         message = std::string("Check for '-1*width <= 2.*asymmetry' failed.");
     }
-    if(m_width < 2.*m_d) {
+    if (m_width < 2. * m_d) {
         result = false;
         message = std::string("Check for 'width >= 2.*asymmetry' failed.");
     }
-    if(m_height <=0) {
+    if (m_height <= 0) {
         result = false;
         message = std::string("Check for 'height > 0' failed.");
     }
 
-    if(!result) {
+    if (!result) {
         std::ostringstream ostr;
         ostr << "FormFactorRipple2() -> Error in class initialization with parameters ";
         ostr << " width:" << m_width;
diff --git a/Core/HardParticle/FormFactorRipple2.h b/Core/HardParticle/FormFactorRipple2.h
index e6a074a608f..86cb37110df 100644
--- a/Core/HardParticle/FormFactorRipple2.h
+++ b/Core/HardParticle/FormFactorRipple2.h
@@ -25,9 +25,11 @@ class BA_CORE_API_ FormFactorRipple2 : public IFormFactorBorn
 public:
     FormFactorRipple2(double length, double width, double height, double asymmetry);
 
-    FormFactorRipple2 *clone() const override final {
-        return new FormFactorRipple2(m_length, m_width, m_height, m_d); }
-    void accept(INodeVisitor *visitor) const override final { visitor->visit(this); }
+    FormFactorRipple2* clone() const override final
+    {
+        return new FormFactorRipple2(m_length, m_width, m_height, m_d);
+    }
+    void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     double getHeight() const { return m_height; }
     double getWidth() const { return m_width; }
diff --git a/Core/HardParticle/FormFactorTetrahedron.cpp b/Core/HardParticle/FormFactorTetrahedron.cpp
index 16b9ef88783..78162e4d83c 100644
--- a/Core/HardParticle/FormFactorTetrahedron.cpp
+++ b/Core/HardParticle/FormFactorTetrahedron.cpp
@@ -15,37 +15,32 @@
 #include "FormFactorTetrahedron.h"
 #include "BornAgainNamespace.h"
 #include "Exceptions.h"
-#include "MathFunctions.h"
 #include "MathConstants.h"
+#include "MathFunctions.h"
 #include "Pyramid3.h"
 #include "RealParameter.h"
 
-const PolyhedralTopology FormFactorTetrahedron::topology = {
-    {
-        { { 2, 1, 0 }, false },
-        { { 0, 1, 4, 3 }, false },
-        { { 1, 2, 5, 4 }, false },
-        { { 2, 0, 3, 5 }, false },
-        { { 3, 4, 5 }, false }
-    }, false };
-
+const PolyhedralTopology FormFactorTetrahedron::topology = {{{{2, 1, 0}, false},
+                                                             {{0, 1, 4, 3}, false},
+                                                             {{1, 2, 5, 4}, false},
+                                                             {{2, 0, 3, 5}, false},
+                                                             {{3, 4, 5}, false}},
+                                                            false};
 
 //! Constructor of a truncated tethrahedron.
 //! @param base_edge: length of one edge of the equilateral triangular base in nanometers
 //! @param height: height of the tetrahedron in nanometers
 //! @param alpha: dihedral angle in radians between base and facet
 FormFactorTetrahedron::FormFactorTetrahedron(double base_edge, double height, double alpha)
-    : FormFactorPolyhedron()
-    , m_base_edge(base_edge)
-    , m_height(height)
-    , m_alpha(alpha)
+    : FormFactorPolyhedron(), m_base_edge(base_edge), m_height(height), m_alpha(alpha)
 {
     setName(BornAgain::FFTetrahedronType);
-    registerParameter(BornAgain::BaseEdge, &m_base_edge).setUnit(BornAgain::UnitsNm)
-        .setNonnegative();
-    registerParameter(BornAgain::Height, &m_height).setUnit(BornAgain::UnitsNm)
+    registerParameter(BornAgain::BaseEdge, &m_base_edge)
+        .setUnit(BornAgain::UnitsNm)
         .setNonnegative();
-    registerParameter(BornAgain::Alpha, &m_alpha).setUnit(BornAgain::UnitsRad)
+    registerParameter(BornAgain::Height, &m_height).setUnit(BornAgain::UnitsNm).setNonnegative();
+    registerParameter(BornAgain::Alpha, &m_alpha)
+        .setUnit(BornAgain::UnitsRad)
         .setLimited(0., M_PI_2);
     onChange();
 }
@@ -54,7 +49,7 @@ IFormFactor* FormFactorTetrahedron::sliceFormFactor(ZLimits limits, const IRotat
                                                     kvector_t translation) const
 {
     auto effects = computeSlicingEffects(limits, translation, m_height);
-    double dbase_edge = 2*sqrt(3)*effects.dz_bottom*MathFunctions::cot(m_alpha);
+    double dbase_edge = 2 * sqrt(3) * effects.dz_bottom * MathFunctions::cot(m_alpha);
     FormFactorTetrahedron slicedff(m_base_edge - dbase_edge,
                                    m_height - effects.dz_bottom - effects.dz_top, m_alpha);
     return CreateTransformedFormFactor(slicedff, rot, effects.position);
@@ -63,10 +58,10 @@ IFormFactor* FormFactorTetrahedron::sliceFormFactor(ZLimits limits, const IRotat
 void FormFactorTetrahedron::onChange()
 {
     double cot_alpha = MathFunctions::cot(m_alpha);
-    if( !std::isfinite(cot_alpha) || cot_alpha<0 )
+    if (!std::isfinite(cot_alpha) || cot_alpha < 0)
         throw Exceptions::OutOfBoundsException("pyramid angle alpha out of bounds");
-    double r = cot_alpha * 2*std::sqrt(3.) * m_height / m_base_edge; // L(top)/L(base)
-    if ( r > 1 ) {
+    double r = cot_alpha * 2 * std::sqrt(3.) * m_height / m_base_edge; // L(top)/L(base)
+    if (r > 1) {
         std::ostringstream ostr;
         ostr << "Incompatible parameters in Tetrahedron: ";
         ostr << "(base_edge=" << m_base_edge;
@@ -77,23 +72,23 @@ void FormFactorTetrahedron::onChange()
     mP_shape.reset(new Pyramid3(m_base_edge, m_height, m_alpha));
 
     double a = m_base_edge;
-    double as = a/2;
-    double ac = a/sqrt(3)/2;
-    double ah = a/sqrt(3);
-    double b = a * (1-r);
-    double bs = b/2;
-    double bc = b/sqrt(3)/2;
-    double bh = b/sqrt(3);
+    double as = a / 2;
+    double ac = a / sqrt(3) / 2;
+    double ah = a / sqrt(3);
+    double b = a * (1 - r);
+    double bs = b / 2;
+    double bc = b / sqrt(3) / 2;
+    double bh = b / sqrt(3);
 
-    double zcom = m_height * ( .5 - 2*r/3 + r*r/4 ) / ( 1 - r + r*r/3 ); // center of mass
+    double zcom = m_height * (.5 - 2 * r / 3 + r * r / 4) / (1 - r + r * r / 3); // center of mass
 
-    setPolyhedron( topology, -zcom, {
-            // base:
-            { -ac,  as, -zcom },
-            { -ac, -as, -zcom },
-            {  ah,  0., -zcom },
-            // top:
-            { -bc,  bs, m_height-zcom },
-            { -bc, -bs, m_height-zcom },
-            {  bh,  0., m_height-zcom } } );
+    setPolyhedron(topology, -zcom,
+                  {// base:
+                   {-ac, as, -zcom},
+                   {-ac, -as, -zcom},
+                   {ah, 0., -zcom},
+                   // top:
+                   {-bc, bs, m_height - zcom},
+                   {-bc, -bs, m_height - zcom},
+                   {bh, 0., m_height - zcom}});
 }
diff --git a/Core/HardParticle/FormFactorTetrahedron.h b/Core/HardParticle/FormFactorTetrahedron.h
index 09259d48fa2..e08c4677bd3 100644
--- a/Core/HardParticle/FormFactorTetrahedron.h
+++ b/Core/HardParticle/FormFactorTetrahedron.h
@@ -25,9 +25,11 @@ class BA_CORE_API_ FormFactorTetrahedron : public FormFactorPolyhedron
 public:
     FormFactorTetrahedron(double base_edge, double height, double alpha);
 
-    FormFactorTetrahedron *clone() const override final {
-        return new FormFactorTetrahedron(m_base_edge, m_height, m_alpha); }
-    void accept(INodeVisitor *visitor) const override final { visitor->visit(this); }
+    FormFactorTetrahedron* clone() const override final
+    {
+        return new FormFactorTetrahedron(m_base_edge, m_height, m_alpha);
+    }
+    void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     double getBaseEdge() const { return m_base_edge; }
     double getHeight() const { return m_height; }
diff --git a/Core/HardParticle/FormFactorTriangle.cpp b/Core/HardParticle/FormFactorTriangle.cpp
index 85b65955c83..c646c527a18 100644
--- a/Core/HardParticle/FormFactorTriangle.cpp
+++ b/Core/HardParticle/FormFactorTriangle.cpp
@@ -18,12 +18,11 @@
 #include "RealParameter.h"
 #include "Triangle.h"
 
-
-FormFactorTriangle::FormFactorTriangle(const double base_edge)
-    : m_base_edge( base_edge )
+FormFactorTriangle::FormFactorTriangle(const double base_edge) : m_base_edge(base_edge)
 {
     setName("Triangle");
-    registerParameter(BornAgain::BaseEdge, &m_base_edge).setUnit(BornAgain::UnitsNm)
+    registerParameter(BornAgain::BaseEdge, &m_base_edge)
+        .setUnit(BornAgain::UnitsNm)
         .setNonnegative();
     onChange();
 }
@@ -32,12 +31,9 @@ void FormFactorTriangle::onChange()
 {
     mP_shape.reset(new Triangle(m_base_edge, 0.0));
     double a = m_base_edge;
-    double as = a/2;
-    double ac = a/sqrt(3)/2;
-    double ah = a/sqrt(3);
-    kvector_t V[3] = {
-        { -ac,  as, 0. },
-        { -ac, -as, 0. },
-        {  ah,  0., 0. } };
-    m_base = std::unique_ptr<PolyhedralFace>( new PolyhedralFace( { V[0], V[1], V[2] }, false ) );
+    double as = a / 2;
+    double ac = a / sqrt(3) / 2;
+    double ah = a / sqrt(3);
+    kvector_t V[3] = {{-ac, as, 0.}, {-ac, -as, 0.}, {ah, 0., 0.}};
+    m_base = std::unique_ptr<PolyhedralFace>(new PolyhedralFace({V[0], V[1], V[2]}, false));
 }
diff --git a/Core/HardParticle/FormFactorTruncatedCube.cpp b/Core/HardParticle/FormFactorTruncatedCube.cpp
index 0327479e171..f807914a261 100644
--- a/Core/HardParticle/FormFactorTruncatedCube.cpp
+++ b/Core/HardParticle/FormFactorTruncatedCube.cpp
@@ -19,42 +19,39 @@
 #include "TruncatedCube.h"
 
 const PolyhedralTopology FormFactorTruncatedCube::topology = {
-    {
-        { {  0, 1, 7, 6,  9,10, 4, 3 }, true },
-        { {  0, 2, 1 }, false },
-        { {  3, 4, 5 }, false },
-        { {  9,11,10 }, false },
-        { {  6, 7, 8 }, false },
-        { {  0, 3, 5,17, 15,12,14, 2 }, true },
-        { {  4,10,11,23, 22,16,17, 5 }, true },
-        { {  1, 2,14,13, 19,20, 8, 7 }, true },
-        { {  6, 8,20,18, 21,23,11, 9 }, true },
-        { { 15,17,16 }, false },
-        { { 12,13,14 }, false },
-        { { 18,20,19 }, false },
-        { { 21,22,23 }, false },
-        { { 12,15,16,22, 21,18,19,13 }, true }
-    }, true };
+    {{{0, 1, 7, 6, 9, 10, 4, 3}, true},
+     {{0, 2, 1}, false},
+     {{3, 4, 5}, false},
+     {{9, 11, 10}, false},
+     {{6, 7, 8}, false},
+     {{0, 3, 5, 17, 15, 12, 14, 2}, true},
+     {{4, 10, 11, 23, 22, 16, 17, 5}, true},
+     {{1, 2, 14, 13, 19, 20, 8, 7}, true},
+     {{6, 8, 20, 18, 21, 23, 11, 9}, true},
+     {{15, 17, 16}, false},
+     {{12, 13, 14}, false},
+     {{18, 20, 19}, false},
+     {{21, 22, 23}, false},
+     {{12, 15, 16, 22, 21, 18, 19, 13}, true}},
+    true};
 
 //! Constructor of a truncated cube.
 //! @param length: length of the full cube's edge in nanometers
 //! @param removed_length: removed length from each edge of the cube in nanometers
 FormFactorTruncatedCube::FormFactorTruncatedCube(double length, double removed_length)
-    : FormFactorPolyhedron()
-    , m_length(length)
-    , m_removed_length(removed_length)
+    : FormFactorPolyhedron(), m_length(length), m_removed_length(removed_length)
 {
     setName(BornAgain::FFTruncatedCubeType);
-    registerParameter(BornAgain::Length, &m_length).setUnit(BornAgain::UnitsNm)
-        .setNonnegative();
-    registerParameter(BornAgain::RemovedLength, &m_removed_length).setUnit(BornAgain::UnitsNm)
+    registerParameter(BornAgain::Length, &m_length).setUnit(BornAgain::UnitsNm).setNonnegative();
+    registerParameter(BornAgain::RemovedLength, &m_removed_length)
+        .setUnit(BornAgain::UnitsNm)
         .setNonnegative();
     onChange();
 }
 
 void FormFactorTruncatedCube::onChange()
 {
-    if(m_removed_length > 0.5*m_length) {
+    if (m_removed_length > 0.5 * m_length) {
         std::ostringstream ostr;
         ostr << "::FormFactorTruncatedCube() -> Error in class initialization ";
         ostr << "with parameters 'length':" << m_length;
@@ -64,32 +61,14 @@ void FormFactorTruncatedCube::onChange()
     }
     mP_shape.reset(new TruncatedCube(m_length, m_removed_length));
 
-    double a = m_length/2;
+    double a = m_length / 2;
     double b = m_removed_length;
 
-    setPolyhedron( topology, -a, {
-        { -a+b, -a  , -a   },
-        { -a  , -a+b, -a   },
-        { -a  , -a  , -a+b },
-        {  a-b, -a  , -a   },
-        {  a  , -a+b, -a   },
-        {  a  , -a  , -a+b },
-        { -a+b,  a  , -a   },
-        { -a  ,  a-b, -a   },
-        { -a  ,  a  , -a+b },
-        {  a-b,  a  , -a   },
-        {  a  ,  a-b, -a   },
-        {  a  ,  a  , -a+b },
-        { -a+b, -a  ,  a   },
-        { -a  , -a+b,  a   },
-        { -a  , -a  ,  a-b },
-        {  a-b, -a  ,  a   },
-        {  a  , -a+b,  a   },
-        {  a  , -a  ,  a-b },
-        { -a+b,  a  ,  a   },
-        { -a  ,  a-b,  a   },
-        { -a  ,  a  ,  a-b },
-        {  a-b,  a  ,  a   },
-        {  a  ,  a-b,  a   },
-        {  a  ,  a  ,  a-b } } );
+    setPolyhedron(topology, -a,
+                  {{-a + b, -a, -a}, {-a, -a + b, -a}, {-a, -a, -a + b}, {a - b, -a, -a},
+                   {a, -a + b, -a},  {a, -a, -a + b},  {-a + b, a, -a},  {-a, a - b, -a},
+                   {-a, a, -a + b},  {a - b, a, -a},   {a, a - b, -a},   {a, a, -a + b},
+                   {-a + b, -a, a},  {-a, -a + b, a},  {-a, -a, a - b},  {a - b, -a, a},
+                   {a, -a + b, a},   {a, -a, a - b},   {-a + b, a, a},   {-a, a - b, a},
+                   {-a, a, a - b},   {a - b, a, a},    {a, a - b, a},    {a, a, a - b}});
 }
diff --git a/Core/HardParticle/FormFactorTruncatedCube.h b/Core/HardParticle/FormFactorTruncatedCube.h
index 2b30ef9e6e6..8f449c46a36 100644
--- a/Core/HardParticle/FormFactorTruncatedCube.h
+++ b/Core/HardParticle/FormFactorTruncatedCube.h
@@ -25,9 +25,11 @@ class BA_CORE_API_ FormFactorTruncatedCube : public FormFactorPolyhedron
 public:
     FormFactorTruncatedCube(double length, double removed_length);
 
-    FormFactorTruncatedCube*clone() const override final {
-        return new FormFactorTruncatedCube(m_length, m_removed_length); }
-    void accept(INodeVisitor*visitor) const override final { visitor->visit(this); }
+    FormFactorTruncatedCube* clone() const override final
+    {
+        return new FormFactorTruncatedCube(m_length, m_removed_length);
+    }
+    void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     double getLength() const { return m_length; }
     double getRemovedLength() const { return m_removed_length; }
diff --git a/Core/HardParticle/FormFactorTruncatedSphere.cpp b/Core/HardParticle/FormFactorTruncatedSphere.cpp
index eb255d8c2f0..5feb6439120 100644
--- a/Core/HardParticle/FormFactorTruncatedSphere.cpp
+++ b/Core/HardParticle/FormFactorTruncatedSphere.cpp
@@ -15,9 +15,9 @@
 #include "FormFactorTruncatedSphere.h"
 #include "BornAgainNamespace.h"
 #include "Exceptions.h"
-#include "RealLimits.h"
-#include "MathFunctions.h"
 #include "MathConstants.h"
+#include "MathFunctions.h"
+#include "RealLimits.h"
 #include "RealParameter.h"
 #include "TruncatedEllipsoid.h"
 #include <limits>
@@ -27,9 +27,7 @@
 //! @param height: height of the truncated sphere in nanometers
 //! @param dh: length of cup truncated from the top
 FormFactorTruncatedSphere::FormFactorTruncatedSphere(double radius, double height, double dh)
-    : m_radius(radius)
-    , m_height(height)
-    , m_dh(dh)
+    : m_radius(radius), m_height(height), m_dh(dh)
 {
     setName(BornAgain::FFTruncatedSphereType);
     check_initialization();
@@ -43,7 +41,7 @@ FormFactorTruncatedSphere::FormFactorTruncatedSphere(double radius, double heigh
 bool FormFactorTruncatedSphere::check_initialization() const
 {
     bool result(true);
-    if(m_height > 2.*m_radius || m_dh > m_height) {
+    if (m_height > 2. * m_radius || m_dh > m_height) {
         std::ostringstream ostr;
         ostr << "::FormFactorTruncatedSphere() -> Error in class initialization ";
         ostr << "with parameters 'radius':" << m_radius << " 'height':" << m_height
@@ -57,24 +55,25 @@ bool FormFactorTruncatedSphere::check_initialization() const
 //! Integrand for complex formfactor.
 complex_t FormFactorTruncatedSphere::Integrand(double Z) const
 {
-    double Rz = std::sqrt(m_radius*m_radius-Z*Z );
+    double Rz = std::sqrt(m_radius * m_radius - Z * Z);
     complex_t qx = m_q.x();
     complex_t qy = m_q.y();
-    complex_t q_p = std::sqrt(qx*qx + qy*qy); // NOT the modulus!
-    return Rz*Rz*MathFunctions::Bessel_J1c(q_p*Rz) * exp_I(m_q.z()*Z);
+    complex_t q_p = std::sqrt(qx * qx + qy * qy); // NOT the modulus!
+    return Rz * Rz * MathFunctions::Bessel_J1c(q_p * Rz) * exp_I(m_q.z() * Z);
 }
 
 //! Complex formfactor.
 complex_t FormFactorTruncatedSphere::evaluate_for_q(cvector_t q) const
 {
     m_q = q;
-    if ( std::abs(q.mag()) < std::numeric_limits<double>::epsilon()) {
-        return M_PI/3.*(  m_height*m_height*(3.*m_radius - m_height)
-                        - m_dh*m_dh*(3.*m_radius - m_dh) );
+    if (std::abs(q.mag()) < std::numeric_limits<double>::epsilon()) {
+        return M_PI / 3.
+               * (m_height * m_height * (3. * m_radius - m_height)
+                  - m_dh * m_dh * (3. * m_radius - m_dh));
     }
     // else
-    complex_t integral = mP_integrator->integrate(m_radius-m_height, m_radius - m_dh);
-    return M_TWOPI * integral * exp_I(q.z()*(m_height-m_radius));
+    complex_t integral = mP_integrator->integrate(m_radius - m_height, m_radius - m_dh);
+    return M_TWOPI * integral * exp_I(q.z() * (m_height - m_radius));
 }
 
 IFormFactor* FormFactorTruncatedSphere::sliceFormFactor(ZLimits limits, const IRotation& rot,
diff --git a/Core/HardParticle/FormFactorTruncatedSphere.h b/Core/HardParticle/FormFactorTruncatedSphere.h
index d6d6dd88c24..80cc5891e33 100644
--- a/Core/HardParticle/FormFactorTruncatedSphere.h
+++ b/Core/HardParticle/FormFactorTruncatedSphere.h
@@ -24,11 +24,13 @@
 class BA_CORE_API_ FormFactorTruncatedSphere : public IFormFactorBorn
 {
 public:
-    FormFactorTruncatedSphere(double radius, double height, double dh=0.0);
+    FormFactorTruncatedSphere(double radius, double height, double dh = 0.0);
 
-    FormFactorTruncatedSphere *clone() const override final {
-        return new FormFactorTruncatedSphere(m_radius, m_height, m_dh); }
-    void accept(INodeVisitor *visitor) const override final { visitor->visit(this); }
+    FormFactorTruncatedSphere* clone() const override final
+    {
+        return new FormFactorTruncatedSphere(m_radius, m_height, m_dh);
+    }
+    void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     double getHeight() const { return m_height; }
     double getRadius() const { return m_radius; }
diff --git a/Core/HardParticle/FormFactorTruncatedSpheroid.cpp b/Core/HardParticle/FormFactorTruncatedSpheroid.cpp
index 536c763f2ef..0c5ee9f4e75 100644
--- a/Core/HardParticle/FormFactorTruncatedSpheroid.cpp
+++ b/Core/HardParticle/FormFactorTruncatedSpheroid.cpp
@@ -15,8 +15,8 @@
 #include "FormFactorTruncatedSpheroid.h"
 #include "BornAgainNamespace.h"
 #include "Exceptions.h"
-#include "MathFunctions.h"
 #include "MathConstants.h"
+#include "MathFunctions.h"
 #include "RealParameter.h"
 #include "TruncatedEllipsoid.h"
 #include <limits>
@@ -26,12 +26,9 @@
 //! @param height: height of the truncated spheroid in nanometers
 //! @param height_flattening: ratio of the height of the corresponding full spheroid to its diameter
 //! @param dh: length of cup truncated from the top
-FormFactorTruncatedSpheroid::FormFactorTruncatedSpheroid(
-    double radius, double height, double height_flattening, double dh)
-    : m_radius(radius)
-    , m_height(height)
-    , m_height_flattening(height_flattening)
-    , m_dh(dh)
+FormFactorTruncatedSpheroid::FormFactorTruncatedSpheroid(double radius, double height,
+                                                         double height_flattening, double dh)
+    : m_radius(radius), m_height(height), m_height_flattening(height_flattening), m_dh(dh)
 {
     setName(BornAgain::FFTruncatedSpheroidType);
     check_initialization();
@@ -46,8 +43,7 @@ FormFactorTruncatedSpheroid::FormFactorTruncatedSpheroid(
 bool FormFactorTruncatedSpheroid::check_initialization() const
 {
     bool result(true);
-    if(m_height > 2.*m_radius*m_height_flattening ||
-       m_dh > m_height) {
+    if (m_height > 2. * m_radius * m_height_flattening || m_dh > m_height) {
         std::ostringstream ostr;
         ostr << "::FormFactorTruncatedSpheroid() -> Error in class initialization with parameters ";
         ostr << " radius:" << m_radius;
@@ -65,11 +61,11 @@ complex_t FormFactorTruncatedSpheroid::Integrand(double Z) const
     double R = m_radius;
     double fp = m_height_flattening;
 
-    double Rz  = std::sqrt(R*R-Z*Z/(fp*fp));
-    complex_t qrRz = std::sqrt(m_q.x()*m_q.x()+m_q.y()*m_q.y())*Rz;
+    double Rz = std::sqrt(R * R - Z * Z / (fp * fp));
+    complex_t qrRz = std::sqrt(m_q.x() * m_q.x() + m_q.y() * m_q.y()) * Rz;
     complex_t J1_qrRz_div_qrRz = MathFunctions::Bessel_J1c(qrRz);
 
-    return Rz * Rz * J1_qrRz_div_qrRz * std::exp(complex_t(0.0,1.0)*m_q.z()*Z);
+    return Rz * Rz * J1_qrRz_div_qrRz * std::exp(complex_t(0.0, 1.0) * m_q.z() * Z);
 }
 
 complex_t FormFactorTruncatedSpheroid::evaluate_for_q(cvector_t q) const
@@ -80,9 +76,9 @@ complex_t FormFactorTruncatedSpheroid::evaluate_for_q(cvector_t q) const
     m_q = q;
 
     if (std::abs(m_q.mag()) <= std::numeric_limits<double>::epsilon())
-        return M_PI/3./fp*( H*H*(3.*R-H/fp) - m_dh*m_dh*(3.*R-m_dh/fp));
-    complex_t z_part    =  std::exp(complex_t(0.0, 1.0)*m_q.z()*(H-fp*R));
-    return M_TWOPI * z_part *mP_integrator->integrate(fp*R-H,fp*R-m_dh );
+        return M_PI / 3. / fp * (H * H * (3. * R - H / fp) - m_dh * m_dh * (3. * R - m_dh / fp));
+    complex_t z_part = std::exp(complex_t(0.0, 1.0) * m_q.z() * (H - fp * R));
+    return M_TWOPI * z_part * mP_integrator->integrate(fp * R - H, fp * R - m_dh);
 }
 
 IFormFactor* FormFactorTruncatedSpheroid::sliceFormFactor(ZLimits limits, const IRotation& rot,
@@ -90,13 +86,13 @@ IFormFactor* FormFactorTruncatedSpheroid::sliceFormFactor(ZLimits limits, const
 {
     double height = m_height - m_dh;
     auto effects = computeSlicingEffects(limits, translation, height);
-    FormFactorTruncatedSpheroid slicedff(m_radius, height - effects.dz_bottom,
-                                         m_height_flattening, effects.dz_top + m_dh);
+    FormFactorTruncatedSpheroid slicedff(m_radius, height - effects.dz_bottom, m_height_flattening,
+                                         effects.dz_top + m_dh);
     return CreateTransformedFormFactor(slicedff, rot, effects.position);
 }
 
 void FormFactorTruncatedSpheroid::onChange()
 {
-    mP_shape.reset(new TruncatedEllipsoid(m_radius, m_radius, m_height_flattening*m_radius,
-                                          m_height, m_dh));
+    mP_shape.reset(
+        new TruncatedEllipsoid(m_radius, m_radius, m_height_flattening * m_radius, m_height, m_dh));
 }
diff --git a/Core/HardParticle/FormFactorTruncatedSpheroid.h b/Core/HardParticle/FormFactorTruncatedSpheroid.h
index 6fc5a655708..c193133a5e4 100644
--- a/Core/HardParticle/FormFactorTruncatedSpheroid.h
+++ b/Core/HardParticle/FormFactorTruncatedSpheroid.h
@@ -26,10 +26,12 @@ class BA_CORE_API_ FormFactorTruncatedSpheroid : public IFormFactorBorn
 {
 public:
     FormFactorTruncatedSpheroid(double radius, double height, double height_flattening,
-                                double dh=0.0);
+                                double dh = 0.0);
 
-    FormFactorTruncatedSpheroid* clone() const override final {
-        return new FormFactorTruncatedSpheroid(m_radius, m_height, m_height_flattening, m_dh); }
+    FormFactorTruncatedSpheroid* clone() const override final
+    {
+        return new FormFactorTruncatedSpheroid(m_radius, m_height, m_height_flattening, m_dh);
+    }
     void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     double getRadius() const { return m_radius; }
diff --git a/Core/InputOutput/DataFormatUtils.cpp b/Core/InputOutput/DataFormatUtils.cpp
index 0e481257bc8..3282588879a 100644
--- a/Core/InputOutput/DataFormatUtils.cpp
+++ b/Core/InputOutput/DataFormatUtils.cpp
@@ -16,17 +16,17 @@
 #include "ConstKBinAxis.h"
 #include "CustomBinAxis.h"
 #include "FileSystemUtils.h"
-#include "PointwiseAxis.h"
 #include "OutputData.h"
+#include "PointwiseAxis.h"
 #include "StringUtils.h"
-#include <iterator>
 #include <iostream>
+#include <iterator>
 
-namespace {
+namespace
+{
 std::istringstream getAxisStringRepresentation(std::istream& input_stream);
 
-template<class Axis>
-std::unique_ptr<IAxis> createFixedBinLikeAxis(std::istringstream iss);
+template <class Axis> std::unique_ptr<IAxis> createFixedBinLikeAxis(std::istringstream iss);
 std::unique_ptr<IAxis> createVariableBinAxis(std::istringstream iss);
 std::unique_ptr<IAxis> createPointwiseAxis(std::istringstream iss);
 
@@ -43,7 +43,7 @@ const std::string BzipExtension = ".bz2";
 const std::string IntExtension = ".int";
 const std::string TiffExtension = ".tif";
 const std::string TiffExtension2 = ".tiff";
-}
+} // namespace
 
 bool DataFormatUtils::isCompressed(const std::string& name)
 {
@@ -62,16 +62,15 @@ bool DataFormatUtils::isBZipped(const std::string& name)
     return FileSystemUtils::extension(name) == BzipExtension;
 }
 
-
 //! Returns file main extension (without .gz).
 
 std::string DataFormatUtils::GetFileMainExtension(const std::string& name)
 {
     std::string stripped_name(name);
-    if(isGZipped(name)) {
-        stripped_name = name.substr(0, name.size()-GzipExtension.size());
-    } else if(isBZipped(name)) {
-        stripped_name = name.substr(0, name.size()-BzipExtension.size());
+    if (isGZipped(name)) {
+        stripped_name = name.substr(0, name.size() - GzipExtension.size());
+    } else if (isBZipped(name)) {
+        stripped_name = name.substr(0, name.size() - BzipExtension.size());
     }
     return FileSystemUtils::extension(stripped_name);
 }
@@ -83,8 +82,8 @@ bool DataFormatUtils::isIntFile(const std::string& file_name)
 
 bool DataFormatUtils::isTiffFile(const std::string& file_name)
 {
-    return (GetFileMainExtension(file_name) == TiffExtension ||
-            GetFileMainExtension(file_name) == TiffExtension2 );
+    return (GetFileMainExtension(file_name) == TiffExtension
+            || GetFileMainExtension(file_name) == TiffExtension2);
 }
 
 //! Creates axis of certain type from input stream
@@ -110,8 +109,9 @@ void DataFormatUtils::fillOutputData(OutputData<double>* data, std::istream& inp
     std::string line;
     data->setAllTo(0.0);
     OutputData<double>::iterator it = data->begin();
-    while( std::getline(input_stream, line) ) {
-        if(line.empty() || line[0] == '#') break;
+    while (std::getline(input_stream, line)) {
+        if (line.empty() || line[0] == '#')
+            break;
 
         std::istringstream iss(line);
         std::vector<double> buffer;
@@ -121,7 +121,7 @@ void DataFormatUtils::fillOutputData(OutputData<double>* data, std::istream& inp
             ++it;
         }
     }
-    if(it!= data->end())
+    if (it != data->end())
         throw Exceptions::FormatErrorException(
             "DataFormatUtils::fillOutputData() -> Error while parsing data.");
 }
@@ -133,14 +133,15 @@ std::vector<double> DataFormatUtils::parse_doubles(const std::string& str)
     std::vector<double> result;
     std::istringstream iss(str);
     DataFormatUtils::readLineOfDoubles(result, iss);
-    if( result.empty() ) {
+    if (result.empty()) {
         std::string out = str;
         const size_t max_string_length(10);
-        if(out.size() > max_string_length)
+        if (out.size() > max_string_length)
             out.resize(max_string_length, ' ');
         out += " ...";
         throw std::runtime_error("DataFormatUtils::parse_doubles -> Error! Can't parse double "
-                                 "values from a string '"+out+"'");
+                                 "values from a string '"
+                                 + out + "'");
     }
     return result;
 }
@@ -148,11 +149,12 @@ std::vector<double> DataFormatUtils::parse_doubles(const std::string& str)
 void DataFormatUtils::readLineOfDoubles(std::vector<double>& buffer, std::istringstream& iss)
 {
     iss.imbue(std::locale::classic());
-    std::copy(std::istream_iterator<double>(iss),
-              std::istream_iterator<double>(), back_inserter(buffer));
+    std::copy(std::istream_iterator<double>(iss), std::istream_iterator<double>(),
+              back_inserter(buffer));
 }
 
-namespace {
+namespace
+{
 std::istringstream getAxisStringRepresentation(std::istream& input_stream)
 {
     std::string line;
@@ -166,18 +168,17 @@ std::istringstream getAxisStringRepresentation(std::istream& input_stream)
 //! FixedBinAxis("axis0", 10, -1, 1)
 //! ConstKBinAxis("axis0", 10, -1, 1)
 //! CustomBinAxis("axis0", 10, -1, 1)
-template<class Axis>
-std::unique_ptr<IAxis> createFixedBinLikeAxis(std::istringstream iss)
+template <class Axis> std::unique_ptr<IAxis> createFixedBinLikeAxis(std::istringstream iss)
 {
     std::string name;
     size_t nbins(0);
-    if( !(iss >> name >> nbins) )
+    if (!(iss >> name >> nbins))
         throw Exceptions::FormatErrorException(
             "createFixedBinLikeAxis() -> Error. Can't parse the string.");
 
     std::vector<double> boundaries;
     DataFormatUtils::readLineOfDoubles(boundaries, iss);
-    if(boundaries.size() != 2)
+    if (boundaries.size() != 2)
         throw Exceptions::FormatErrorException(
             "Error in createFixedBinLikeAxis: Can't parse the string while "
             "reading boundaries.");
@@ -185,20 +186,19 @@ std::unique_ptr<IAxis> createFixedBinLikeAxis(std::istringstream iss)
     return std::make_unique<Axis>(name, nbins, boundaries[0], boundaries[1]);
 }
 
-
 //! Create VariableBinAxis from string representation
 //! VariableBinAxis("axis0", 4, [-1, -0.5, 0.5, 1, 2])
 std::unique_ptr<IAxis> createVariableBinAxis(std::istringstream iss)
 {
     std::string name;
     size_t nbins(0);
-    if( !(iss >> name >> nbins) )
+    if (!(iss >> name >> nbins))
         throw Exceptions::FormatErrorException(
             "Error in createVariableBinAxis: Can't parse the string.");
 
     std::vector<double> boundaries;
     DataFormatUtils::readLineOfDoubles(boundaries, iss);
-    if(boundaries.size() != nbins+1)
+    if (boundaries.size() != nbins + 1)
         throw Exceptions::FormatErrorException(
             "Error in createVariableBinAxis: wrong number of boundaries read.");
 
@@ -219,4 +219,4 @@ std::unique_ptr<IAxis> createPointwiseAxis(std::istringstream iss)
 
     return std::make_unique<PointwiseAxis>(name, coordinates);
 }
-}
+} // namespace
diff --git a/Core/InputOutput/DataFormatUtils.h b/Core/InputOutput/DataFormatUtils.h
index 4c51c3fefd8..fbdd6e9803e 100644
--- a/Core/InputOutput/DataFormatUtils.h
+++ b/Core/InputOutput/DataFormatUtils.h
@@ -25,7 +25,8 @@ template <class T> class OutputData;
 
 //! Utility functions for data input and output.
 
-namespace DataFormatUtils {
+namespace DataFormatUtils
+{
 //! Returns true if name contains *.gz extension
 BA_CORE_API_ bool isCompressed(const std::string& name);
 
@@ -51,6 +52,6 @@ BA_CORE_API_ void fillOutputData(OutputData<double>* data, std::istream& input_s
 BA_CORE_API_ std::vector<double> parse_doubles(const std::string& str);
 
 void readLineOfDoubles(std::vector<double>& buffer, std::istringstream& iss);
-}
+} // namespace DataFormatUtils
 
 #endif // DATAFORMATUTILS_H
diff --git a/Core/InputOutput/IntensityDataIOFactory.cpp b/Core/InputOutput/IntensityDataIOFactory.cpp
index 44e55927c2d..839ff43538b 100644
--- a/Core/InputOutput/IntensityDataIOFactory.cpp
+++ b/Core/InputOutput/IntensityDataIOFactory.cpp
@@ -13,11 +13,11 @@
 // ************************************************************************** //
 
 #include "IntensityDataIOFactory.h"
+#include "FileSystemUtils.h"
 #include "IHistogram.h"
 #include "OutputDataReadFactory.h"
 #include "OutputDataWriteFactory.h"
 #include "SimulationResult.h"
-#include "FileSystemUtils.h"
 #include <fstream>
 #include <memory>
 
@@ -35,7 +35,8 @@ OutputData<double>* IntensityDataIOFactory::readReflectometryData(const std::str
 {
     if (!FileSystemUtils::IsFileExists(file_name))
         return nullptr;
-    std::unique_ptr<OutputDataReader> P_reader(OutputDataReadFactory::getReflectometryReader(file_name));
+    std::unique_ptr<OutputDataReader> P_reader(
+        OutputDataReadFactory::getReflectometryReader(file_name));
     if (P_reader)
         return P_reader->getOutputData();
     return nullptr;
@@ -50,7 +51,7 @@ IHistogram* IntensityDataIOFactory::readIntensityData(const std::string& file_na
 void IntensityDataIOFactory::writeOutputData(const OutputData<double>& data,
                                              const std::string& file_name)
 {
-    auto *writer = OutputDataWriteFactory::getWriter(file_name);
+    auto* writer = OutputDataWriteFactory::getWriter(file_name);
     writer->writeOutputData(data);
     delete writer;
 }
diff --git a/Core/InputOutput/IntensityDataIOFactory.h b/Core/InputOutput/IntensityDataIOFactory.h
index cb5a9b0273a..a14b29c84cf 100644
--- a/Core/InputOutput/IntensityDataIOFactory.h
+++ b/Core/InputOutput/IntensityDataIOFactory.h
@@ -49,7 +49,7 @@ class BA_CORE_API_ IntensityDataIOFactory
 public:
     //! Reads file and returns newly created OutputData object
     static OutputData<double>* readOutputData(const std::string& file_name);
-    static OutputData<double> *readReflectometryData(const std::string &file_name);
+    static OutputData<double>* readReflectometryData(const std::string& file_name);
 
     //! Reads file and returns newly created Histogram object
     static IHistogram* readIntensityData(const std::string& file_name);
@@ -58,7 +58,7 @@ public:
     static void writeOutputData(const OutputData<double>& data, const std::string& file_name);
 
     //! Writes histogram in file
-    static void writeIntensityData(const IHistogram &histogram, const std::string& file_name);
+    static void writeIntensityData(const IHistogram& histogram, const std::string& file_name);
 
     //! Writes OutputData contained in the given SimulationResult object
     static void writeSimulationResult(const SimulationResult& result, const std::string& file_name);
diff --git a/Core/InputOutput/OutputDataReadFactory.cpp b/Core/InputOutput/OutputDataReadFactory.cpp
index 79c0ec6993e..0dce7d067ac 100644
--- a/Core/InputOutput/OutputDataReadFactory.cpp
+++ b/Core/InputOutput/OutputDataReadFactory.cpp
@@ -13,8 +13,8 @@
 // ************************************************************************** //
 
 #include "OutputDataReadFactory.h"
-#include "Exceptions.h"
 #include "DataFormatUtils.h"
+#include "Exceptions.h"
 
 OutputDataReader* OutputDataReadFactory::getReader(const std::string& file_name)
 {
@@ -33,16 +33,16 @@ OutputDataReader* OutputDataReadFactory::getReflectometryReader(const std::strin
 IOutputDataReadStrategy* OutputDataReadFactory::getReadStrategy(const std::string& file_name)
 {
     IOutputDataReadStrategy* result(nullptr);
-    if(DataFormatUtils::isIntFile(file_name))
+    if (DataFormatUtils::isIntFile(file_name))
         result = new OutputDataReadINTStrategy();
 #ifdef BORNAGAIN_TIFF_SUPPORT
-    else if(DataFormatUtils::isTiffFile(file_name))
-       result = new OutputDataReadTiffStrategy();
+    else if (DataFormatUtils::isTiffFile(file_name))
+        result = new OutputDataReadTiffStrategy();
 #endif // BORNAGAIN_TIFF_SUPPORT
     else
-        //Try to read ASCII by default. Binary maps to ASCII.
-        //If the file is not actually a matrix of numbers,
-        //the error will be thrown during the reading.
+        // Try to read ASCII by default. Binary maps to ASCII.
+        // If the file is not actually a matrix of numbers,
+        // the error will be thrown during the reading.
         result = new OutputDataReadNumpyTXTStrategy();
     return result;
 }
diff --git a/Core/InputOutput/OutputDataReadFactory.h b/Core/InputOutput/OutputDataReadFactory.h
index f38b76e60a5..5802d64dc01 100644
--- a/Core/InputOutput/OutputDataReadFactory.h
+++ b/Core/InputOutput/OutputDataReadFactory.h
@@ -24,7 +24,8 @@ class BA_CORE_API_ OutputDataReadFactory
 {
 public:
     static OutputDataReader* getReader(const std::string& file_name);
-    static OutputDataReader *getReflectometryReader(const std::string &file_name);
+    static OutputDataReader* getReflectometryReader(const std::string& file_name);
+
 private:
     static IOutputDataReadStrategy* getReadStrategy(const std::string& file_name);
 };
diff --git a/Core/InputOutput/OutputDataReadStrategy.cpp b/Core/InputOutput/OutputDataReadStrategy.cpp
index 1502eff5860..9d814b336d1 100644
--- a/Core/InputOutput/OutputDataReadStrategy.cpp
+++ b/Core/InputOutput/OutputDataReadStrategy.cpp
@@ -13,17 +13,17 @@
 // ************************************************************************** //
 
 #include "OutputDataReadStrategy.h"
-#include "OutputData.h"
+#include "ArrayUtils.h"
 #include "DataFormatUtils.h"
+#include "OutputData.h"
 #include "PointwiseAxis.h"
-#include "ArrayUtils.h"
 #include "TiffHandler.h"
-#include <stdexcept> // need overlooked by g++ 5.4
 #include <map>
+#include <stdexcept> // need overlooked by g++ 5.4
 
-namespace{
-inline std::string trim(const std::string& str,
-                        const std::string& whitespace = " \t")
+namespace
+{
+inline std::string trim(const std::string& str, const std::string& whitespace = " \t")
 {
     const auto strBegin = str.find_first_not_of(whitespace);
 
@@ -39,16 +39,14 @@ inline bool isDoubleStartChar(char c)
 {
     return isdigit(c) || c == '-' || c == '+';
 }
-}
-
-
+} // namespace
 
 OutputData<double>* OutputDataReadINTStrategy::readOutputData(std::istream& input_stream)
 {
     OutputData<double>* result = new OutputData<double>;
     std::string line;
 
-    while( std::getline(input_stream, line) ) {
+    while (std::getline(input_stream, line)) {
         line = trim(line);
         if (line.find("axis") != std::string::npos) {
             std::unique_ptr<IAxis> axis = DataFormatUtils::createAxis(input_stream);
@@ -64,15 +62,15 @@ OutputData<double>* OutputDataReadINTStrategy::readOutputData(std::istream& inpu
 
 OutputData<double>* OutputDataReadReflectometryStrategy::readOutputData(std::istream& fin)
 {
-    OutputData<double> *oData = new OutputData<double>();
+    OutputData<double>* oData = new OutputData<double>();
     std::string line;
     std::vector<std::vector<double>> vecVec;
-    std::map<double,double> QvsR;
-    std::map<double,double> QvsDR;
-    std::map<double,double> QvsDQ;
+    std::map<double, double> QvsR;
+    std::map<double, double> QvsDR;
+    std::map<double, double> QvsDQ;
 
-    //Read numbers from file:
-    while( std::getline(fin, line) ) {
+    // Read numbers from file:
+    while (std::getline(fin, line)) {
         line = trim(line);
         try {
             std::vector<double> rowVec = DataFormatUtils::parse_doubles(line);
@@ -91,43 +89,41 @@ OutputData<double>* OutputDataReadReflectometryStrategy::readOutputData(std::ist
         throw std::runtime_error("Import1dTextData: Minimum 2 columns required");
 
     // Assign Q vs R, dR, dQ:
-    for(size_t row=0; row<nrows; row++) {
-        if(vecVec[row].size() != ncols)
+    for (size_t row = 0; row < nrows; row++) {
+        if (vecVec[row].size() != ncols)
             throw std::runtime_error("The number of columns varies among the rows");
         double Q = vecVec[row][0];
-        switch(ncols){
+        switch (ncols) {
         case 1:
             break;
         case 2:
-            QvsR[Q]  = vecVec[row][1];
+            QvsR[Q] = vecVec[row][1];
             QvsDR[Q] = 0;
             QvsDQ[Q] = 0;
             break;
         case 3:
-            QvsR[Q]  = vecVec[row][1];
+            QvsR[Q] = vecVec[row][1];
             QvsDR[Q] = vecVec[row][2];
             QvsDQ[Q] = 0;
             break;
         default:
-            QvsR[Q]  = vecVec[row][1];
+            QvsR[Q] = vecVec[row][1];
             QvsDR[Q] = vecVec[row][2];
             QvsDQ[Q] = vecVec[row][3];
             break;
         }
     }
 
-
     std::vector<double> qVec;
     std::vector<double> rVec;
-    for(auto it = QvsR.begin(); it != QvsR.end(); ++it) {
-        if(it->second <= 0)
+    for (auto it = QvsR.begin(); it != QvsR.end(); ++it) {
+        if (it->second <= 0)
             continue;
         qVec.push_back(it->first);
         rVec.push_back(it->second);
     }
 
-
-    oData->addAxis(PointwiseAxis("qVector",qVec));
+    oData->addAxis(PointwiseAxis("qVector", qVec));
     oData->setRawDataVector(rVec);
     return oData;
 }
@@ -137,10 +133,10 @@ OutputData<double>* OutputDataReadNumpyTXTStrategy::readOutputData(std::istream&
     std::string line;
     std::vector<std::vector<double>> data;
 
-    //Read numbers from input stream:
-    while( std::getline(input_stream, line) ) {
+    // Read numbers from input stream:
+    while (std::getline(input_stream, line)) {
         line = trim(line);
-        if(line.empty() || !isDoubleStartChar(line[0]))
+        if (line.empty() || !isDoubleStartChar(line[0]))
             continue;
 
         try {
@@ -151,43 +147,39 @@ OutputData<double>* OutputDataReadNumpyTXTStrategy::readOutputData(std::istream&
         }
     }
 
-   // validating
+    // validating
     size_t nrows = data.size();
     size_t ncols(0);
-    if(nrows) ncols = data[0].size();
+    if (nrows)
+        ncols = data[0].size();
 
     if (ncols == 0)
         throw std::runtime_error("OutputDataReadNumpyTXTStrategy::readOutputData() -> Error. "
-                                     "Can't parse file");
+                                 "Can't parse file");
 
-    for(size_t row=0; row<nrows; row++) {
-        if(data[row].size() != ncols)
+    for (size_t row = 0; row < nrows; row++) {
+        if (data[row].size() != ncols)
             throw std::runtime_error("OutputDataReadNumpyTXTStrategy::readOutputData() -> Error. "
-                                         "Number of elements is different from row to row.");
+                                     "Number of elements is different from row to row.");
     }
 
-    if(nrows < 2){
+    if (nrows < 2) {
         return ArrayUtils::createData(std::move(data[0])).release();
-    }
-    else if(ncols < 2){
+    } else if (ncols < 2) {
         const size_t size = data.size();
         std::vector<double> vector1d(size);
-        for(size_t i = 0; i < size; ++i){
+        for (size_t i = 0; i < size; ++i) {
             vector1d[i] = data[i][0];
         }
         return ArrayUtils::createData(std::move(vector1d)).release();
-    }
-    else{
+    } else {
         return ArrayUtils::createData(data).release();
     }
 }
 
-
 #ifdef BORNAGAIN_TIFF_SUPPORT
 
-OutputDataReadTiffStrategy::OutputDataReadTiffStrategy()
-        : m_d(new TiffHandler)
-{}
+OutputDataReadTiffStrategy::OutputDataReadTiffStrategy() : m_d(new TiffHandler) {}
 
 OutputDataReadTiffStrategy::~OutputDataReadTiffStrategy()
 {
diff --git a/Core/InputOutput/OutputDataReadStrategy.h b/Core/InputOutput/OutputDataReadStrategy.h
index 6b9e6d2857b..817a7b97b01 100644
--- a/Core/InputOutput/OutputDataReadStrategy.h
+++ b/Core/InputOutput/OutputDataReadStrategy.h
@@ -26,7 +26,7 @@ template <class T> class OutputData;
 class BA_CORE_API_ IOutputDataReadStrategy
 {
 public:
-    virtual ~IOutputDataReadStrategy(){}
+    virtual ~IOutputDataReadStrategy() {}
     virtual OutputData<double>* readOutputData(std::istream& input_stream) = 0;
 };
 
@@ -48,7 +48,6 @@ public:
     OutputData<double>* readOutputData(std::istream& input_stream);
 };
 
-
 //! Strategy to read OutputData from simple ASCII file with the layout as in numpy.savetxt.
 //! @ingroup input_output_internal
 
@@ -58,7 +57,6 @@ public:
     OutputData<double>* readOutputData(std::istream& input_stream);
 };
 
-
 #ifdef BORNAGAIN_TIFF_SUPPORT
 
 class TiffHandler;
@@ -72,8 +70,9 @@ public:
     OutputDataReadTiffStrategy();
     virtual ~OutputDataReadTiffStrategy();
     virtual OutputData<double>* readOutputData(std::istream& input_stream);
+
 private:
-    TiffHandler *m_d;
+    TiffHandler* m_d;
 };
 #endif // BORNAGAIN_TIFF_SUPPORT
 
diff --git a/Core/InputOutput/OutputDataReader.cpp b/Core/InputOutput/OutputDataReader.cpp
index f1426c81a23..ce91b91cdc6 100644
--- a/Core/InputOutput/OutputDataReader.cpp
+++ b/Core/InputOutput/OutputDataReader.cpp
@@ -13,33 +13,31 @@
 // ************************************************************************** //
 
 #include "OutputDataReader.h"
-#include "OutputData.h"
 #include "DataFormatUtils.h"
+#include "OutputData.h"
 #ifdef _WIN32
-#pragma warning ( push )
-#pragma warning ( disable: 4244 4275 )
+#pragma warning(push)
+#pragma warning(disable : 4244 4275)
 #include "boost_streams.h"
-#pragma warning ( pop )
+#pragma warning(pop)
 #else
 #include "boost_streams.h"
 #endif
-#include <fstream>
 #include "FileSystemUtils.h"
+#include <fstream>
 
-OutputDataReader::OutputDataReader(const std::string& file_name)
-    : m_file_name(file_name)
-{}
+OutputDataReader::OutputDataReader(const std::string& file_name) : m_file_name(file_name) {}
 
 OutputData<double>* OutputDataReader::getOutputData()
 {
     using namespace DataFormatUtils;
-    if(!m_read_strategy)
+    if (!m_read_strategy)
         throw Exceptions::NullPointerException(
             "OutputDataReader::getOutputData() -> Error! No read strategy defined");
 
     std::ifstream fin;
     std::ios_base::openmode openmode = std::ios::in;
-    if(isTiffFile(m_file_name) || isCompressed(m_file_name))
+    if (isTiffFile(m_file_name) || isCompressed(m_file_name))
         openmode = std::ios::in | std::ios_base::binary;
 
 #ifdef _WIN32
@@ -48,14 +46,13 @@ OutputData<double>* OutputDataReader::getOutputData()
     fin.open(m_file_name, openmode);
 #endif
 
-    if(!fin.is_open())
+    if (!fin.is_open())
         throw Exceptions::FileNotIsOpenException(
-            "OutputDataReader::getOutputData() -> Error. Can't open file '"
-            + m_file_name + "' for reading.");
+            "OutputDataReader::getOutputData() -> Error. Can't open file '" + m_file_name
+            + "' for reading.");
     if (!fin.good())
-        throw Exceptions::FileIsBadException(
-            "OutputDataReader::getOutputData() -> Error! "
-            "File is not good, probably it is a directory.");
+        throw Exceptions::FileIsBadException("OutputDataReader::getOutputData() -> Error! "
+                                             "File is not good, probably it is a directory.");
     OutputData<double>* result = getFromFilteredStream(fin);
     fin.close();
     return result;
diff --git a/Core/InputOutput/OutputDataWriteFactory.cpp b/Core/InputOutput/OutputDataWriteFactory.cpp
index b6b24416f87..f5524652035 100644
--- a/Core/InputOutput/OutputDataWriteFactory.cpp
+++ b/Core/InputOutput/OutputDataWriteFactory.cpp
@@ -12,35 +12,32 @@
 //
 // ************************************************************************** //
 #include "OutputDataWriteFactory.h"
-#include "Exceptions.h"
 #include "DataFormatUtils.h"
+#include "Exceptions.h"
 
-OutputDataWriter *OutputDataWriteFactory::getWriter(const std::string &file_name)
+OutputDataWriter* OutputDataWriteFactory::getWriter(const std::string& file_name)
 {
-    OutputDataWriter *result = new OutputDataWriter(file_name);
+    OutputDataWriter* result = new OutputDataWriter(file_name);
     result->setStrategy(getWriteStrategy(file_name));
     return result;
 }
 
-
-IOutputDataWriteStrategy *OutputDataWriteFactory::getWriteStrategy(const std::string &file_name)
+IOutputDataWriteStrategy* OutputDataWriteFactory::getWriteStrategy(const std::string& file_name)
 {
-    IOutputDataWriteStrategy *result(nullptr);
-    if(DataFormatUtils::isIntFile(file_name)) {
+    IOutputDataWriteStrategy* result(nullptr);
+    if (DataFormatUtils::isIntFile(file_name)) {
         result = new OutputDataWriteINTStrategy();
     }
 
-
 #ifdef BORNAGAIN_TIFF_SUPPORT
-    else if(DataFormatUtils::isTiffFile(file_name)) {
+    else if (DataFormatUtils::isTiffFile(file_name)) {
         result = new OutputDataWriteTiffStrategy();
     }
 #endif // BORNAGAIN_TIFF_SUPPORT
 
-    else{
+    else {
         result = new OutputDataWriteNumpyTXTStrategy();
     }
 
-
     return result;
 }
diff --git a/Core/InputOutput/OutputDataWriteFactory.h b/Core/InputOutput/OutputDataWriteFactory.h
index 0ae5038c216..5822d24b5da 100644
--- a/Core/InputOutput/OutputDataWriteFactory.h
+++ b/Core/InputOutput/OutputDataWriteFactory.h
@@ -26,7 +26,7 @@ public:
     static OutputDataWriter* getWriter(const std::string& file_name);
 
 private:
-    static IOutputDataWriteStrategy *getWriteStrategy(const std::string& file_name);
+    static IOutputDataWriteStrategy* getWriteStrategy(const std::string& file_name);
 };
 
 #endif // OUTPUTDATAWRITEFACTORY_H
diff --git a/Core/InputOutput/OutputDataWriteStrategy.h b/Core/InputOutput/OutputDataWriteStrategy.h
index 2061d6193f5..968f0055d2f 100644
--- a/Core/InputOutput/OutputDataWriteStrategy.h
+++ b/Core/InputOutput/OutputDataWriteStrategy.h
@@ -27,7 +27,7 @@ class BA_CORE_API_ IOutputDataWriteStrategy
 {
 public:
     IOutputDataWriteStrategy() {}
-    virtual ~IOutputDataWriteStrategy(){}
+    virtual ~IOutputDataWriteStrategy() {}
 
     virtual void writeOutputData(const OutputData<double>& data, std::ostream& output_stream) = 0;
 };
@@ -63,6 +63,7 @@ public:
     OutputDataWriteTiffStrategy();
     virtual ~OutputDataWriteTiffStrategy();
     virtual void writeOutputData(const OutputData<double>& data, std::ostream& output_stream);
+
 private:
     TiffHandler* m_d;
 };
diff --git a/Core/InputOutput/OutputDataWriter.cpp b/Core/InputOutput/OutputDataWriter.cpp
index 86ca6981a6f..c876fcbbbf9 100644
--- a/Core/InputOutput/OutputDataWriter.cpp
+++ b/Core/InputOutput/OutputDataWriter.cpp
@@ -13,34 +13,31 @@
 // ************************************************************************** //
 
 #include "OutputDataWriter.h"
-#include "OutputData.h"
 #include "DataFormatUtils.h"
+#include "OutputData.h"
 #ifdef _WIN32
-#pragma warning ( push )
-#pragma warning ( disable: 4244 4275 )
+#pragma warning(push)
+#pragma warning(disable : 4244 4275)
 #include "boost_streams.h"
-#pragma warning ( pop )
+#pragma warning(pop)
 #else
 #include "boost_streams.h"
 #endif
-#include <fstream>
 #include "FileSystemUtils.h"
+#include <fstream>
 
-OutputDataWriter::OutputDataWriter(const std::string& file_name)
-    : m_file_name(file_name)
-{
-}
+OutputDataWriter::OutputDataWriter(const std::string& file_name) : m_file_name(file_name) {}
 
 void OutputDataWriter::writeOutputData(const OutputData<double>& data)
 {
     using namespace DataFormatUtils;
-    if(!m_write_strategy)
+    if (!m_write_strategy)
         throw Exceptions::NullPointerException("OutputDataWriter::getOutputData() ->"
                                                " Error! No read strategy defined");
 
     std::ofstream fout;
     std::ios_base::openmode openmode = std::ios::out;
-    if(isTiffFile(m_file_name) || isCompressed(m_file_name))
+    if (isTiffFile(m_file_name) || isCompressed(m_file_name))
         openmode = std::ios::out | std::ios_base::binary;
 
 #ifdef _WIN32
@@ -49,9 +46,10 @@ void OutputDataWriter::writeOutputData(const OutputData<double>& data)
     fout.open(m_file_name, openmode);
 #endif
 
-    if(!fout.is_open())
+    if (!fout.is_open())
         throw Exceptions::FileNotIsOpenException("OutputDataWriter::writeOutputData() -> Error. "
-                                                 "Can't open file '"+m_file_name+"' for writing.");
+                                                 "Can't open file '"
+                                                 + m_file_name + "' for writing.");
     if (!fout.good())
         throw Exceptions::FileIsBadException("OutputDataReader::writeOutputData() -> Error! "
                                              "File is not good, probably it is a directory.");
@@ -59,9 +57,9 @@ void OutputDataWriter::writeOutputData(const OutputData<double>& data)
     m_write_strategy->writeOutputData(data, ss);
 
     boost::iostreams::filtering_streambuf<boost::iostreams::input> input_filtered;
-    if(DataFormatUtils::isGZipped(m_file_name))
+    if (DataFormatUtils::isGZipped(m_file_name))
         input_filtered.push(boost::iostreams::gzip_compressor());
-    else if(DataFormatUtils::isBZipped(m_file_name))
+    else if (DataFormatUtils::isBZipped(m_file_name))
         input_filtered.push(boost::iostreams::bzip2_compressor());
     input_filtered.push(ss);
 
@@ -70,7 +68,6 @@ void OutputDataWriter::writeOutputData(const OutputData<double>& data)
     fout.close();
 }
 
-
 void OutputDataWriter::setStrategy(IOutputDataWriteStrategy* write_strategy)
 {
     m_write_strategy.reset(write_strategy);
diff --git a/Core/InputOutput/TiffHandler.cpp b/Core/InputOutput/TiffHandler.cpp
index dfe4fe95ee3..53eb08c9ecb 100644
--- a/Core/InputOutput/TiffHandler.cpp
+++ b/Core/InputOutput/TiffHandler.cpp
@@ -19,20 +19,20 @@
 #include "SysUtils.h"
 
 TiffHandler::TiffHandler()
-    : m_tiff(0)
-    , m_width(0), m_height(0)
-    , m_bitsPerSample(0), m_samplesPerPixel(0), m_sampleFormat(0)
-{}
+    : m_tiff(0), m_width(0), m_height(0), m_bitsPerSample(0), m_samplesPerPixel(0),
+      m_sampleFormat(0)
+{
+}
 
 TiffHandler::~TiffHandler()
 {
     close();
 }
 
-void TiffHandler::read(std::istream &input_stream)
+void TiffHandler::read(std::istream& input_stream)
 {
     m_tiff = TIFFStreamOpen("MemTIFF", &input_stream);
-    if(!m_tiff) {
+    if (!m_tiff) {
         throw Exceptions::FormatErrorException("TiffHandler::read() -> Can't open the file.");
     }
     read_header();
@@ -40,21 +40,20 @@ void TiffHandler::read(std::istream &input_stream)
     close();
 }
 
-const OutputData<double> *TiffHandler::getOutputData() const
+const OutputData<double>* TiffHandler::getOutputData() const
 {
     return m_data.get();
 }
 
-void TiffHandler::write(const OutputData<double> &data, std::ostream &output_stream)
+void TiffHandler::write(const OutputData<double>& data, std::ostream& output_stream)
 {
     m_data.reset(data.clone());
-    if(m_data->getRank() != 2)
-        throw Exceptions::LogicErrorException(
-            "TiffHandler::write -> Error. "
-            "Only 2-dim arrays supported");
+    if (m_data->getRank() != 2)
+        throw Exceptions::LogicErrorException("TiffHandler::write -> Error. "
+                                              "Only 2-dim arrays supported");
     m_tiff = TIFFStreamOpen("MemTIFF", &output_stream);
     m_width = m_data->getAxis(BornAgain::X_AXIS_INDEX).size();
-    m_height = m_data->getAxis(BornAgain::Y_AXIS_INDEX).size(); //this does not exist for 1d data
+    m_height = m_data->getAxis(BornAgain::Y_AXIS_INDEX).size(); // this does not exist for 1d data
     write_header();
     write_data();
     close();
@@ -71,8 +70,8 @@ void TiffHandler::read_header()
                                                "Can't read width/height.");
     }
 
-    m_width = (size_t) width;
-    m_height = (size_t) height;
+    m_width = (size_t)width;
+    m_height = (size_t)height;
 
     uint16 orientationTag(0);
     TIFFGetField(m_tiff, TIFFTAG_ORIENTATION, &orientationTag);
@@ -83,27 +82,27 @@ void TiffHandler::read_header()
     if (!TIFFGetField(m_tiff, TIFFTAG_BITSPERSAMPLE, &m_bitsPerSample))
         m_bitsPerSample = 1;
     if (8 != m_bitsPerSample && 16 != m_bitsPerSample && 32 != m_bitsPerSample)
-      good = false;
+        good = false;
 
     // they may be e.g. grayscale with 2 samples per pixel
     if (!TIFFGetField(m_tiff, TIFFTAG_SAMPLESPERPIXEL, &m_samplesPerPixel))
         m_samplesPerPixel = 1;
     if (m_samplesPerPixel != 1)
-      good = false;
+        good = false;
 
     if (!TIFFGetField(m_tiff, TIFFTAG_SAMPLEFORMAT, &m_sampleFormat))
-      m_sampleFormat = 1;
+        m_sampleFormat = 1;
 
     switch (m_sampleFormat) {
     case 1: // unsigned int
     case 2: // signed int
-      break;
+        break;
     case 3: // IEEE float
-      if (32 != m_bitsPerSample)
-        good = false;
-      break;
+        if (32 != m_bitsPerSample)
+            good = false;
+        break;
     default:
-      good = false;
+        good = false;
     }
 
     if (!good) {
@@ -115,23 +114,22 @@ void TiffHandler::read_header()
                 << "    TIFFTAG_SAMPLEFORMAT: " << m_sampleFormat << std::endl;
         throw Exceptions::FormatErrorException(message.str());
     }
-
 }
 
 void TiffHandler::read_data()
 {
     assert(m_tiff);
 
-    assert(0 == m_bitsPerSample%8);
-    uint16 bytesPerSample = m_bitsPerSample/8;
+    assert(0 == m_bitsPerSample % 8);
+    uint16 bytesPerSample = m_bitsPerSample / 8;
     tmsize_t buf_size = TIFFScanlineSize(m_tiff);
     tmsize_t expected_size = bytesPerSample * m_width;
-    if(buf_size != expected_size)
+    if (buf_size != expected_size)
         throw Exceptions::FormatErrorException(
             "TiffHandler::read_data() -> Error. Wrong scanline size.");
 
     tdata_t buf = _TIFFmalloc(buf_size);
-    if(!buf)
+    if (!buf)
         throw Exceptions::FormatErrorException(
             "TiffHandler::read_data() -> Error. Can't allocate buffer.");
 
@@ -142,53 +140,53 @@ void TiffHandler::read_data()
 
     std::vector<unsigned> axes_indices(2);
 
-    for (uint32 row = 0; row < (uint32) m_height; row++) {
-        if(TIFFReadScanline(m_tiff, buf, row) < 0)
+    for (uint32 row = 0; row < (uint32)m_height; row++) {
+        if (TIFFReadScanline(m_tiff, buf, row) < 0)
             throw Exceptions::FormatErrorException(
                 "TiffHandler::read_data() -> Error. Error in scanline.");
 
         memcpy(&line_buf[0], buf, buf_size);
 
-        for(unsigned col=0; col<m_width; ++col) {
+        for (unsigned col = 0; col < m_width; ++col) {
             axes_indices[0] = col;
             axes_indices[1] = static_cast<unsigned>(m_height) - 1 - row;
             size_t global_index = m_data->toGlobalIndex(axes_indices);
 
-            void *incoming = &line_buf[col*bytesPerSample];
+            void* incoming = &line_buf[col * bytesPerSample];
             double sample = 0;
 
             switch (m_sampleFormat) {
             case 1: // unsigned int
-              switch (m_bitsPerSample) {
-              case 8:
-                sample = *reinterpret_cast<uint8*>(incoming);
-                break;
-              case 16:
-                sample = *reinterpret_cast<uint16*>(incoming);
-                break;
-              case 32:
-                sample = *reinterpret_cast<uint32*>(incoming);
+                switch (m_bitsPerSample) {
+                case 8:
+                    sample = *reinterpret_cast<uint8*>(incoming);
+                    break;
+                case 16:
+                    sample = *reinterpret_cast<uint16*>(incoming);
+                    break;
+                case 32:
+                    sample = *reinterpret_cast<uint32*>(incoming);
+                    break;
+                }
                 break;
-              }
-              break;
             case 2: // signed int
-              switch (m_bitsPerSample) {
-              case 8:
-                sample = *reinterpret_cast<int8*>(incoming);
+                switch (m_bitsPerSample) {
+                case 8:
+                    sample = *reinterpret_cast<int8*>(incoming);
+                    break;
+                case 16:
+                    sample = *reinterpret_cast<int16*>(incoming);
+                    break;
+                case 32:
+                    sample = *reinterpret_cast<int32*>(incoming);
+                    break;
+                }
                 break;
-              case 16:
-                sample = *reinterpret_cast<int16*>(incoming);
-                break;
-              case 32:
-                sample = *reinterpret_cast<int32*>(incoming);
-                break;
-              }
-              break;
             case 3: // IEEE float
-              sample = double(*reinterpret_cast<float*>(incoming));
-              break;
+                sample = double(*reinterpret_cast<float*>(incoming));
+                break;
             default:
-              throw Exceptions::FormatErrorException("TiffHandler: unexpected sample format");
+                throw Exceptions::FormatErrorException("TiffHandler: unexpected sample format");
             }
 
             (*m_data)[global_index] = sample;
@@ -203,7 +201,7 @@ void TiffHandler::write_header()
     TIFFSetField(m_tiff, TIFFTAG_ARTIST, "BornAgain.IOFactory");
     TIFFSetField(m_tiff, TIFFTAG_DATETIME, SysUtils::getCurrentDateAndTime().c_str());
     TIFFSetField(m_tiff, TIFFTAG_IMAGEDESCRIPTION,
-           "Image converted from BornAgain intensity file.");
+                 "Image converted from BornAgain intensity file.");
     TIFFSetField(m_tiff, TIFFTAG_SOFTWARE, "BornAgain");
 
     uint32 width = static_cast<uint32>(m_width);
@@ -224,15 +222,15 @@ void TiffHandler::write_data()
     typedef int sample_t;
     tmsize_t buf_size = sizeof(sample_t) * m_width;
     tdata_t buf = _TIFFmalloc(buf_size);
-    if(!buf)
+    if (!buf)
         throw Exceptions::FormatErrorException(
             "TiffHandler::write_data() -> Error. Can't allocate buffer.");
 
     std::vector<sample_t> line_buf;
     line_buf.resize(m_width, 0);
     std::vector<unsigned> axes_indices(2);
-    for (unsigned row = 0; row < (uint32) m_height; row++) {
-        for(unsigned col=0; col<line_buf.size(); ++col) {
+    for (unsigned row = 0; row < (uint32)m_height; row++) {
+        for (unsigned col = 0; col < line_buf.size(); ++col) {
             axes_indices[0] = col;
             axes_indices[1] = static_cast<unsigned>(m_height) - 1 - row;
             size_t global_index = m_data->toGlobalIndex(axes_indices);
@@ -240,7 +238,7 @@ void TiffHandler::write_data()
         }
         memcpy(buf, &line_buf[0], buf_size);
 
-        if(TIFFWriteScanline(m_tiff, buf, row) < 0)
+        if (TIFFWriteScanline(m_tiff, buf, row) < 0)
             throw Exceptions::FormatErrorException(
                 "TiffHandler::write_data() -> Error. Error in TIFFWriteScanline.");
     }
@@ -250,7 +248,7 @@ void TiffHandler::write_data()
 
 void TiffHandler::close()
 {
-    if(m_tiff) {
+    if (m_tiff) {
         TIFFClose(m_tiff);
         m_tiff = 0;
         m_width = 0;
diff --git a/Core/InputOutput/TiffHandler.h b/Core/InputOutput/TiffHandler.h
index b9dc9ad22be..8d52c0d9ab7 100644
--- a/Core/InputOutput/TiffHandler.h
+++ b/Core/InputOutput/TiffHandler.h
@@ -18,9 +18,9 @@
 #ifdef BORNAGAIN_TIFF_SUPPORT
 
 #include "OutputData.h"
+#include <memory>
 #include <tiffio.h>
 #include <tiffio.hxx>
-#include <memory>
 
 //! Reads/write tiff files, should be used through TiffReadStrategy.
 //! @ingroup input_output_internal
diff --git a/Core/InputOutput/boost_streams.h b/Core/InputOutput/boost_streams.h
index 1d87b46f0d2..82f1dee5279 100644
--- a/Core/InputOutput/boost_streams.h
+++ b/Core/InputOutput/boost_streams.h
@@ -16,19 +16,18 @@
 #define BOOST_STREAMS_H
 
 #include "Macros.h"
-GCC_DIAG_OFF(unused-parameter)
-#include <boost/iostreams/filtering_stream.hpp>
+GCC_DIAG_OFF(unused - parameter)
 #include <boost/iostreams/copy.hpp>
+#include <boost/iostreams/filtering_stream.hpp>
 #ifdef _MSC_VER
 #pragma warning(push)
-#pragma warning(disable: 4244)
+#pragma warning(disable : 4244)
 #endif
-#include <boost/iostreams/filter/gzip.hpp>
 #include <boost/iostreams/filter/bzip2.hpp>
+#include <boost/iostreams/filter/gzip.hpp>
 #ifdef _MSC_VER
 #pragma warning(pop)
 #endif
-GCC_DIAG_ON(unused-parameter)
+GCC_DIAG_ON(unused - parameter)
 
 #endif // BOOST_STREAMS_H
-
diff --git a/Core/Instrument/AngularSpecScan.cpp b/Core/Instrument/AngularSpecScan.cpp
index fcce8cb028f..adfc4b39e37 100644
--- a/Core/Instrument/AngularSpecScan.cpp
+++ b/Core/Instrument/AngularSpecScan.cpp
@@ -23,41 +23,38 @@
 #include "ScanResolution.h"
 #include "SpecularSimulationElement.h"
 
-namespace {
+namespace
+{
 std::vector<std::vector<double>>
 extractValues(std::vector<std::vector<ParameterSample>> samples,
               const std::function<double(const ParameterSample&)> extractor);
 
 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)
-    : ISpecularScan(SPECULAR_DATA_TYPE::angle)
-    , m_wl(wl)
-    , m_inc_angle(std::make_unique<PointwiseAxis>("inc_angles", std::move(inc_angle)))
-    , m_wl_resolution(ScanResolution::scanEmptyResolution())
-    , m_inc_resolution(ScanResolution::scanEmptyResolution())
+    : ISpecularScan(SPECULAR_DATA_TYPE::angle), m_wl(wl),
+      m_inc_angle(std::make_unique<PointwiseAxis>("inc_angles", std::move(inc_angle))),
+      m_wl_resolution(ScanResolution::scanEmptyResolution()),
+      m_inc_resolution(ScanResolution::scanEmptyResolution())
 {
     checkInitialization();
 }
 
 AngularSpecScan::AngularSpecScan(double wl, const IAxis& inc_angle)
-    : ISpecularScan(SPECULAR_DATA_TYPE::angle)
-    , m_wl(wl)
-    , m_inc_angle(inc_angle.clone())
-    , m_wl_resolution(ScanResolution::scanEmptyResolution())
-    , m_inc_resolution(ScanResolution::scanEmptyResolution())
+    : ISpecularScan(SPECULAR_DATA_TYPE::angle), m_wl(wl), m_inc_angle(inc_angle.clone()),
+      m_wl_resolution(ScanResolution::scanEmptyResolution()),
+      m_inc_resolution(ScanResolution::scanEmptyResolution())
 {
     checkInitialization();
 }
 
 AngularSpecScan::AngularSpecScan(double wl, int nbins, double alpha_i_min, double alpha_i_max)
-    : ISpecularScan(SPECULAR_DATA_TYPE::angle)
-    , m_wl(wl)
-    , m_inc_angle(std::make_unique<FixedBinAxis>("inc_angles", nbins, alpha_i_min, alpha_i_max))
-    , m_wl_resolution(ScanResolution::scanEmptyResolution())
-    , m_inc_resolution(ScanResolution::scanEmptyResolution())
+    : ISpecularScan(SPECULAR_DATA_TYPE::angle), m_wl(wl),
+      m_inc_angle(std::make_unique<FixedBinAxis>("inc_angles", nbins, alpha_i_min, alpha_i_max)),
+      m_wl_resolution(ScanResolution::scanEmptyResolution()),
+      m_inc_resolution(ScanResolution::scanEmptyResolution())
 {
     checkInitialization();
 }
@@ -142,7 +139,7 @@ void AngularSpecScan::setAngleResolution(const ScanResolution& resolution)
     m_inc_res_cache.shrink_to_fit();
 }
 
-void AngularSpecScan::setRelativeAngularResolution(const RangedDistribution &distr, double rel_dev)
+void AngularSpecScan::setRelativeAngularResolution(const RangedDistribution& distr, double rel_dev)
 {
     std::unique_ptr<ScanResolution> resolution(
         ScanResolution::scanRelativeResolution(distr, rel_dev));
@@ -157,7 +154,7 @@ void AngularSpecScan::setRelativeAngularResolution(const RangedDistribution& dis
     setAngleResolution(*resolution);
 }
 
-void AngularSpecScan::setAbsoluteAngularResolution(const RangedDistribution &distr, double std_dev)
+void AngularSpecScan::setAbsoluteAngularResolution(const RangedDistribution& distr, double std_dev)
 {
     std::unique_ptr<ScanResolution> resolution(
         ScanResolution::scanAbsoluteResolution(distr, std_dev));
@@ -244,8 +241,7 @@ std::string AngularSpecScan::print() const
     result << "\n" << PythonFormatting::indent() << "# Defining specular scan:\n";
     const std::string axis_def = PythonFormatting::indent() + "axis = ";
     result << axis_def
-           << PythonFormatting::printAxis(*coordinateAxis(), BornAgain::UnitsRad,
-                                          axis_def.size())
+           << PythonFormatting::printAxis(*coordinateAxis(), BornAgain::UnitsRad, axis_def.size())
            << "\n";
 
     result << PythonFormatting::indent() << "scan = ";
@@ -323,7 +319,7 @@ extractValues(std::vector<std::vector<ParameterSample>> samples,
 {
     std::vector<std::vector<double>> result;
     result.resize(samples.size());
-    for(size_t i = 0, size = result.size(); i < size; ++i) {
+    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());
@@ -334,4 +330,4 @@ extractValues(std::vector<std::vector<ParameterSample>> samples,
     }
     return result;
 }
-}
+} // namespace
diff --git a/Core/Instrument/AngularSpecScan.h b/Core/Instrument/AngularSpecScan.h
index ded69c83261..c0f61b01b9a 100644
--- a/Core/Instrument/AngularSpecScan.h
+++ b/Core/Instrument/AngularSpecScan.h
@@ -106,7 +106,7 @@ public:
     //! _std_dev_ can be either single-valued or a numpy array. In the latter case the length of the
     //! array should coinside with the length of the inclination angle axis.
     void setAbsoluteAngularResolution(const RangedDistribution& distr,
-                                         const std::vector<double>& std_dev);
+                                      const std::vector<double>& std_dev);
 
 private:
     using WlAnglePair = std::pair<double, double>;
diff --git a/Core/Instrument/ArrayUtils.cpp b/Core/Instrument/ArrayUtils.cpp
index 13b3f275dc5..791d22e0cab 100644
--- a/Core/Instrument/ArrayUtils.cpp
+++ b/Core/Instrument/ArrayUtils.cpp
@@ -22,19 +22,19 @@ PyObject* ArrayUtils::createNumpyArray(const std::vector<double>& data)
 {
     const size_t ndim(1);
     npy_int ndim_numpy = ndim;
-    npy_intp *ndimsizes_numpy = new npy_intp[ndim];
+    npy_intp* ndimsizes_numpy = new npy_intp[ndim];
     ndimsizes_numpy[0] = data.size();
 
     // creating standalone numpy array
-    PyObject *pyarray = PyArray_SimpleNew(ndim_numpy, ndimsizes_numpy, NPY_DOUBLE);
-    delete [] ndimsizes_numpy;
-    if(pyarray == nullptr )
+    PyObject* pyarray = PyArray_SimpleNew(ndim_numpy, ndimsizes_numpy, NPY_DOUBLE);
+    delete[] ndimsizes_numpy;
+    if (pyarray == nullptr)
         throw Exceptions::RuntimeErrorException("ExportOutputData() -> Panic in PyArray_SimpleNew");
 
     // getting pointer to data buffer of numpy array
-    double *array_buffer = (double *)PyArray_DATA((PyArrayObject*)pyarray);
+    double* array_buffer = (double*)PyArray_DATA((PyArrayObject*)pyarray);
 
-    for(size_t index=0; index<data.size(); ++index)
+    for (size_t index = 0; index < data.size(); ++index)
         *array_buffer++ = data[index];
 
     return pyarray;
diff --git a/Core/Instrument/ArrayUtils.h b/Core/Instrument/ArrayUtils.h
index 5b3a04268ab..bd6c59194f9 100644
--- a/Core/Instrument/ArrayUtils.h
+++ b/Core/Instrument/ArrayUtils.h
@@ -15,51 +15,56 @@
 #ifndef ARRAYUTILS_H
 #define ARRAYUTILS_H
 
-#include <vector>
-#include "WinDllMacros.h"
 #include "OutputData.h"
-#include <stdexcept>
+#include "WinDllMacros.h"
 #include <memory>
+#include <stdexcept>
+#include <vector>
 
 //! Array and Numpy utility functions getShape, createNumpyArray.
 
 namespace ArrayUtils
 {
 //! Returns shape nrows, ncols of 2D array.
-template<class T> std::pair<size_t, size_t> getShape(const T& data);
+template <class T> std::pair<size_t, size_t> getShape(const T& data);
 
-class CreateDataImpl {
+class CreateDataImpl
+{
     //! Holds the dimensionality of template argument as the enum value.
     //! Intended for vectors only.
-    template <typename T> struct nDim { enum { value = 0 }; };
+    template <typename T> struct nDim {
+        enum { value = 0 };
+    };
     template <typename T, typename A> struct nDim<std::vector<T, A>> {
         enum { value = 1 + nDim<T>::value };
     };
 
-    template <typename T> struct baseClass { using value = T; };
+    template <typename T> struct baseClass {
+        using value = T;
+    };
     template <typename T, typename A> struct baseClass<std::vector<T, A>> {
         using value = typename baseClass<T>::value;
     };
 
-    template<class T>
+    template <class T>
     using ReturnType = std::unique_ptr<OutputData<typename CreateDataImpl::baseClass<T>::value>>;
 
     template <class T> friend ReturnType<T> createData(const T& vec);
 
-    template<class T>
+    template <class T>
     static std::unique_ptr<OutputData<T>> createDataImpl(const std::vector<T>& vec);
 
-    template<class T>
+    template <class T>
     static std::unique_ptr<OutputData<T>> createDataImpl(const std::vector<std::vector<T>>& vec);
 };
 
 //! Creates OutputData array from input vector.
 //! @param vec: input vector
-template<class T>
-CreateDataImpl::ReturnType<T> createData(const T& vec)
+template <class T> CreateDataImpl::ReturnType<T> createData(const T& vec)
 {
     constexpr const int size = CreateDataImpl::nDim<T>::value;
-    static_assert(size == 1 || size == 2,
+    static_assert(
+        size == 1 || size == 2,
         "Error in ArrayUtils::createData: invalid dimensionality or type of the input argument");
     static_assert(std::is_same<CreateDataImpl::ReturnType<T>,
                                decltype(CreateDataImpl::createDataImpl(vec))>::value,
@@ -74,16 +79,16 @@ PyObject* createNumpyArray(const std::vector<double>& data);
 //! Creates 1D vector from OutputData.
 //! @param vec: OutputData<double>
 //! @return vector<double>
-template<class T> decltype(auto) createVector1D(const T& data);
+template <class T> decltype(auto) createVector1D(const T& data);
 
 //! Creates 2D vector from OutputData.
 //! @param vec: OutputData<double>
 //! @return vector<vector<double>>
-template<class T> decltype(auto) createVector2D(const T& data);
+template <class T> decltype(auto) createVector2D(const T& data);
 
-}
+} // namespace ArrayUtils
 
-template<class T>
+template <class T>
 std::unique_ptr<OutputData<T>> ArrayUtils::CreateDataImpl::createDataImpl(const std::vector<T>& vec)
 {
     auto result = std::make_unique<OutputData<T>>();
@@ -103,7 +108,7 @@ ArrayUtils::CreateDataImpl::createDataImpl(const std::vector<std::vector<T>>& ve
     const size_t nrows = shape.first;
     const size_t ncols = shape.second;
 
-    if(nrows == 0 || ncols == 0)
+    if (nrows == 0 || ncols == 0)
         throw std::runtime_error(
             "Error in ArrayUtils::createDataImpl: input argument contains empty dimensions");
 
@@ -111,9 +116,9 @@ ArrayUtils::CreateDataImpl::createDataImpl(const std::vector<std::vector<T>>& ve
     result->addAxis(FixedBinAxis("axis1", nrows, 0.0, static_cast<double>(nrows)));
 
     // filling the data
-    for(size_t row=0; row<nrows; ++row) {
-        for(size_t col=0; col<ncols; ++col) {
-            size_t globalbin = nrows - row - 1 + col*nrows;
+    for (size_t row = 0; row < nrows; ++row) {
+        for (size_t col = 0; col < ncols; ++col) {
+            size_t globalbin = nrows - row - 1 + col * nrows;
             (*result)[globalbin] = vec[row][col];
         }
     }
@@ -121,18 +126,20 @@ ArrayUtils::CreateDataImpl::createDataImpl(const std::vector<std::vector<T>>& ve
     return result;
 }
 
-template<class T>  std::pair<size_t, size_t> ArrayUtils::getShape(const T& data){
+template <class T> std::pair<size_t, size_t> ArrayUtils::getShape(const T& data)
+{
     size_t nrows = data.size();
     size_t ncols(0);
-    if(nrows) ncols = data[0].size();
-    for(size_t row=0; row<nrows; row++)
-        if(data[row].size() != ncols)
+    if (nrows)
+        ncols = data[0].size();
+    for (size_t row = 0; row < nrows; row++)
+        if (data[row].size() != ncols)
             throw std::runtime_error("Util::getShape() -> Error. "
                                      "Number of elements is different from row to row.");
     return std::make_pair(nrows, ncols);
 }
 
-template<class T> decltype(auto) ArrayUtils::createVector1D(const T& data)
+template <class T> decltype(auto) ArrayUtils::createVector1D(const T& data)
 {
     if (data.getRank() != 1)
         throw std::runtime_error("ArrayUtils::createVector1D() -> Error. Not 1D data.");
@@ -142,7 +149,7 @@ template<class T> decltype(auto) ArrayUtils::createVector1D(const T& data)
     return result;
 }
 
-template<class T> decltype(auto) ArrayUtils::createVector2D(const T& data)
+template <class T> decltype(auto) ArrayUtils::createVector2D(const T& data)
 {
     using value_type = typename T::value_type;
     std::vector<std::vector<value_type>> result;
@@ -152,10 +159,10 @@ template<class T> decltype(auto) ArrayUtils::createVector2D(const T& data)
 
     result.resize(nrows);
 
-    for(size_t row=0; row<nrows; ++row) {
+    for (size_t row = 0; row < nrows; ++row) {
         result[row].resize(ncols, 0.0);
-        for(size_t col=0; col<ncols; ++col) {
-            size_t globalbin = nrows - row - 1 + col*nrows;
+        for (size_t col = 0; col < ncols; ++col) {
+            size_t globalbin = nrows - row - 1 + col * nrows;
             result[row][col] = data[globalbin];
         }
     }
@@ -163,5 +170,4 @@ template<class T> decltype(auto) ArrayUtils::createVector2D(const T& data)
     return result;
 }
 
-
 #endif // ARRAYUTILS_H
diff --git a/Core/Instrument/AxisNames.cpp b/Core/Instrument/AxisNames.cpp
index 39fd583f12b..805b85f2257 100644
--- a/Core/Instrument/AxisNames.cpp
+++ b/Core/Instrument/AxisNames.cpp
@@ -116,4 +116,4 @@ std::map<AxesUnits, std::string> InitSampleDepthAxis()
     return result;
 }
 
-}
+} // namespace AxisNames
diff --git a/Core/Instrument/AxisNames.h b/Core/Instrument/AxisNames.h
index b1ae4b91f5a..119f67f43c9 100644
--- a/Core/Instrument/AxisNames.h
+++ b/Core/Instrument/AxisNames.h
@@ -33,6 +33,6 @@ BA_CORE_API_ std::map<AxesUnits, std::string> InitOffSpecAxis1();
 BA_CORE_API_ std::map<AxesUnits, std::string> InitSpecAxis();
 BA_CORE_API_ std::map<AxesUnits, std::string> InitSpecAxisQ();
 BA_CORE_API_ std::map<AxesUnits, std::string> InitSampleDepthAxis();
-}
+} // namespace AxisNames
 
 #endif // AXISNAMES_H
diff --git a/Core/Instrument/ChiSquaredModule.cpp b/Core/Instrument/ChiSquaredModule.cpp
index 89c019d0bca..fa8c731251e 100644
--- a/Core/Instrument/ChiSquaredModule.cpp
+++ b/Core/Instrument/ChiSquaredModule.cpp
@@ -16,21 +16,21 @@
 #include "IIntensityFunction.h"
 #include "VarianceFunctions.h"
 #include <cassert>
-#include <limits>
 #include <cmath>
+#include <limits>
 
 double ChiSquaredModule::residual(double a, double b, double weight)
 {
     double value_simu = a;
     double value_real = b;
 
-    if(mp_intensity_function) {
+    if (mp_intensity_function) {
         value_simu = mp_intensity_function->evaluate(value_simu);
         value_real = mp_intensity_function->evaluate(value_real);
     }
 
     double variance = m_variance_function->variance(value_real, value_simu);
-    double normalize = variance <=0 ? std::numeric_limits<double>::min() : std::sqrt(variance);
+    double normalize = variance <= 0 ? std::numeric_limits<double>::min() : std::sqrt(variance);
 
-    return std::sqrt(weight)*(value_simu - value_real)/normalize;
+    return std::sqrt(weight) * (value_simu - value_real) / normalize;
 }
diff --git a/Core/Instrument/ChiSquaredModule.h b/Core/Instrument/ChiSquaredModule.h
index c51f1f637e9..a8f2f742f2a 100644
--- a/Core/Instrument/ChiSquaredModule.h
+++ b/Core/Instrument/ChiSquaredModule.h
@@ -24,11 +24,10 @@ class BA_CORE_API_ ChiSquaredModule : public IChiSquaredModule
 {
 public:
     ChiSquaredModule() {}
-    ChiSquaredModule(const ChiSquaredModule& other)
-        : IChiSquaredModule(other) {}
+    ChiSquaredModule(const ChiSquaredModule& other) : IChiSquaredModule(other) {}
     virtual ~ChiSquaredModule() {}
 
-    virtual ChiSquaredModule *clone() const { return new ChiSquaredModule(*this); }
+    virtual ChiSquaredModule* clone() const { return new ChiSquaredModule(*this); }
 
     virtual double residual(double a, double b, double weight);
 };
diff --git a/Core/Instrument/ConvolutionDetectorResolution.cpp b/Core/Instrument/ConvolutionDetectorResolution.cpp
index 268517da417..39d57e326d1 100644
--- a/Core/Instrument/ConvolutionDetectorResolution.cpp
+++ b/Core/Instrument/ConvolutionDetectorResolution.cpp
@@ -15,35 +15,28 @@
 #include "ConvolutionDetectorResolution.h"
 #include "Convolve.h"
 
-
-ConvolutionDetectorResolution::ConvolutionDetectorResolution(
-    cumulative_DF_1d res_function_1d)
-    : m_dimension(1)
-    , m_res_function_1d(res_function_1d)
+ConvolutionDetectorResolution::ConvolutionDetectorResolution(cumulative_DF_1d res_function_1d)
+    : m_dimension(1), m_res_function_1d(res_function_1d)
 {
     setName("ConvolutionDetectorResolution");
 }
 
 ConvolutionDetectorResolution::ConvolutionDetectorResolution(
-    const IResolutionFunction2D &p_res_function_2d)
-    : m_dimension(2)
-    , m_res_function_1d(0)
+    const IResolutionFunction2D& p_res_function_2d)
+    : m_dimension(2), m_res_function_1d(0)
 {
     setName("ConvolutionDetectorResolution");
     setResolutionFunction(p_res_function_2d);
 }
 
-
-ConvolutionDetectorResolution::~ConvolutionDetectorResolution()
-{
-}
+ConvolutionDetectorResolution::~ConvolutionDetectorResolution() {}
 
 ConvolutionDetectorResolution::ConvolutionDetectorResolution(
     const ConvolutionDetectorResolution& other)
 {
     m_dimension = other.m_dimension;
-    m_res_function_1d=other.m_res_function_1d;
-    if(other.mp_res_function_2d)
+    m_res_function_1d = other.m_res_function_1d;
+    if (other.mp_res_function_2d)
         setResolutionFunction(*other.mp_res_function_2d);
     setName(other.getName());
 }
@@ -64,7 +57,7 @@ void ConvolutionDetectorResolution::applyDetectorResolution(
     if (p_intensity_map->getRank() != m_dimension) {
         throw Exceptions::RuntimeErrorException(
             "ConvolutionDetectorResolution::applyDetectorResolution() -> Error! "
-            "Intensity map must have same dimension as detector resolution function." );
+            "Intensity map must have same dimension as detector resolution function.");
     }
     switch (m_dimension) {
     case 1:
@@ -76,13 +69,11 @@ void ConvolutionDetectorResolution::applyDetectorResolution(
     default:
         throw Exceptions::LogicErrorException(
             "ConvolutionDetectorResolution::applyDetectorResolution() -> Error! "
-            "Class ConvolutionDetectorResolution must be initialized with dimension 1 or 2." );
+            "Class ConvolutionDetectorResolution must be initialized with dimension 1 or 2.");
     }
 }
 
-void ConvolutionDetectorResolution::init_parameters()
-{
-}
+void ConvolutionDetectorResolution::init_parameters() {}
 
 void ConvolutionDetectorResolution::setResolutionFunction(const IResolutionFunction2D& resFunc)
 {
@@ -92,15 +83,15 @@ void ConvolutionDetectorResolution::setResolutionFunction(const IResolutionFunct
 
 void ConvolutionDetectorResolution::apply1dConvolution(OutputData<double>* p_intensity_map) const
 {
-    if (m_res_function_1d==0)
+    if (m_res_function_1d == 0)
         throw Exceptions::LogicErrorException(
             "ConvolutionDetectorResolution::apply1dConvolution() -> Error! "
-            "No 1d resolution function present for convolution of 1d data." );
+            "No 1d resolution function present for convolution of 1d data.");
     if (p_intensity_map->getRank() != 1)
         throw Exceptions::LogicErrorException(
             "ConvolutionDetectorResolution::apply1dConvolution() -> Error! "
-            "Number of axes for intensity map does not correspond to the dimension of the map." );
-    const IAxis &axis = p_intensity_map->getAxis(0);
+            "Number of axes for intensity map does not correspond to the dimension of the map.");
+    const IAxis& axis = p_intensity_map->getAxis(0);
     // Construct source vector from original intensity map
     std::vector<double> source_vector = p_intensity_map->getRawDataVector();
     size_t data_size = source_vector.size();
@@ -110,34 +101,34 @@ void ConvolutionDetectorResolution::apply1dConvolution(OutputData<double>* p_int
     if (axis.size() != data_size)
         throw Exceptions::LogicErrorException(
             "ConvolutionDetectorResolution::apply1dConvolution() -> Error! "
-            "Size of axis for intensity map does not correspond to size of data in the map." );
-    double step_size = std::abs(axis[0]-axis[axis.size()-1])/(data_size-1);
-    double mid_value = axis[axis.size()/2]; // because Convolve expects zero at midpoint
+            "Size of axis for intensity map does not correspond to size of data in the map.");
+    double step_size = std::abs(axis[0] - axis[axis.size() - 1]) / (data_size - 1);
+    double mid_value = axis[axis.size() / 2]; // because Convolve expects zero at midpoint
     std::vector<double> kernel;
-    for (size_t index=0; index<data_size; ++index) {
+    for (size_t index = 0; index < data_size; ++index) {
         kernel.push_back(getIntegratedPDF1d(axis[index] - mid_value, step_size));
     }
     // Calculate convolution
     std::vector<double> result;
     Convolve().fftconvolve(source_vector, kernel, result);
     // Truncate negative values that can arise because of finite precision of Fourier Transform
-    std::for_each(result.begin(), result.end(), [](double &val){ val = std::max(0.0, val); });
+    std::for_each(result.begin(), result.end(), [](double& val) { val = std::max(0.0, val); });
     // Populate intensity map with results
     p_intensity_map->setRawDataVector(result);
 }
 
 void ConvolutionDetectorResolution::apply2dConvolution(OutputData<double>* p_intensity_map) const
 {
-    if (mp_res_function_2d==0)
+    if (mp_res_function_2d == 0)
         throw Exceptions::LogicErrorException(
             "ConvolutionDetectorResolution::apply2dConvolution() -> Error! "
-            "No 2d resolution function present for convolution of 2d data." );
+            "No 2d resolution function present for convolution of 2d data.");
     if (p_intensity_map->getRank() != 2)
         throw Exceptions::LogicErrorException(
             "ConvolutionDetectorResolution::apply2dConvolution() -> Error! "
-            "Number of axes for intensity map does not correspond to the dimension of the map." );
-    const IAxis &axis_1 = p_intensity_map->getAxis(0);
-    const IAxis &axis_2 = p_intensity_map->getAxis(1);
+            "Number of axes for intensity map does not correspond to the dimension of the map.");
+    const IAxis& axis_1 = p_intensity_map->getAxis(0);
+    const IAxis& axis_2 = p_intensity_map->getAxis(1);
     size_t axis_size_1 = axis_1.size();
     size_t axis_size_2 = axis_2.size();
     if (axis_size_1 < 2 || axis_size_2 < 2)
@@ -146,27 +137,27 @@ void ConvolutionDetectorResolution::apply2dConvolution(OutputData<double>* p_int
     std::vector<double> raw_source_vector = p_intensity_map->getRawDataVector();
     std::vector<std::vector<double>> source;
     size_t raw_data_size = raw_source_vector.size();
-    if (raw_data_size != axis_size_1*axis_size_2)
+    if (raw_data_size != axis_size_1 * axis_size_2)
         throw Exceptions::LogicErrorException(
             "ConvolutionDetectorResolution::apply2dConvolution() -> Error! "
-            "Intensity map data size does not match the product of its axes' sizes" );
-    for (auto it=raw_source_vector.begin(); it != raw_source_vector.end();it+=axis_size_2) {
-        std::vector<double> row_vector(it, it+axis_size_2);
+            "Intensity map data size does not match the product of its axes' sizes");
+    for (auto it = raw_source_vector.begin(); it != raw_source_vector.end(); it += axis_size_2) {
+        std::vector<double> row_vector(it, it + axis_size_2);
         source.push_back(row_vector);
     }
     // Construct kernel vector from resolution function
     std::vector<std::vector<double>> kernel;
     kernel.resize(axis_size_1);
-    double mid_value_1 = axis_1[axis_size_1/2]; // because Convolve expects zero at midpoint
-    double mid_value_2 = axis_2[axis_size_2/2]; // because Convolve expects zero at midpoint
-    double step_size_1 = std::abs(axis_1[0]-axis_1[axis_size_1-1])/(axis_size_1-1);
-    double step_size_2 = std::abs(axis_2[0]-axis_2[axis_size_2-1])/(axis_size_2-1);
-    for (size_t index_1=0; index_1<axis_size_1; ++index_1) {
-        double value_1 = axis_1[index_1]-mid_value_1;
+    double mid_value_1 = axis_1[axis_size_1 / 2]; // because Convolve expects zero at midpoint
+    double mid_value_2 = axis_2[axis_size_2 / 2]; // because Convolve expects zero at midpoint
+    double step_size_1 = std::abs(axis_1[0] - axis_1[axis_size_1 - 1]) / (axis_size_1 - 1);
+    double step_size_2 = std::abs(axis_2[0] - axis_2[axis_size_2 - 1]) / (axis_size_2 - 1);
+    for (size_t index_1 = 0; index_1 < axis_size_1; ++index_1) {
+        double value_1 = axis_1[index_1] - mid_value_1;
         std::vector<double> row_vector;
         row_vector.resize(axis_size_2, 0.0);
-        for (size_t index_2=0; index_2<axis_size_2;++index_2) {
-            double value_2 = axis_2[index_2]-mid_value_2;
+        for (size_t index_2 = 0; index_2 < axis_size_2; ++index_2) {
+            double value_2 = axis_2[index_2] - mid_value_2;
             double z_value = getIntegratedPDF2d(value_1, step_size_1, value_2, step_size_2);
             row_vector[index_2] = z_value;
         }
@@ -177,40 +168,39 @@ void ConvolutionDetectorResolution::apply2dConvolution(OutputData<double>* p_int
     Convolve().fftconvolve(source, kernel, result);
     // Populate intensity map with results
     std::vector<double> result_vector;
-    for (size_t index_1=0; index_1<axis_size_1; ++index_1) {
-        for (size_t index_2=0; index_2<axis_size_2;++index_2) {
+    for (size_t index_1 = 0; index_1 < axis_size_1; ++index_1) {
+        for (size_t index_2 = 0; index_2 < axis_size_2; ++index_2) {
             double value = result[index_1][index_2];
             result_vector.push_back(value);
         }
     }
     // Truncate negative values that can arise because of finite precision of Fourier Transform
     std::for_each(result_vector.begin(), result_vector.end(),
-                  [](double &val){ val = std::max(0.0, val); });
-    for(auto it=p_intensity_map->begin(); it!=p_intensity_map->end(); ++it)
+                  [](double& val) { val = std::max(0.0, val); });
+    for (auto it = p_intensity_map->begin(); it != p_intensity_map->end(); ++it)
         (*it) = result_vector[it.getIndex()];
 }
 
 double ConvolutionDetectorResolution::getIntegratedPDF1d(double x, double step) const
 {
-    double halfstep = step/2.0;
+    double halfstep = step / 2.0;
     double xmin = x - halfstep;
     double xmax = x + halfstep;
     assert(m_res_function_1d != nullptr);
     return m_res_function_1d(xmax) - m_res_function_1d(xmin);
 }
 
-double ConvolutionDetectorResolution::getIntegratedPDF2d(
-    double x, double step_x, double y, double step_y) const
+double ConvolutionDetectorResolution::getIntegratedPDF2d(double x, double step_x, double y,
+                                                         double step_y) const
 {
-    double halfstepx = step_x/2.0;
-    double halfstepy = step_y/2.0;
+    double halfstepx = step_x / 2.0;
+    double halfstepy = step_y / 2.0;
     double xmin = x - halfstepx;
     double xmax = x + halfstepx;
     double ymin = y - halfstepy;
     double ymax = y + halfstepy;
-    double result = mp_res_function_2d->evaluateCDF(xmax, ymax) -
-        mp_res_function_2d->evaluateCDF(xmax, ymin) -
-        mp_res_function_2d->evaluateCDF(xmin, ymax) +
-        mp_res_function_2d->evaluateCDF(xmin, ymin);
+    double result =
+        mp_res_function_2d->evaluateCDF(xmax, ymax) - mp_res_function_2d->evaluateCDF(xmax, ymin)
+        - mp_res_function_2d->evaluateCDF(xmin, ymax) + mp_res_function_2d->evaluateCDF(xmin, ymin);
     return result;
 }
diff --git a/Core/Instrument/ConvolutionDetectorResolution.h b/Core/Instrument/ConvolutionDetectorResolution.h
index 1646e285962..d307ffa4765 100644
--- a/Core/Instrument/ConvolutionDetectorResolution.h
+++ b/Core/Instrument/ConvolutionDetectorResolution.h
@@ -32,18 +32,18 @@ public:
     ConvolutionDetectorResolution(cumulative_DF_1d res_function_1d);
 
     //! Constructor taking a 2 dimensional resolution function as argument.
-    ConvolutionDetectorResolution(const IResolutionFunction2D &p_res_function_2d);
+    ConvolutionDetectorResolution(const IResolutionFunction2D& p_res_function_2d);
 
     virtual ~ConvolutionDetectorResolution();
 
     //! Convolve given intensities with the encapsulated resolution.
-    virtual void applyDetectorResolution(OutputData<double> *p_intensity_map) const;
+    virtual void applyDetectorResolution(OutputData<double>* p_intensity_map) const;
 
-    virtual ConvolutionDetectorResolution *clone() const;
+    virtual ConvolutionDetectorResolution* clone() const;
 
     void accept(INodeVisitor* visitor) const final { visitor->visit(this); }
 
-    const IResolutionFunction2D *getResolutionFunction2D() const;
+    const IResolutionFunction2D* getResolutionFunction2D() const;
 
     std::vector<const INode*> getChildren() const;
 
@@ -54,8 +54,8 @@ protected:
 
 private:
     void setResolutionFunction(const IResolutionFunction2D& resFunc);
-    void apply1dConvolution(OutputData<double> *p_intensity_map) const;
-    void apply2dConvolution(OutputData<double> *p_intensity_map) const;
+    void apply1dConvolution(OutputData<double>* p_intensity_map) const;
+    void apply2dConvolution(OutputData<double>* p_intensity_map) const;
     double getIntegratedPDF1d(double x, double step) const;
     double getIntegratedPDF2d(double x, double step_x, double y, double step_y) const;
 
@@ -64,7 +64,7 @@ private:
     std::unique_ptr<IResolutionFunction2D> mp_res_function_2d;
 };
 
-inline const IResolutionFunction2D *ConvolutionDetectorResolution::getResolutionFunction2D() const
+inline const IResolutionFunction2D* ConvolutionDetectorResolution::getResolutionFunction2D() const
 {
     return mp_res_function_2d.get();
 }
diff --git a/Core/Instrument/Convolve.cpp b/Core/Instrument/Convolve.cpp
index ef423c17442..5b2aa40502a 100644
--- a/Core/Instrument/Convolve.cpp
+++ b/Core/Instrument/Convolve.cpp
@@ -21,17 +21,16 @@
 Convolve::Convolve() : m_mode(FFTW_UNDEFINED)
 {
     // storing favorite fftw3 prime factors
-    const size_t FFTW_FACTORS[] = {13,11,7,5,3,2};
-    m_implemented_factors.assign(
-        FFTW_FACTORS, FFTW_FACTORS + sizeof(FFTW_FACTORS)/sizeof(FFTW_FACTORS[0]));
+    const size_t FFTW_FACTORS[] = {13, 11, 7, 5, 3, 2};
+    m_implemented_factors.assign(FFTW_FACTORS,
+                                 FFTW_FACTORS + sizeof(FFTW_FACTORS) / sizeof(FFTW_FACTORS[0]));
 }
 
-Convolve::Workspace::Workspace() :
-    h_src(0), w_src(0), h_kernel(0), w_kernel(0), w_fftw(0), h_fftw(0),
-    in_src(0), out_src(0), in_kernel(0), out_kernel(0), dst_fft(0), h_dst(0), w_dst(0),
-    //dst(0),
-    h_offset(0), w_offset(0),
-    p_forw_src(nullptr), p_forw_kernel(nullptr), p_back(nullptr)
+Convolve::Workspace::Workspace()
+    : h_src(0), w_src(0), h_kernel(0), w_kernel(0), w_fftw(0), h_fftw(0), in_src(0), out_src(0),
+      in_kernel(0), out_kernel(0), dst_fft(0), h_dst(0), w_dst(0),
+      // dst(0),
+      h_offset(0), w_offset(0), p_forw_src(nullptr), p_forw_kernel(nullptr), p_back(nullptr)
 {
 }
 
@@ -42,47 +41,53 @@ Convolve::Workspace::~Workspace()
 
 void Convolve::Workspace::clear()
 {
-    h_src=0;
-    w_src=0;
-    h_kernel=0;
+    h_src = 0;
+    w_src = 0;
+    h_kernel = 0;
     w_kernel = 0;
-    if(in_src) delete[] in_src;
+    if (in_src)
+        delete[] in_src;
     in_src = 0;
 
-    if(out_src) fftw_free((fftw_complex*)out_src);
+    if (out_src)
+        fftw_free((fftw_complex*)out_src);
     out_src = 0;
 
-    if(in_kernel) delete[] in_kernel;
-    in_kernel=0;
+    if (in_kernel)
+        delete[] in_kernel;
+    in_kernel = 0;
 
-    if(out_kernel) fftw_free((fftw_complex*)out_kernel);
-    out_kernel=0;
+    if (out_kernel)
+        fftw_free((fftw_complex*)out_kernel);
+    out_kernel = 0;
 
-    if(dst_fft) delete[] dst_fft;
-    dst_fft=0;
+    if (dst_fft)
+        delete[] dst_fft;
+    dst_fft = 0;
 
-    //if(dst) delete[] dst;
-    //dst=0;
+    // if(dst) delete[] dst;
+    // dst=0;
 
     h_offset = 0;
     w_offset = 0;
 
-    if(p_forw_src != nullptr) fftw_destroy_plan(p_forw_src);
-    if(p_forw_kernel != nullptr) fftw_destroy_plan(p_forw_kernel);
-    if(p_back != nullptr)  fftw_destroy_plan(p_back);
+    if (p_forw_src != nullptr)
+        fftw_destroy_plan(p_forw_src);
+    if (p_forw_kernel != nullptr)
+        fftw_destroy_plan(p_forw_kernel);
+    if (p_back != nullptr)
+        fftw_destroy_plan(p_back);
 
     fftw_cleanup();
 }
 
-
 /* ************************************************************************* */
 // convolution in 2d
 /* ************************************************************************* */
-void Convolve::fftconvolve(
-    const double2d_t& source, const double2d_t& kernel, double2d_t& result)
+void Convolve::fftconvolve(const double2d_t& source, const double2d_t& kernel, double2d_t& result)
 {
     // set default convolution mode, if not defined
-    if(m_mode == FFTW_UNDEFINED)
+    if (m_mode == FFTW_UNDEFINED)
         setMode(FFTW_LINEAR_SAME);
 
     int h_src = (int)source.size();
@@ -98,28 +103,24 @@ void Convolve::fftconvolve(
     // results
     result.clear();
     result.resize(ws.h_dst);
-    for(int i=0; i<ws.h_dst; i++) {
-        result[i].resize(ws.w_dst,0);
-        for(int j=0; j<ws.w_dst; j++) {
-            //result[i][j]=ws.dst[i*ws.w_dst+j];
-            if(m_mode == FFTW_CIRCULAR_SAME_SHIFTED) {
-                result[i][j] = ws.dst_fft[
-                    ((i+int(ws.h_kernel/2.0))%ws.h_fftw)*ws.w_fftw+
-                    (j+int(ws.w_kernel/2.0))%ws.w_fftw];
+    for (int i = 0; i < ws.h_dst; i++) {
+        result[i].resize(ws.w_dst, 0);
+        for (int j = 0; j < ws.w_dst; j++) {
+            // result[i][j]=ws.dst[i*ws.w_dst+j];
+            if (m_mode == FFTW_CIRCULAR_SAME_SHIFTED) {
+                result[i][j] = ws.dst_fft[((i + int(ws.h_kernel / 2.0)) % ws.h_fftw) * ws.w_fftw
+                                          + (j + int(ws.w_kernel / 2.0)) % ws.w_fftw];
             } else {
-                result[i][j] = ws.dst_fft[(i+ws.h_offset)*ws.w_fftw+j+ws.w_offset];
+                result[i][j] = ws.dst_fft[(i + ws.h_offset) * ws.w_fftw + j + ws.w_offset];
             }
         }
     }
-
 }
 
-
 /* ************************************************************************* */
 // convolution in 1d
 /* ************************************************************************* */
-void Convolve::fftconvolve(
-    const double1d_t& source, const double1d_t& kernel, double1d_t& result)
+void Convolve::fftconvolve(const double1d_t& source, const double1d_t& kernel, double1d_t& result)
 {
     // we simply create 2d arrays with length of first dimension equal to 1, and call 2d convolution
     double2d_t source2d, kernel2d;
@@ -128,22 +129,20 @@ void Convolve::fftconvolve(
 
     double2d_t result2d;
     fftconvolve(source2d, kernel2d, result2d);
-    if(result2d.size() != 1)
-        throw Exceptions::RuntimeErrorException(
-            "Convolve::fftconvolve -> Panic in 1d");
+    if (result2d.size() != 1)
+        throw Exceptions::RuntimeErrorException("Convolve::fftconvolve -> Panic in 1d");
     result = result2d[0];
 }
 
-
 /* ************************************************************************* */
 // initialise input and output arrays for fast Fourier transformation
 /* ************************************************************************* */
 void Convolve::init(int h_src, int w_src, int h_kernel, int w_kernel)
 {
-    if(!h_src || !w_src || !h_kernel || !w_kernel) {
+    if (!h_src || !w_src || !h_kernel || !w_kernel) {
         std::ostringstream os;
-        os << "Convolve::init() -> Panic! Wrong dimensions " <<
-            h_src << " " << w_src << " " << h_kernel << " " << w_kernel << std::endl;
+        os << "Convolve::init() -> Panic! Wrong dimensions " << h_src << " " << w_src << " "
+           << h_kernel << " " << w_kernel << std::endl;
         throw Exceptions::RuntimeErrorException(os.str());
     }
 
@@ -152,44 +151,42 @@ void Convolve::init(int h_src, int w_src, int h_kernel, int w_kernel)
     ws.w_src = w_src;
     ws.h_kernel = h_kernel;
     ws.w_kernel = w_kernel;
-    switch(m_mode)
-    {
+    switch (m_mode) {
     case FFTW_LINEAR_FULL:
         // Full Linear convolution
         ws.h_fftw = find_closest_factor(h_src + h_kernel - 1);
         ws.w_fftw = find_closest_factor(w_src + w_kernel - 1);
-        ws.h_dst = h_src + h_kernel-1;
-        ws.w_dst = w_src + w_kernel-1;
+        ws.h_dst = h_src + h_kernel - 1;
+        ws.w_dst = w_src + w_kernel - 1;
         // Here we just keep the first [0:h_dst-1 ; 0:w_dst-1] real part elements of out_src
         ws.h_offset = 0;
         ws.w_offset = 0;
         break;
     case FFTW_LINEAR_SAME_UNPADDED:
         // Same Linear convolution
-        ws.h_fftw = h_src + int(h_kernel/2.0);
-        ws.w_fftw = w_src + int(w_kernel/2.0);
+        ws.h_fftw = h_src + int(h_kernel / 2.0);
+        ws.w_fftw = w_src + int(w_kernel / 2.0);
         ws.h_dst = h_src;
         ws.w_dst = w_src;
         // Here we just keep the first [h_filt/2:h_filt/2+h_dst-1 ; w_filt/2:w_filt/2+w_dst-1]
         // real part elements of out_src
-        ws.h_offset = int(ws.h_kernel/2.0);
-        ws.w_offset = int(ws.w_kernel/2.0);
+        ws.h_offset = int(ws.h_kernel / 2.0);
+        ws.w_offset = int(ws.w_kernel / 2.0);
         break;
     case FFTW_LINEAR_SAME:
         // Same Linear convolution
-        ws.h_fftw = find_closest_factor(h_src + int(h_kernel/2.0));
-        ws.w_fftw = find_closest_factor(w_src + int(w_kernel/2.0));
+        ws.h_fftw = find_closest_factor(h_src + int(h_kernel / 2.0));
+        ws.w_fftw = find_closest_factor(w_src + int(w_kernel / 2.0));
         ws.h_dst = h_src;
         ws.w_dst = w_src;
         // Here we just keep the first [h_filt/2:h_filt/2+h_dst-1 ; w_filt/2:w_filt/2+w_dst-1]
         // real part elements of out_src
-        ws.h_offset = int(ws.h_kernel/2.0);
-        ws.w_offset = int(ws.w_kernel/2.0);
+        ws.h_offset = int(ws.h_kernel / 2.0);
+        ws.w_offset = int(ws.w_kernel / 2.0);
         break;
     case FFTW_LINEAR_VALID:
         // Valid Linear convolution
-        if(ws.h_kernel > ws.h_src || ws.w_kernel > ws.w_src)
-        {
+        if (ws.h_kernel > ws.h_src || ws.w_kernel > ws.w_src) {
             ws.h_fftw = 0;
             ws.w_fftw = 0;
             ws.h_dst = 0;
@@ -199,8 +196,8 @@ void Convolve::init(int h_src, int w_src, int h_kernel, int w_kernel)
         } else {
             ws.h_fftw = find_closest_factor(h_src);
             ws.w_fftw = find_closest_factor(w_src);
-            ws.h_dst = h_src - h_kernel+1;
-            ws.w_dst = w_src - w_kernel+1;
+            ws.h_dst = h_src - h_kernel + 1;
+            ws.w_dst = w_src - w_kernel + 1;
         }
         // Here we just take [h_dst x w_dst] elements starting at [h_kernel-1;w_kernel-1]
         ws.h_offset = ws.h_kernel - 1;
@@ -234,71 +231,70 @@ void Convolve::init(int h_src, int w_src, int h_kernel, int w_kernel)
         ws.w_offset = 0;
         break;
     default:
-        std::cout << "Unrecognized convolution mode, possible modes are " <<
-            "FFTW_LINEAR_FULL, FFTW_LINEAR_SAME, FFTW_LINEAR_SAME_UNPADDED, FFTW_LINEAR_VALID, " <<
-            "FFTW_CIRCULAR_SAME, FFTW_CIRCULAR_SHIFTED " << std::endl;
+        std::cout
+            << "Unrecognized convolution mode, possible modes are "
+            << "FFTW_LINEAR_FULL, FFTW_LINEAR_SAME, FFTW_LINEAR_SAME_UNPADDED, FFTW_LINEAR_VALID, "
+            << "FFTW_CIRCULAR_SAME, FFTW_CIRCULAR_SHIFTED " << std::endl;
         break;
     }
 
     ws.in_src = new double[ws.h_fftw * ws.w_fftw];
-    ws.out_src = (double*) fftw_malloc(sizeof(fftw_complex) * ws.h_fftw * (ws.w_fftw/2+1));
+    ws.out_src = (double*)fftw_malloc(sizeof(fftw_complex) * ws.h_fftw * (ws.w_fftw / 2 + 1));
     ws.in_kernel = new double[ws.h_fftw * ws.w_fftw];
-    ws.out_kernel = (double*) fftw_malloc(sizeof(fftw_complex) * ws.h_fftw * (ws.w_fftw/2+1));
+    ws.out_kernel = (double*)fftw_malloc(sizeof(fftw_complex) * ws.h_fftw * (ws.w_fftw / 2 + 1));
 
     ws.dst_fft = new double[ws.h_fftw * ws.w_fftw];
-    //ws.dst = new double[ws.h_dst * ws.w_dst];
+    // ws.dst = new double[ws.h_dst * ws.w_dst];
 
     // Initialization of the plans
-    ws.p_forw_src = fftw_plan_dft_r2c_2d(ws.h_fftw, ws.w_fftw, ws.in_src,
-                                         (fftw_complex*)ws.out_src, FFTW_ESTIMATE);
-    if( ws.p_forw_src == nullptr )
+    ws.p_forw_src = fftw_plan_dft_r2c_2d(ws.h_fftw, ws.w_fftw, ws.in_src, (fftw_complex*)ws.out_src,
+                                         FFTW_ESTIMATE);
+    if (ws.p_forw_src == nullptr)
         throw Exceptions::RuntimeErrorException(
             "Convolve::init() -> Error! Can't initialise p_forw_src plan.");
 
     ws.p_forw_kernel = fftw_plan_dft_r2c_2d(ws.h_fftw, ws.w_fftw, ws.in_kernel,
                                             (fftw_complex*)ws.out_kernel, FFTW_ESTIMATE);
-    if( ws.p_forw_kernel == nullptr )
+    if (ws.p_forw_kernel == nullptr)
         throw Exceptions::RuntimeErrorException(
             "Convolve::init() -> Error! Can't initialise p_forw_kernel plan.");
 
     // The backward FFT takes ws.out_kernel as input
-    ws.p_back = fftw_plan_dft_c2r_2d(
-        ws.h_fftw, ws.w_fftw, (fftw_complex*)ws.out_kernel, ws.dst_fft, FFTW_ESTIMATE);
-    if( ws.p_back == nullptr )
+    ws.p_back = fftw_plan_dft_c2r_2d(ws.h_fftw, ws.w_fftw, (fftw_complex*)ws.out_kernel, ws.dst_fft,
+                                     FFTW_ESTIMATE);
+    if (ws.p_back == nullptr)
         throw Exceptions::RuntimeErrorException(
             "Convolve::init() -> Error! Can't initialise p_back plan.");
 }
 
-
 /* ************************************************************************* */
 // initialise input and output arrays for fast Fourier transformation
 /* ************************************************************************* */
 
-void Convolve::fftw_circular_convolution(
-    const double2d_t& src, const double2d_t& kernel)
+void Convolve::fftw_circular_convolution(const double2d_t& src, const double2d_t& kernel)
 {
-    if(ws.h_fftw <= 0 || ws.w_fftw <= 0)
+    if (ws.h_fftw <= 0 || ws.w_fftw <= 0)
         throw Exceptions::RuntimeErrorException(
             "Convolve::fftw_convolve() -> Panic! Initialisation is missed.");
 
-    double * ptr, *ptr_end, *ptr2;
+    double *ptr, *ptr_end, *ptr2;
 
     // Reset the content of ws.in_src
-    for(ptr = ws.in_src, ptr_end = ws.in_src + ws.h_fftw*ws.w_fftw ; ptr != ptr_end ; ++ptr)
+    for (ptr = ws.in_src, ptr_end = ws.in_src + ws.h_fftw * ws.w_fftw; ptr != ptr_end; ++ptr)
         *ptr = 0.0;
-    for(ptr = ws.in_kernel, ptr_end = ws.in_kernel + ws.h_fftw*ws.w_fftw ; ptr != ptr_end ; ++ptr)
+    for (ptr = ws.in_kernel, ptr_end = ws.in_kernel + ws.h_fftw * ws.w_fftw; ptr != ptr_end; ++ptr)
         *ptr = 0.0;
 
     // Then we build our periodic signals
-    //ptr = src;
-    for(int i = 0 ; i < ws.h_src ; ++i)
-        for(int j = 0 ; j < ws.w_src ; ++j, ++ptr)
-            ws.in_src[(i%ws.h_fftw)*ws.w_fftw+(j%ws.w_fftw)] += src[i][j];
+    // ptr = src;
+    for (int i = 0; i < ws.h_src; ++i)
+        for (int j = 0; j < ws.w_src; ++j, ++ptr)
+            ws.in_src[(i % ws.h_fftw) * ws.w_fftw + (j % ws.w_fftw)] += src[i][j];
 
-    //ptr = kernel;
-    for(int i = 0 ; i < ws.h_kernel ; ++i)
-        for(int j = 0 ; j < ws.w_kernel ; ++j, ++ptr)
-            ws.in_kernel[(i%ws.h_fftw)*ws.w_fftw+(j%ws.w_fftw)] += kernel[i][j];
+    // ptr = kernel;
+    for (int i = 0; i < ws.h_kernel; ++i)
+        for (int j = 0; j < ws.w_kernel; ++j, ++ptr)
+            ws.in_kernel[(i % ws.h_fftw) * ws.w_fftw + (j % ws.w_fftw)] += kernel[i][j];
 
     // And we compute their packed FFT
     fftw_execute(ws.p_forw_src);
@@ -307,15 +303,14 @@ void Convolve::fftw_circular_convolution(
     // Compute the element-wise product on the packed terms
     // Let's put the element wise products in ws.in_kernel
     double re_s, im_s, re_k, im_k;
-    for(ptr = ws.out_src,
-            ptr2 = ws.out_kernel,
-            ptr_end = ws.out_src+2*ws.h_fftw * (ws.w_fftw/2+1); ptr != ptr_end ; ++ptr, ++ptr2)
-    {
+    for (ptr = ws.out_src, ptr2 = ws.out_kernel,
+        ptr_end = ws.out_src + 2 * ws.h_fftw * (ws.w_fftw / 2 + 1);
+         ptr != ptr_end; ++ptr, ++ptr2) {
         re_s = *ptr;
         im_s = *(++ptr);
         re_k = *ptr2;
         im_k = *(++ptr2);
-        *(ptr2-1) = re_s * re_k - im_s * im_k;
+        *(ptr2 - 1) = re_s * re_k - im_s * im_k;
         *ptr2 = re_s * im_k + im_s * re_k;
     }
 
@@ -323,12 +318,10 @@ void Convolve::fftw_circular_convolution(
     // Carefull, The backward FFT does not preserve the output
     fftw_execute(ws.p_back);
     // Scale the transform
-    for(ptr = ws.dst_fft, ptr_end = ws.dst_fft + ws.w_fftw*ws.h_fftw ; ptr != ptr_end ; ++ptr)
-        *ptr /= double(ws.h_fftw*ws.w_fftw);
-
+    for (ptr = ws.dst_fft, ptr_end = ws.dst_fft + ws.w_fftw * ws.h_fftw; ptr != ptr_end; ++ptr)
+        *ptr /= double(ws.h_fftw * ws.w_fftw);
 }
 
-
 /* ************************************************************************* */
 // find a number closest to the given one, which  can be factorised according
 // to fftw3 favorite factorisation
@@ -336,28 +329,28 @@ void Convolve::fftw_circular_convolution(
 
 int Convolve::find_closest_factor(int n)
 {
-    if(is_optimal(n) ) {
+    if (is_optimal(n)) {
         return n;
     } else {
-        int j = n+1;
-        while( !is_optimal(j) ) ++j;
+        int j = n + 1;
+        while (!is_optimal(j))
+            ++j;
         return j;
     }
 }
 
-
 /* ************************************************************************* */
 // if a number can be factorised using only favorite fftw3 factors
 /* ************************************************************************* */
 bool Convolve::is_optimal(int n)
 {
-    if(n==1)
+    if (n == 1)
         return false;
     size_t ntest = n;
-    for(size_t i=0; i<m_implemented_factors.size(); i++){
-        while( (ntest%m_implemented_factors[i]) == 0 ) {
-            ntest = ntest/m_implemented_factors[i];
+    for (size_t i = 0; i < m_implemented_factors.size(); i++) {
+        while ((ntest % m_implemented_factors[i]) == 0) {
+            ntest = ntest / m_implemented_factors[i];
         }
     }
-    return ntest==1;
+    return ntest == 1;
 }
diff --git a/Core/Instrument/Convolve.h b/Core/Instrument/Convolve.h
index 944e4c7e846..5c5a7320c57 100644
--- a/Core/Instrument/Convolve.h
+++ b/Core/Instrument/Convolve.h
@@ -35,19 +35,24 @@ class BA_CORE_API_ Convolve
 {
 public:
     //! definition of 1d vector of double
-    typedef std::vector<double > double1d_t;
+    typedef std::vector<double> double1d_t;
 
     //! definition of 2d vector of double
-    typedef std::vector<double1d_t > double2d_t;
+    typedef std::vector<double1d_t> double2d_t;
 
     Convolve();
 
     //! convolution  modes
     //! use LINEAR_SAME or CIRCULAR_SAME_SHIFTED for maximum performance
-    enum EConvolutionMode { FFTW_LINEAR_FULL, FFTW_LINEAR_SAME_UNPADDED,
-                            FFTW_LINEAR_SAME, FFTW_LINEAR_VALID,
-                            FFTW_CIRCULAR_SAME, FFTW_CIRCULAR_SAME_SHIFTED,
-                            FFTW_UNDEFINED };
+    enum EConvolutionMode {
+        FFTW_LINEAR_FULL,
+        FFTW_LINEAR_SAME_UNPADDED,
+        FFTW_LINEAR_SAME,
+        FFTW_LINEAR_VALID,
+        FFTW_CIRCULAR_SAME,
+        FFTW_CIRCULAR_SAME_SHIFTED,
+        FFTW_UNDEFINED
+    };
 
     //! convolution in 1D
     void fftconvolve(const double1d_t& source, const double1d_t& kernel, double1d_t& result);
@@ -85,23 +90,24 @@ private:
         ~Workspace();
         void clear();
         friend class Convolve;
+
     private:
-        int h_src, w_src;                 // size of original 'source' array in 2 dimensions
-        int h_kernel, w_kernel;           // size of original 'kernel' array in 2 dimensions
+        int h_src, w_src;       // size of original 'source' array in 2 dimensions
+        int h_kernel, w_kernel; // size of original 'kernel' array in 2 dimensions
         // size of adjusted source and kernel arrays (in_src, out_src, in_kernel, out_kernel)
         int w_fftw, h_fftw;
         //! adjusted input 'source' array
-        double *in_src;
+        double* in_src;
         //! result of Fourier transformation of source
-        double *out_src;
+        double* out_src;
         //! adjusted input 'kernel' array
-        double *in_kernel;
+        double* in_kernel;
         //! result of Fourier transformation of kernel
-        double *out_kernel;
+        double* out_kernel;
         //! result of product of FFT(source) and FFT(kernel)
-        double *dst_fft;
-        int h_dst, w_dst;                 // size of resulting array
-        int h_offset, w_offset;           // offsets to copy result into output arrays
+        double* dst_fft;
+        int h_dst, w_dst;       // size of resulting array
+        int h_offset, w_offset; // offsets to copy result into output arrays
         fftw_plan p_forw_src;
         fftw_plan p_forw_kernel;
         fftw_plan p_back;
@@ -111,7 +117,7 @@ private:
     Workspace ws;
     //! convolution mode
     EConvolutionMode m_mode;
-    std::vector<size_t > m_implemented_factors; // favorite factorization terms of fftw3
+    std::vector<size_t> m_implemented_factors; // favorite factorization terms of fftw3
 };
 
 #endif // CONVOLVE_H
diff --git a/Core/Instrument/CumulativeValue.cpp b/Core/Instrument/CumulativeValue.cpp
index 74bfcc9f241..b2dd4ba8655 100644
--- a/Core/Instrument/CumulativeValue.cpp
+++ b/Core/Instrument/CumulativeValue.cpp
@@ -24,9 +24,11 @@ void CumulativeValue::add(double value, double weight)
 {
     m_n_entries++;
     m_sum += value;
-    m_rms2 = (m_sum_of_weights/(m_sum_of_weights+weight))*
-            (m_rms2+(weight/(m_sum_of_weights+weight))*(value-m_average)*(value-m_average));
-    m_average = m_average+(value-m_average)*weight/(m_sum_of_weights+weight);
+    m_rms2 =
+        (m_sum_of_weights / (m_sum_of_weights + weight))
+        * (m_rms2
+           + (weight / (m_sum_of_weights + weight)) * (value - m_average) * (value - m_average));
+    m_average = m_average + (value - m_average) * weight / (m_sum_of_weights + weight);
     m_sum_of_weights += weight;
 }
 
@@ -41,10 +43,10 @@ void CumulativeValue::clear()
 
 bool operator<(const CumulativeValue& lhs, const CumulativeValue& rhs)
 {
-    return lhs.getContent()< rhs.getContent();
+    return lhs.getContent() < rhs.getContent();
 }
 
 bool operator>(const CumulativeValue& lhs, const CumulativeValue& rhs)
 {
-    return rhs<lhs;
+    return rhs < lhs;
 }
diff --git a/Core/Instrument/CumulativeValue.h b/Core/Instrument/CumulativeValue.h
index e0208fa8321..6d9edb0622c 100644
--- a/Core/Instrument/CumulativeValue.h
+++ b/Core/Instrument/CumulativeValue.h
@@ -27,7 +27,7 @@ public:
 
     void clear();
     void setContent(double value) { m_sum = value; }
-    void add(double value, double weight=1.0);
+    void add(double value, double weight = 1.0);
 
     int getNumberOfEntries() const { return m_n_entries; }
     double getContent() const { return m_sum; }
@@ -38,11 +38,11 @@ private:
     int m_n_entries;
     double m_sum;
     double m_average;
-    double m_rms2; //sum[ (x-x_aver)^2]/nentries
+    double m_rms2; // sum[ (x-x_aver)^2]/nentries
     double m_sum_of_weights;
 };
 
-BA_CORE_API_ bool operator< (const CumulativeValue& lhs, const CumulativeValue& rhs);
-BA_CORE_API_ bool operator> (const CumulativeValue& lhs, const CumulativeValue& rhs);
+BA_CORE_API_ bool operator<(const CumulativeValue& lhs, const CumulativeValue& rhs);
+BA_CORE_API_ bool operator>(const CumulativeValue& lhs, const CumulativeValue& rhs);
 
 #endif // CUMULATIVEVALUE_H
diff --git a/Core/Instrument/DetectionProperties.cpp b/Core/Instrument/DetectionProperties.cpp
index 7442ef13851..6c3f1a44273 100644
--- a/Core/Instrument/DetectionProperties.cpp
+++ b/Core/Instrument/DetectionProperties.cpp
@@ -13,38 +13,35 @@
 // ************************************************************************** //
 
 #include "DetectionProperties.h"
-#include "Exceptions.h"
 #include "Complex.h"
+#include "Exceptions.h"
 #include "RealParameter.h"
 
 DetectionProperties::DetectionProperties()
-    : m_direction {}
-    , m_efficiency {}
-    , m_total_transmission { 1.0 }
+    : m_direction{}, m_efficiency{}, m_total_transmission{1.0}
 {
     setName(BornAgain::DetectorAnalyzer);
     init_parameters();
 }
 
 DetectionProperties::DetectionProperties(const DetectionProperties& other)
-    : m_direction { other.m_direction }
-    , m_efficiency { other.m_efficiency }
-    , m_total_transmission { other.m_total_transmission }
+    : m_direction{other.m_direction}, m_efficiency{other.m_efficiency},
+      m_total_transmission{other.m_total_transmission}
 {
     setName(other.getName());
     init_parameters();
 }
 
-DetectionProperties::~DetectionProperties() =default;
+DetectionProperties::~DetectionProperties() = default;
 
 void DetectionProperties::setAnalyzerProperties(const kvector_t direction, double efficiency,
-                                               double total_transmission)
+                                                double total_transmission)
 {
     if (!checkAnalyzerProperties(direction, efficiency, total_transmission))
         throw Exceptions::ClassInitializationException("IDetector2D::setAnalyzerProperties: the "
                                                        "given properties are not physical");
-    if (efficiency==0.0 || total_transmission==0.0 || direction.mag()==0.0) {
-        m_direction = kvector_t {};
+    if (efficiency == 0.0 || total_transmission == 0.0 || direction.mag() == 0.0) {
+        m_direction = kvector_t{};
         m_efficiency = 0.0;
     } else {
         m_direction = direction.unit();
@@ -55,19 +52,19 @@ void DetectionProperties::setAnalyzerProperties(const kvector_t direction, doubl
 
 Eigen::Matrix2cd DetectionProperties::analyzerOperator() const
 {
-    if (m_direction.mag()==0.0 || m_efficiency==0.0)
-        return m_total_transmission*Eigen::Matrix2cd::Identity();
+    if (m_direction.mag() == 0.0 || m_efficiency == 0.0)
+        return m_total_transmission * Eigen::Matrix2cd::Identity();
     Eigen::Matrix2cd result;
-    double x = m_direction.x()/m_direction.mag();
-    double y = m_direction.y()/m_direction.mag();
-    double z = m_direction.z()/m_direction.mag();
+    double x = m_direction.x() / m_direction.mag();
+    double y = m_direction.y() / m_direction.mag();
+    double z = m_direction.z() / m_direction.mag();
     double sum = m_total_transmission * 2.0;
     double diff = m_total_transmission * m_efficiency * 2.0;
     complex_t im(0.0, 1.0);
-    result(0, 0) = (sum + diff*z) / 2.0;
-    result(0, 1) = diff*(x - im * y) / 2.0;
-    result(1, 0) = diff*(x + im * y) / 2.0;
-    result(1, 1) = (sum - diff*z) / 2.0;
+    result(0, 0) = (sum + diff * z) / 2.0;
+    result(0, 1) = diff * (x - im * y) / 2.0;
+    result(1, 0) = diff * (x + im * y) / 2.0;
+    result(1, 1) = (sum - diff * z) / 2.0;
     return result;
 }
 
@@ -93,8 +90,8 @@ void DetectionProperties::init_parameters()
     registerParameter(BornAgain::Transmission, &m_total_transmission).setNonnegative();
 }
 
-bool DetectionProperties::checkAnalyzerProperties(
-    const kvector_t direction, double efficiency, double total_transmission) const
+bool DetectionProperties::checkAnalyzerProperties(const kvector_t direction, double efficiency,
+                                                  double total_transmission) const
 {
     if (direction.mag() == 0.0)
         return false;
diff --git a/Core/Instrument/DetectionProperties.h b/Core/Instrument/DetectionProperties.h
index bd1597008d7..48639925caa 100644
--- a/Core/Instrument/DetectionProperties.h
+++ b/Core/Instrument/DetectionProperties.h
@@ -15,15 +15,16 @@
 #ifndef DETECTIONPROPERTIES_H
 #define DETECTIONPROPERTIES_H
 
-#include "WinDllMacros.h"
 #include "EigenCore.h"
 #include "INode.h"
 #include "Vectors3D.h"
+#include "WinDllMacros.h"
 
 //! Detector properties (efficiency, transmission).
 //! @ingroup simulation
 
-class BA_CORE_API_ DetectionProperties : public INode {
+class BA_CORE_API_ DetectionProperties : public INode
+{
 public:
     DetectionProperties();
     DetectionProperties(const DetectionProperties& other);
@@ -50,9 +51,9 @@ private:
     bool checkAnalyzerProperties(const kvector_t direction, double efficiency,
                                  double total_transmission) const;
 
-    kvector_t m_direction;  //!< direction of polarization analysis
-    double m_efficiency;  //!< efficiency of polarization analysis
-    double m_total_transmission;  //!< total transmission of polarization analysis
+    kvector_t m_direction;       //!< direction of polarization analysis
+    double m_efficiency;         //!< efficiency of polarization analysis
+    double m_total_transmission; //!< total transmission of polarization analysis
 };
 
 #endif // DETECTIONPROPERTIES_H
diff --git a/Core/Instrument/DetectorContext.cpp b/Core/Instrument/DetectorContext.cpp
index f9fc7ce3732..b9a1894d1d2 100644
--- a/Core/Instrument/DetectorContext.cpp
+++ b/Core/Instrument/DetectorContext.cpp
@@ -15,7 +15,7 @@
 #include "DetectorContext.h"
 #include "IDetector2D.h"
 
-DetectorContext::DetectorContext(const IDetector2D *detector)
+DetectorContext::DetectorContext(const IDetector2D* detector)
 {
     setup_context(detector);
 }
@@ -39,7 +39,7 @@ size_t DetectorContext::detectorIndex(size_t element_index) const
     return active_indices[element_index];
 }
 
-void DetectorContext::setup_context(const IDetector2D *detector)
+void DetectorContext::setup_context(const IDetector2D* detector)
 {
     active_indices = detector->active_indices();
     analyzer_operator = detector->detectionProperties().analyzerOperator();
diff --git a/Core/Instrument/DetectorFunctions.cpp b/Core/Instrument/DetectorFunctions.cpp
index ad1ac3835ab..ec1681cfd2e 100644
--- a/Core/Instrument/DetectorFunctions.cpp
+++ b/Core/Instrument/DetectorFunctions.cpp
@@ -13,15 +13,15 @@
 // ************************************************************************** //
 
 #include "DetectorFunctions.h"
-#include "OutputData.h"
 #include "Instrument.h"
+#include "OutputData.h"
 #include "SimulationArea.h"
 #include "SimulationAreaIterator.h"
 #include "StringUtils.h"
-#include <sstream>
 #include <algorithm>
-#include <map>
 #include <cctype>
+#include <map>
+#include <sstream>
 
 bool DetectorFunctions::hasSameDimensions(const IDetector& detector, const OutputData<double>& data)
 {
@@ -29,7 +29,7 @@ bool DetectorFunctions::hasSameDimensions(const IDetector& detector, const Outpu
         return false;
 
     for (size_t i = 0; i < detector.dimension(); ++i)
-        if(data.getAxis(i).size() != detector.getAxis(i).size())
+        if (data.getAxis(i).size() != detector.getAxis(i).size())
             return false;
 
     return true;
@@ -42,7 +42,7 @@ std::string DetectorFunctions::axesToString(const IDetector& detector)
     result << "(";
     for (size_t i = 0; i < detector.dimension(); ++i) {
         result << detector.getAxis(i).size();
-        if(i!=detector.dimension()-1)
+        if (i != detector.dimension() - 1)
             result << ",";
     }
     result << ")";
@@ -50,14 +50,14 @@ std::string DetectorFunctions::axesToString(const IDetector& detector)
     return result.str();
 }
 
-std::string DetectorFunctions::axesToString(const OutputData<double> &data)
+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)
+        if (i != data.getRank() - 1)
             result << ",";
     }
     result << ")";
diff --git a/Core/Instrument/DetectorFunctions.h b/Core/Instrument/DetectorFunctions.h
index a306eccbafc..e3fc15556a5 100644
--- a/Core/Instrument/DetectorFunctions.h
+++ b/Core/Instrument/DetectorFunctions.h
@@ -15,21 +15,21 @@
 #ifndef DETECTORFUNCTIONS_H
 #define DETECTORFUNCTIONS_H
 
-#include "WinDllMacros.h"
 #include "IDetector.h"
-#include <string>
-#include <memory>
+#include "WinDllMacros.h"
 #include <functional>
-template<class T> class OutputData;
+#include <memory>
+#include <string>
+template <class T> class OutputData;
 class Instrument;
 class IDetector;
 class SimulationAreaIterator;
 
-
 //! Contains set of detector-related convenience functions.
 //! @ingroup simulation
 
-namespace DetectorFunctions {
+namespace DetectorFunctions
+{
 
 //! Returns true if the data has same axes size (nx,ny) with the detector.
 BA_CORE_API_ bool hasSameDimensions(const IDetector& detector, const OutputData<double>& data);
@@ -43,7 +43,6 @@ BA_CORE_API_ std::string axesToString(const IDetector& detector);
 //! Returns string representation of axes dimension in the form "(nx,ny)"
 BA_CORE_API_ std::string axesToString(const OutputData<double>& data);
 
-}
+} // namespace DetectorFunctions
 
 #endif // DETECTORFUNCTIONS_H
-
diff --git a/Core/Instrument/DetectorMask.cpp b/Core/Instrument/DetectorMask.cpp
index 309e5e1a604..90e8e4f115d 100644
--- a/Core/Instrument/DetectorMask.cpp
+++ b/Core/Instrument/DetectorMask.cpp
@@ -13,19 +13,15 @@
 // ************************************************************************** //
 
 #include "BornAgainNamespace.h"
-#include "IDetector2D.h"
 #include "Histogram2D.h"
+#include "IDetector2D.h"
 #include "RegionOfInterest.h"
 
-DetectorMask::DetectorMask()
-    : m_number_of_masked_channels(0)
-{
-}
+DetectorMask::DetectorMask() : m_number_of_masked_channels(0) {}
 
 DetectorMask::DetectorMask(const DetectorMask& other)
-    : m_shapes(other.m_shapes)
-    , m_mask_of_shape(other.m_mask_of_shape)
-    , m_number_of_masked_channels(other.m_number_of_masked_channels)
+    : m_shapes(other.m_shapes), m_mask_of_shape(other.m_mask_of_shape),
+      m_number_of_masked_channels(other.m_number_of_masked_channels)
 {
     m_mask_data.copyFrom(other.m_mask_data);
 }
@@ -37,8 +33,8 @@ DetectorMask& DetectorMask::operator=(const DetectorMask& other)
         m_mask_of_shape = other.m_mask_of_shape;
         m_mask_data.copyFrom(other.m_mask_data);
         m_number_of_masked_channels = other.m_number_of_masked_channels;
-//        DetectorMask tmp(other);
-//        tmp.swapContent(*this);
+        //        DetectorMask tmp(other);
+        //        tmp.swapContent(*this);
     }
     return *this;
 }
@@ -53,15 +49,15 @@ void DetectorMask::addMask(const IShape2D& shape, bool mask_value)
 
 void DetectorMask::initMaskData(const IDetector2D& detector)
 {
-    if(detector.dimension() != 2)
+    if (detector.dimension() != 2)
         throw Exceptions::RuntimeErrorException("DetectorMask::initMaskData() -> Error. Attempt "
                                                 "to add masks to uninitialized detector.");
 
     assert(m_shapes.size() == m_mask_of_shape.size());
     m_mask_data.clear();
 
-    for (size_t dim=0; dim<detector.dimension(); ++dim) {
-        const IAxis &axis = detector.getAxis(dim);
+    for (size_t dim = 0; dim < detector.dimension(); ++dim) {
+        const IAxis& axis = detector.getAxis(dim);
         m_mask_data.addAxis(axis);
     }
 
@@ -73,7 +69,7 @@ void DetectorMask::initMaskData(const OutputData<double>& data)
     assert(m_shapes.size() == m_mask_of_shape.size());
     m_mask_data.clear();
 
-    for (size_t dim=0; dim<data.getRank(); ++dim)
+    for (size_t dim = 0; dim < data.getRank(); ++dim)
         m_mask_data.addAxis(data.getAxis(dim));
 
     process_masks();
@@ -88,7 +84,7 @@ Histogram2D* DetectorMask::createHistogram() const
 {
     OutputData<double> data;
     data.copyShapeFrom(m_mask_data);
-    for(size_t i=0; i<m_mask_data.getAllocatedSize(); ++i)
+    for (size_t i = 0; i < m_mask_data.getAllocatedSize(); ++i)
         data[i] = static_cast<double>(m_mask_data[i]);
     return dynamic_cast<Histogram2D*>(IHistogram::createHistogram(data));
 }
@@ -107,7 +103,7 @@ size_t DetectorMask::numberOfMasks() const
 
 const IShape2D* DetectorMask::getMaskShape(size_t mask_index, bool& mask_value) const
 {
-    if(mask_index >= numberOfMasks())
+    if (mask_index >= numberOfMasks())
         return nullptr;
     mask_value = m_mask_of_shape[mask_index];
     return m_shapes[mask_index];
@@ -116,25 +112,25 @@ const IShape2D* DetectorMask::getMaskShape(size_t mask_index, bool& mask_value)
 void DetectorMask::process_masks()
 {
     m_mask_data.setAllTo(false);
-    if(!m_shapes.size())
+    if (!m_shapes.size())
         return;
 
     m_number_of_masked_channels = 0;
-    for(size_t index=0; index<m_mask_data.getAllocatedSize(); ++index) {
+    for (size_t index = 0; index < m_mask_data.getAllocatedSize(); ++index) {
         Bin1D binx = m_mask_data.getAxisBin(index, BornAgain::X_AXIS_INDEX);
         Bin1D biny = m_mask_data.getAxisBin(index, BornAgain::Y_AXIS_INDEX);
         // setting mask to the data starting from last shape added
         bool is_masked(false);
-        for(size_t i_shape=m_shapes.size(); i_shape>0; --i_shape) {
-            const IShape2D* shape = m_shapes[i_shape-1];
-            if(shape->contains(binx, biny)) {
-                if(m_mask_of_shape[i_shape-1])
+        for (size_t i_shape = m_shapes.size(); i_shape > 0; --i_shape) {
+            const IShape2D* shape = m_shapes[i_shape - 1];
+            if (shape->contains(binx, biny)) {
+                if (m_mask_of_shape[i_shape - 1])
                     is_masked = true;
-                m_mask_data[index] = m_mask_of_shape[i_shape-1];
+                m_mask_data[index] = m_mask_of_shape[i_shape - 1];
                 break; // index is covered by the shape, stop looking further
             }
         }
-        if(is_masked)
+        if (is_masked)
             ++m_number_of_masked_channels;
     }
 }
diff --git a/Core/Instrument/FourierTransform.cpp b/Core/Instrument/FourierTransform.cpp
index 8dab83ee533..f5fcb06d0f4 100644
--- a/Core/Instrument/FourierTransform.cpp
+++ b/Core/Instrument/FourierTransform.cpp
@@ -28,7 +28,10 @@ FourierTransform::Workspace::Workspace()
 {
 }
 
-FourierTransform::Workspace::~Workspace() { clear(); }
+FourierTransform::Workspace::~Workspace()
+{
+    clear();
+}
 
 void FourierTransform::Workspace::clear()
 {
@@ -202,8 +205,7 @@ void FourierTransform::fftw_forward_FT(const double2d_t& src)
     for (size_t row = 0; row < static_cast<size_t>(ws.h_src); ++row)
         for (size_t col = 0; col < static_cast<size_t>(ws.w_src); ++col)
             ws.in_src[(static_cast<int>(row) % ws.h_fftw) * ws.w_fftw
-                      + (static_cast<int>(col) % ws.w_fftw)]
-                += src[row][col];
+                      + (static_cast<int>(col) % ws.w_fftw)] += src[row][col];
 
     // Computing the FFT with fftw plan
     fftw_execute(ws.p_forw_src);
diff --git a/Core/Instrument/Histogram1D.cpp b/Core/Instrument/Histogram1D.cpp
index 2675abf03cd..c9dcc7a0365 100644
--- a/Core/Instrument/Histogram1D.cpp
+++ b/Core/Instrument/Histogram1D.cpp
@@ -27,9 +27,7 @@ Histogram1D::Histogram1D(int nbinsx, const std::vector<double>& xbins)
     m_data.addAxis(VariableBinAxis("x-axis", nbinsx, xbins));
 }
 
-Histogram1D::Histogram1D(const IAxis& axis)
-    : IHistogram(axis)
-{}
+Histogram1D::Histogram1D(const IAxis& axis) : IHistogram(axis) {}
 
 Histogram1D::Histogram1D(const OutputData<double>& data)
 {
@@ -44,7 +42,7 @@ Histogram1D* Histogram1D::clone() const
 int Histogram1D::fill(double x, double weight)
 {
     const IAxis& axis = getXaxis();
-    if(x < axis.getMin() || x>=axis.getMax())
+    if (x < axis.getMin() || x >= axis.getMax())
         return -1;
     size_t index = axis.findClosestIndex(x);
     m_data[index].add(weight);
@@ -87,14 +85,13 @@ PyObject* Histogram1D::getBinErrorsNumpy() const
 
 Histogram1D* Histogram1D::crop(double xmin, double xmax)
 {
-    const std::unique_ptr<IAxis > xaxis(getXaxis().createClippedAxis(xmin, xmax));
+    const std::unique_ptr<IAxis> xaxis(getXaxis().createClippedAxis(xmin, xmax));
     Histogram1D* result = new Histogram1D(*xaxis);
     OutputData<CumulativeValue>::const_iterator it_origin = m_data.begin();
     OutputData<CumulativeValue>::iterator it_result = result->m_data.begin();
-    while (it_origin != m_data.end())
-    {
+    while (it_origin != m_data.end()) {
         double x = m_data.getAxisValue(it_origin.getIndex(), 0);
-        if(result->getXaxis().contains(x)) {
+        if (result->getXaxis().contains(x)) {
             *it_result = *it_origin;
             ++it_result;
         }
diff --git a/Core/Instrument/Histogram1D.h b/Core/Instrument/Histogram1D.h
index e95ad6328ad..732f50d648f 100644
--- a/Core/Instrument/Histogram1D.h
+++ b/Core/Instrument/Histogram1D.h
@@ -45,7 +45,7 @@ public:
     Histogram1D* clone() const;
 
     //! Returns the number of histogram dimensions
-    size_t getRank() const { return 1;}
+    size_t getRank() const { return 1; }
 
     //! Increment bin with abscissa x with a weight.
     int fill(double x, double weight = 1.0);
@@ -67,8 +67,6 @@ public:
 
     //! Create new histogram by applying crop on axis.
     Histogram1D* crop(double xmin, double xmax);
-
 };
 
-
 #endif // HISTOGRAM1D_H
diff --git a/Core/Instrument/Histogram2D.cpp b/Core/Instrument/Histogram2D.cpp
index 6c87255332f..93216801f3d 100644
--- a/Core/Instrument/Histogram2D.cpp
+++ b/Core/Instrument/Histogram2D.cpp
@@ -13,10 +13,10 @@
 // ************************************************************************** //
 
 #include "Histogram2D.h"
+#include "ArrayUtils.h"
+#include "BornAgainNamespace.h"
 #include "Histogram1D.h"
 #include "VariableBinAxis.h"
-#include "BornAgainNamespace.h"
-#include "ArrayUtils.h"
 #include <memory>
 
 Histogram2D::Histogram2D(int nbinsx, double xlow, double xup, int nbinsy, double ylow, double yup)
@@ -25,16 +25,14 @@ Histogram2D::Histogram2D(int nbinsx, double xlow, double xup, int nbinsy, double
     m_data.addAxis(FixedBinAxis("y-axis", nbinsy, ylow, yup));
 }
 
-Histogram2D::Histogram2D(
-    int nbinsx, const std::vector<double>& xbins, int nbinsy, const std::vector<double>& ybins)
+Histogram2D::Histogram2D(int nbinsx, const std::vector<double>& xbins, int nbinsy,
+                         const std::vector<double>& ybins)
 {
     m_data.addAxis(VariableBinAxis("x-axis", nbinsx, xbins));
     m_data.addAxis(VariableBinAxis("y-axis", nbinsy, ybins));
 }
 
-Histogram2D::Histogram2D(const IAxis &axis_x, const IAxis &axis_y)
-    : IHistogram(axis_x, axis_y)
-{}
+Histogram2D::Histogram2D(const IAxis& axis_x, const IAxis& axis_y) : IHistogram(axis_x, axis_y) {}
 
 Histogram2D::Histogram2D(const OutputData<double>& data)
 {
@@ -42,7 +40,7 @@ Histogram2D::Histogram2D(const OutputData<double>& data)
 }
 
 // IMPORTANT intentionally passed by copy to avoid problems on Python side
-Histogram2D::Histogram2D(std::vector<std::vector<double> > data)
+Histogram2D::Histogram2D(std::vector<std::vector<double>> data)
 {
     initFromShape(data);
     this->setContent(data);
@@ -55,16 +53,18 @@ Histogram2D* Histogram2D::clone() const
 
 int Histogram2D::fill(double x, double y, double weight)
 {
-    if(x < getXaxis().getMin() || x >= getXaxis().getMax()) return -1;
-    if(y < getYaxis().getMin() || y >= getYaxis().getMax()) return -1;
-    size_t index = m_data.findGlobalIndex( {x,y} );
+    if (x < getXaxis().getMin() || x >= getXaxis().getMax())
+        return -1;
+    if (y < getYaxis().getMin() || y >= getYaxis().getMax())
+        return -1;
+    size_t index = m_data.findGlobalIndex({x, y});
     m_data[index].add(weight);
     return (int)index;
 }
 
 Histogram1D* Histogram2D::projectionX()
 {
-    return create_projectionX(0, static_cast<int>(getXaxis().size())-1);
+    return create_projectionX(0, static_cast<int>(getXaxis().size()) - 1);
 }
 
 Histogram1D* Histogram2D::projectionX(double yvalue)
@@ -82,7 +82,7 @@ Histogram1D* Histogram2D::projectionX(double ylow, double yup)
 
 Histogram1D* Histogram2D::projectionY()
 {
-    return create_projectionY(0, static_cast<int>(getXaxis().size())-1);
+    return create_projectionY(0, static_cast<int>(getXaxis().size()) - 1);
 }
 
 Histogram1D* Histogram2D::projectionY(double xvalue)
@@ -100,17 +100,16 @@ Histogram1D* Histogram2D::projectionY(double xlow, double xup)
 
 Histogram2D* Histogram2D::crop(double xmin, double ymin, double xmax, double ymax)
 {
-    const std::unique_ptr<IAxis > xaxis(getXaxis().createClippedAxis(xmin, xmax));
-    const std::unique_ptr<IAxis > yaxis(getYaxis().createClippedAxis(ymin, ymax));
+    const std::unique_ptr<IAxis> xaxis(getXaxis().createClippedAxis(xmin, xmax));
+    const std::unique_ptr<IAxis> yaxis(getYaxis().createClippedAxis(ymin, ymax));
 
     Histogram2D* result = new Histogram2D(*xaxis, *yaxis);
     OutputData<CumulativeValue>::const_iterator it_origin = m_data.begin();
     OutputData<CumulativeValue>::iterator it_result = result->m_data.begin();
-    while (it_origin != m_data.end())
-    {
+    while (it_origin != m_data.end()) {
         double x = m_data.getAxisValue(it_origin.getIndex(), 0);
         double y = m_data.getAxisValue(it_origin.getIndex(), 1);
-        if(result->getXaxis().contains(x) && result->getYaxis().contains(y)) {
+        if (result->getXaxis().contains(x) && result->getYaxis().contains(y)) {
             *it_result = *it_origin;
             ++it_result;
         }
@@ -119,31 +118,31 @@ Histogram2D* Histogram2D::crop(double xmin, double ymin, double xmax, double yma
     return result;
 }
 
-void Histogram2D::setContent(const std::vector<std::vector<double> > &data)
+void Histogram2D::setContent(const std::vector<std::vector<double>>& data)
 {
     reset();
     addContent(data);
 }
 
-void Histogram2D::addContent(const std::vector<std::vector<double> > &data)
+void Histogram2D::addContent(const std::vector<std::vector<double>>& data)
 {
     auto shape = ArrayUtils::getShape(data);
     const size_t nrows = shape.first;
     const size_t ncols = shape.second;
 
-    if(nrows != m_data.getAxis(BornAgain::Y_AXIS_INDEX).size()
-            || ncols != m_data.getAxis(BornAgain::X_AXIS_INDEX).size()) {
+    if (nrows != m_data.getAxis(BornAgain::Y_AXIS_INDEX).size()
+        || ncols != m_data.getAxis(BornAgain::X_AXIS_INDEX).size()) {
         std::ostringstream ostr;
-        ostr << "Histogram2D::addContent() -> Shape of input array [" << nrows
-             << ", " << ncols << "] doesn't mach histogram axes. "
+        ostr << "Histogram2D::addContent() -> Shape of input array [" << nrows << ", " << ncols
+             << "] doesn't mach histogram axes. "
              << "X-axis size: " << m_data.getAxis(BornAgain::X_AXIS_INDEX).size()
              << "Y-axis size: " << m_data.getAxis(BornAgain::Y_AXIS_INDEX).size();
         throw Exceptions::LogicErrorException(ostr.str());
     }
 
-    for(size_t row=0; row<nrows; ++row) {
-        for(size_t col=0; col<ncols; ++col) {
-            size_t globalbin = nrows - row - 1 + col*nrows;
+    for (size_t row = 0; row < nrows; ++row) {
+        for (size_t col = 0; col < ncols; ++col) {
+            size_t globalbin = nrows - row - 1 + col * nrows;
             m_data[globalbin].add(data[row][col]);
         }
     }
@@ -153,11 +152,11 @@ Histogram1D* Histogram2D::create_projectionX(int ybinlow, int ybinup)
 {
     Histogram1D* result = new Histogram1D(this->getXaxis());
 
-    for(size_t index=0; index<getTotalNumberOfBins(); ++index) {
+    for (size_t index = 0; index < getTotalNumberOfBins(); ++index) {
 
         int ybin = static_cast<int>(getYaxisIndex(index));
 
-        if(ybin >= ybinlow && ybin <= ybinup) {
+        if (ybin >= ybinlow && ybin <= ybinup) {
             result->fill(getXaxisValue(index), getBinContent(index));
         }
     }
@@ -168,11 +167,11 @@ Histogram1D* Histogram2D::create_projectionY(int xbinlow, int xbinup)
 {
     Histogram1D* result = new Histogram1D(this->getYaxis());
 
-    for(size_t index=0; index<getTotalNumberOfBins(); ++index) {
+    for (size_t index = 0; index < getTotalNumberOfBins(); ++index) {
 
         int xbin = static_cast<int>(getXaxisIndex(index));
 
-        if(xbin >= xbinlow && xbin <= xbinup) {
+        if (xbin >= xbinlow && xbin <= xbinup) {
             result->fill(getYaxisValue(index), getBinContent(index));
         }
     }
diff --git a/Core/Instrument/Histogram2D.h b/Core/Instrument/Histogram2D.h
index 0ae3d65b6a4..fb282c7d8fb 100644
--- a/Core/Instrument/Histogram2D.h
+++ b/Core/Instrument/Histogram2D.h
@@ -15,8 +15,8 @@
 #ifndef HISTOGRAM2D_H
 #define HISTOGRAM2D_H
 
-#include "IHistogram.h"
 #include "ArrayUtils.h"
+#include "IHistogram.h"
 
 //! Two dimensional histogram.
 //! @ingroup tools
@@ -40,8 +40,8 @@ public:
     //! @param nbinsy number of bins on Y-axis
     //! @param ybins Array of size nbins+1 containing low-edges for each
     //! bin and upper edge of last bin.
-    Histogram2D(int nbinsx, const std::vector<double>& xbins,
-                int nbinsy, const std::vector<double>& ybins);
+    Histogram2D(int nbinsx, const std::vector<double>& xbins, int nbinsy,
+                const std::vector<double>& ybins);
 
     //! Constructor for 2D histogram with custom axes
     Histogram2D(const IAxis& axis_x, const IAxis& axis_y);
@@ -56,7 +56,7 @@ public:
     Histogram2D* clone() const;
 
     //! Returns the number of histogram dimensions
-    size_t getRank() const { return 2;}
+    size_t getRank() const { return 2; }
 
     //! Increment bin with abscissa x and ordinate y with a weight.
     int fill(double x, double y, double weight = 1.0);
@@ -101,8 +101,7 @@ public:
     void addContent(const std::vector<std::vector<double>>& data);
 
 protected:
-    template<typename T>
-    void initFromShape(const T& data);
+    template <typename T> void initFromShape(const T& data);
 
     //! Creates projection along X. The projections is made by collecting the data in the range
     //! between [ybinlow, ybinup].
@@ -113,20 +112,18 @@ protected:
     Histogram1D* create_projectionY(int xbinlow, int xbinup);
 };
 
-
-template<typename T> void Histogram2D::initFromShape(const T& data)
+template <typename T> void Histogram2D::initFromShape(const T& data)
 {
     auto shape = ArrayUtils::getShape(data);
     const size_t nrows = shape.first;
     const size_t ncols = shape.second;
 
-    if(nrows == 0 || ncols == 0)
+    if (nrows == 0 || ncols == 0)
         throw Exceptions::LogicErrorException("Histogram2D::Histogram2D() -> Error. "
                                               "Not a two-dimensional numpy array");
 
     m_data.addAxis(FixedBinAxis("x-axis", ncols, 0.0, static_cast<double>(ncols)));
     m_data.addAxis(FixedBinAxis("y-axis", nrows, 0.0, static_cast<double>(nrows)));
-
 }
 
 #endif // HISTOGRAM2D_H
diff --git a/Core/Instrument/IChiSquaredModule.cpp b/Core/Instrument/IChiSquaredModule.cpp
index adacdc5810f..6fe956d9933 100644
--- a/Core/Instrument/IChiSquaredModule.cpp
+++ b/Core/Instrument/IChiSquaredModule.cpp
@@ -16,23 +16,19 @@
 #include "IIntensityFunction.h"
 #include <VarianceFunctions.h>
 
-IChiSquaredModule::IChiSquaredModule()
-    : m_variance_function(new VarianceSimFunction)
-{
-}
+IChiSquaredModule::IChiSquaredModule() : m_variance_function(new VarianceSimFunction) {}
 
 const IVarianceFunction* IChiSquaredModule::varianceFunction() const
 {
     return m_variance_function.get();
 }
 
-IChiSquaredModule::IChiSquaredModule(const IChiSquaredModule& other)
-    : ICloneable()
+IChiSquaredModule::IChiSquaredModule(const IChiSquaredModule& other) : ICloneable()
 {
-    if(other.m_variance_function)
+    if (other.m_variance_function)
         m_variance_function.reset(other.m_variance_function->clone());
 
-    if(other.mp_intensity_function)
+    if (other.mp_intensity_function)
         mp_intensity_function.reset(other.mp_intensity_function->clone());
 }
 
diff --git a/Core/Instrument/IDetector.cpp b/Core/Instrument/IDetector.cpp
index 73b115c927a..03c8cea704a 100644
--- a/Core/Instrument/IDetector.cpp
+++ b/Core/Instrument/IDetector.cpp
@@ -12,14 +12,14 @@
 //
 // ************************************************************************** //
 
-#include "ConvolutionDetectorResolution.h"
 #include "IDetector.h"
+#include "ConvolutionDetectorResolution.h"
+#include "DetectorMask.h"
 #include "IDetectorResolution.h"
 #include "OutputData.h"
 #include "RegionOfInterest.h"
 #include "SimulationArea.h"
 #include "SimulationElement.h"
-#include "DetectorMask.h"
 
 IDetector::IDetector()
 {
@@ -27,11 +27,9 @@ IDetector::IDetector()
 }
 
 IDetector::IDetector(const IDetector& other)
-    : ICloneable()
-    , m_axes(other.m_axes)
-    , m_detection_properties(other.m_detection_properties)
+    : ICloneable(), m_axes(other.m_axes), m_detection_properties(other.m_detection_properties)
 {
-    if(other.mP_detector_resolution)
+    if (other.mP_detector_resolution)
         setDetectorResolution(*other.mP_detector_resolution);
     setName(other.getName());
     registerChild(&m_detection_properties);
@@ -66,12 +64,11 @@ size_t IDetector::axisBinIndex(size_t index, size_t selected_axis) const
                              "Error! No axis with given number");
 }
 
-std::unique_ptr<IAxis> IDetector::createAxis(size_t index, size_t n_bins,
-                                             double min, double max) const
+std::unique_ptr<IAxis> IDetector::createAxis(size_t index, size_t n_bins, double min,
+                                             double max) const
 {
     if (max <= min)
-        throw Exceptions::LogicErrorException(
-            "IDetector::createAxis() -> Error! max <= min");
+        throw Exceptions::LogicErrorException("IDetector::createAxis() -> Error! max <= min");
     if (n_bins == 0)
         throw Exceptions::LogicErrorException(
             "IDetector::createAxis() -> Error! Number n_bins can't be zero.");
@@ -91,7 +88,7 @@ size_t IDetector::totalSize() const
 }
 
 void IDetector::setAnalyzerProperties(const kvector_t direction, double efficiency,
-                                        double total_transmission)
+                                      double total_transmission)
 {
     m_detection_properties.setAnalyzerProperties(direction, efficiency, total_transmission);
 }
@@ -113,7 +110,7 @@ void IDetector::applyDetectorResolution(OutputData<double>* p_intensity_map) con
 {
     if (!p_intensity_map)
         throw std::runtime_error("IDetector::applyDetectorResolution() -> "
-                                   "Error! Null pointer to intensity map");
+                                 "Error! Null pointer to intensity map");
     if (mP_detector_resolution) {
         mP_detector_resolution->applyDetectorResolution(p_intensity_map);
         if (detectorMask() && detectorMask()->hasMasks()) {
@@ -171,10 +168,10 @@ std::unique_ptr<OutputData<double>> IDetector::createDetectorMap() const
     return result;
 }
 
-void IDetector::setDataToDetectorMap(OutputData<double> &detectorMap,
-                                       const std::vector<SimulationElement> &elements) const
+void IDetector::setDataToDetectorMap(OutputData<double>& detectorMap,
+                                     const std::vector<SimulationElement>& elements) const
 {
-    if(elements.empty())
+    if (elements.empty())
         return;
     iterate([&](const_iterator it) {
         detectorMap[it.roiIndex()] = elements[it.elementIndex()].getIntensity();
@@ -184,7 +181,7 @@ void IDetector::setDataToDetectorMap(OutputData<double> &detectorMap,
 size_t IDetector::numberOfSimulationElements() const
 {
     size_t result(0);
-    iterate([&result](const_iterator) { ++result;});
+    iterate([&result](const_iterator) { ++result; });
     return result;
 }
 
@@ -193,19 +190,18 @@ std::vector<const INode*> IDetector::getChildren() const
     return std::vector<const INode*>() << &m_detection_properties << mP_detector_resolution;
 }
 
-void IDetector::iterate(std::function<void (IDetector::const_iterator)> func,
-                        bool visit_masks) const
+void IDetector::iterate(std::function<void(IDetector::const_iterator)> func, bool visit_masks) const
 {
     if (this->dimension() == 0)
         return;
 
     if (visit_masks) {
         SimulationRoiArea area(this);
-        for(SimulationRoiArea::iterator it = area.begin(); it!=area.end(); ++it)
+        for (SimulationRoiArea::iterator it = area.begin(); it != area.end(); ++it)
             func(it);
     } else {
         SimulationArea area(this);
-        for(SimulationArea::iterator it = area.begin(); it!=area.end(); ++it)
+        for (SimulationArea::iterator it = area.begin(); it != area.end(); ++it)
             func(it);
     }
 }
diff --git a/Core/Instrument/IDetector.h b/Core/Instrument/IDetector.h
index a553ca26114..621e30cd42d 100644
--- a/Core/Instrument/IDetector.h
+++ b/Core/Instrument/IDetector.h
@@ -15,11 +15,11 @@
 #ifndef IDETECTOR_H_
 #define IDETECTOR_H_
 
+#include "DetectionProperties.h"
 #include "IAxis.h"
 #include "ICloneable.h"
 #include "INode.h"
 #include "IUnitConverter.h"
-#include "DetectionProperties.h"
 #include "SafePointerVector.h"
 #include "SimulationAreaIterator.h"
 
@@ -27,34 +27,34 @@ class Beam;
 class DetectorMask;
 class IDetectorResolution;
 class IResolutionFunction2D;
-template<class T> class OutputData;
+template <class T> class OutputData;
 class SimulationElement;
 class RegionOfInterest;
 
 //! Abstract detector interface.
 //! @ingroup simulation
 
-class BA_CORE_API_ IDetector :  public ICloneable, public INode
+class BA_CORE_API_ IDetector : public ICloneable, public INode
 {
 public:
     using const_iterator = const SimulationAreaIterator&;
     IDetector();
 
-    IDetector* clone() const override =0;
+    IDetector* clone() const override = 0;
 
     virtual ~IDetector();
 
     //! Inits detector with the beam settings
     virtual void init(const Beam&) {}
 
-    void clear() {m_axes.clear();}
+    void clear() { m_axes.clear(); }
 
     void addAxis(const IAxis& axis);
 
     const IAxis& getAxis(size_t index) const;
 
     //! Returns actual dimensionality of the detector (number of defined axes)
-    size_t dimension() const {return m_axes.size();}
+    size_t dimension() const { return m_axes.size(); }
 
     //! Calculate axis index for given global index
     size_t axisBinIndex(size_t index, size_t selected_axis) const;
@@ -94,22 +94,22 @@ public:
     virtual void resetRegionOfInterest() = 0;
 
     //! Returns detection properties
-    const DetectionProperties& detectionProperties() const {return m_detection_properties;}
+    const DetectionProperties& detectionProperties() const { return m_detection_properties; }
 
     //! Returns new intensity map with detector resolution applied. Map will be cropped to ROI
     //! if ROI is present.
-    OutputData<double>* createDetectorIntensity(
-            const std::vector<SimulationElement>& elements) const;
+    OutputData<double>*
+    createDetectorIntensity(const std::vector<SimulationElement>& elements) const;
 
     //! Return default axes units
-    virtual AxesUnits defaultAxesUnits() const {return AxesUnits::DEFAULT;}
+    virtual AxesUnits defaultAxesUnits() const { return AxesUnits::DEFAULT; }
 
     //! Returns number of simulation elements.
     size_t numberOfSimulationElements() const;
 
     std::vector<const INode*> getChildren() const override;
 
-    void iterate(std::function<void(const_iterator)> func, bool visit_masks=false) const;
+    void iterate(std::function<void(const_iterator)> func, bool visit_masks = false) const;
 
 protected:
     IDetector(const IDetector& other);
diff --git a/Core/Instrument/IDetectorResolution.h b/Core/Instrument/IDetectorResolution.h
index 7b9966cf10b..b412ee0a152 100644
--- a/Core/Instrument/IDetectorResolution.h
+++ b/Core/Instrument/IDetectorResolution.h
@@ -15,10 +15,9 @@
 #ifndef IDETECTORRESOLUTION_H
 #define IDETECTORRESOLUTION_H
 
-#include "INode.h"
 #include "ICloneable.h"
+#include "INode.h"
 #include "OutputData.h"
-#include "ICloneable.h"
 
 //! Interface for detector resolution algorithms
 //! @ingroup algorithms_internal
@@ -28,7 +27,7 @@ class BA_CORE_API_ IDetectorResolution : public ICloneable, public INode
 public:
     virtual ~IDetectorResolution() {}
     //! Apply the resolution function to the intensity data
-    virtual void applyDetectorResolution(OutputData<double>* p_intensity_map) const=0;
+    virtual void applyDetectorResolution(OutputData<double>* p_intensity_map) const = 0;
 #ifndef SWIG
     //! Applies the detector resolution to the matrix-valued intensity data
     void applyDetectorResolutionPol(OutputData<Eigen::Matrix2d>* p_matrix_intensity) const;
diff --git a/Core/Instrument/IHistogram.cpp b/Core/Instrument/IHistogram.cpp
index 2de90554d38..b433d49a5f8 100644
--- a/Core/Instrument/IHistogram.cpp
+++ b/Core/Instrument/IHistogram.cpp
@@ -18,9 +18,7 @@
 #include "Numeric.h"
 #include <memory>
 
-IHistogram::IHistogram()
-{
-}
+IHistogram::IHistogram() {}
 
 IHistogram::IHistogram(const IHistogram& other)
 {
@@ -89,7 +87,8 @@ size_t IHistogram::getGlobalBin(size_t binx, size_t biny) const
 {
     std::vector<unsigned> axes_indices;
     axes_indices.push_back(static_cast<unsigned>(binx));
-    if(getRank() == 2) axes_indices.push_back(static_cast<unsigned>(biny));
+    if (getRank() == 2)
+        axes_indices.push_back(static_cast<unsigned>(biny));
     return m_data.toGlobalIndex(axes_indices);
 }
 
@@ -97,7 +96,8 @@ size_t IHistogram::findGlobalBin(double x, double y) const
 {
     std::vector<double> coordinates;
     coordinates.push_back(x);
-    if(getRank() == 2) coordinates.push_back(y);
+    if (getRank() == 2)
+        coordinates.push_back(y);
     return m_data.findGlobalIndex(coordinates);
 }
 
@@ -175,41 +175,38 @@ int IHistogram::getBinNumberOfEntries(size_t binx, size_t biny) const
 
 double IHistogram::getMaximum() const
 {
-    OutputData<CumulativeValue>::const_iterator it =
-         std::max_element(m_data.begin(), m_data.end());
+    OutputData<CumulativeValue>::const_iterator it = std::max_element(m_data.begin(), m_data.end());
     return it->getContent();
 }
 
 size_t IHistogram::getMaximumBinIndex() const
 {
-    OutputData<CumulativeValue>::const_iterator it =
-         std::max_element(m_data.begin(), m_data.end());
+    OutputData<CumulativeValue>::const_iterator it = std::max_element(m_data.begin(), m_data.end());
     return std::distance(m_data.begin(), it);
 }
 
 double IHistogram::getMinimum() const
 {
-    OutputData<CumulativeValue>::const_iterator it =
-         std::min_element(m_data.begin(), m_data.end());
+    OutputData<CumulativeValue>::const_iterator it = std::min_element(m_data.begin(), m_data.end());
     return it->getContent();
 }
 
 size_t IHistogram::getMinimumBinIndex() const
 {
-    return std::distance(m_data.begin(), std::min_element(m_data.begin(), m_data.end()) );
+    return std::distance(m_data.begin(), std::min_element(m_data.begin(), m_data.end()));
 }
 
 void IHistogram::scale(double value)
 {
-    for(size_t index=0; index<getTotalNumberOfBins(); ++index) {
-        m_data[index].setContent(value*m_data[index].getContent());
+    for (size_t index = 0; index < getTotalNumberOfBins(); ++index) {
+        m_data[index].setContent(value * m_data[index].getContent());
     }
 }
 
 double IHistogram::integral() const
 {
     double result(0.0);
-    for(size_t index=0; index<getTotalNumberOfBins(); ++index) {
+    for (size_t index = 0; index < getTotalNumberOfBins(); ++index) {
         result += m_data[index].getContent();
     }
     return result;
@@ -235,9 +232,9 @@ void IHistogram::reset()
 
 IHistogram* IHistogram::createHistogram(const OutputData<double>& source)
 {
-    if(source.getRank() == 1) {
+    if (source.getRank() == 1) {
         return new Histogram1D(source);
-    } else if(source.getRank() == 2) {
+    } else if (source.getRank() == 2) {
         return new Histogram2D(source);
     } else {
         std::ostringstream message;
@@ -260,7 +257,7 @@ IHistogram* IHistogram::createFrom(const std::vector<std::vector<double>>& data)
 
 void IHistogram::check_x_axis() const
 {
-    if(getRank() <1) {
+    if (getRank() < 1) {
         std::ostringstream message;
         message << "IHistogram::check_x_axis() -> Error. X-xis does not exist. ";
         message << "Rank of histogram " << getRank() << "." << std::endl;
@@ -270,7 +267,7 @@ void IHistogram::check_x_axis() const
 
 void IHistogram::check_y_axis() const
 {
-    if(getRank() <2) {
+    if (getRank() < 2) {
         std::ostringstream message;
         message << "IHistogram::check_y_axis() -> Error. Y-axis does not exist. ";
         message << "Rank of histogram " << getRank() << "." << std::endl;
@@ -280,7 +277,7 @@ void IHistogram::check_y_axis() const
 
 void IHistogram::init_from_data(const OutputData<double>& source)
 {
-    if(getRank() != source.getRank()) {
+    if (getRank() != source.getRank()) {
         std::ostringstream message;
         message << "IHistogram::IHistogram(const OutputData<double>& data) -> Error. ";
         message << "The dimension of this histogram " << getRank() << " ";
@@ -289,7 +286,7 @@ void IHistogram::init_from_data(const OutputData<double>& source)
     }
 
     m_data.copyShapeFrom(source);
-    for(size_t i=0; i<source.getAllocatedSize(); ++i) {
+    for (size_t i = 0; i < source.getAllocatedSize(); ++i) {
         m_data[i].add(source[i]);
     }
 }
@@ -297,13 +294,13 @@ void IHistogram::init_from_data(const OutputData<double>& source)
 //! returns data of requested type for globalbin number
 double IHistogram::getBinData(size_t i, IHistogram::DataType dataType) const
 {
-    if(dataType == DataType::INTEGRAL) {
+    if (dataType == DataType::INTEGRAL) {
         return getBinContent(i);
-    } else if(dataType == DataType::AVERAGE) {
+    } else if (dataType == DataType::AVERAGE) {
         return getBinAverage(i);
-    } else if(dataType == DataType::STANDARD_ERROR) {
+    } else if (dataType == DataType::STANDARD_ERROR) {
         return getBinError(i);
-    } else if(dataType == DataType::NENTRIES) {
+    } else if (dataType == DataType::NENTRIES) {
         return getBinNumberOfEntries(i);
     } else
         throw Exceptions::LogicErrorException(
@@ -315,7 +312,7 @@ std::vector<double> IHistogram::getDataVector(IHistogram::DataType dataType) con
 {
     std::vector<double> result;
     result.resize(getTotalNumberOfBins(), 0.0);
-    for(size_t index=0; index<getTotalNumberOfBins(); ++index) {
+    for (size_t index = 0; index < getTotalNumberOfBins(); ++index) {
         result[index] = getBinData(index, dataType);
     }
     return result;
@@ -324,14 +321,13 @@ std::vector<double> IHistogram::getDataVector(IHistogram::DataType dataType) con
 //! Copy content (but not the axes) from other histogram. Dimensions should be the same.
 void IHistogram::copyContentFrom(const IHistogram& other)
 {
-    if(!hasSameDimensions(other))
+    if (!hasSameDimensions(other))
         throw Exceptions::LogicErrorException(
             "IHistogram::copyContentFrom() -> Error. Can't copy the data of different shape.");
     reset();
-    for(size_t i=0; i<getTotalNumberOfBins(); ++i) {
+    for (size_t i = 0; i < getTotalNumberOfBins(); ++i) {
         m_data[i] = other.m_data[i];
     }
-
 }
 
 //! creates new OutputData with histogram's shape and put there values corresponding to DataType
@@ -339,7 +335,7 @@ OutputData<double>* IHistogram::createOutputData(IHistogram::DataType dataType)
 {
     OutputData<double>* result = new OutputData<double>;
     result->copyShapeFrom(m_data);
-    for(size_t i=0; i<getTotalNumberOfBins(); ++i) {
+    for (size_t i = 0; i < getTotalNumberOfBins(); ++i) {
         (*result)[i] = getBinData(i, dataType);
     }
     return result;
@@ -357,25 +353,24 @@ bool IHistogram::hasSameDimensions(const IHistogram& other) const
 
 const IHistogram& IHistogram::operator+=(const IHistogram& right)
 {
-    if(!hasSameDimensions(right))
+    if (!hasSameDimensions(right))
         throw Exceptions::LogicErrorException(
             "IHistogram::operator+=() -> Error. Histograms have different dimension");
-    for(size_t i=0; i<getTotalNumberOfBins(); ++i)
+    for (size_t i = 0; i < getTotalNumberOfBins(); ++i)
         addBinContent(i, right.getBinContent(i));
     return *this;
 }
 
 IHistogram* IHistogram::relativeDifferenceHistogram(const IHistogram& rhs)
 {
-    if(!hasSameDimensions(rhs))
-        throw Exceptions::LogicErrorException(
-            "IHistogram::relativeDifferenceHistogram() -> Error. "
-            "Histograms have different dimensions");
+    if (!hasSameDimensions(rhs))
+        throw Exceptions::LogicErrorException("IHistogram::relativeDifferenceHistogram() -> Error. "
+                                              "Histograms have different dimensions");
 
     IHistogram* result = this->clone();
     result->reset();
 
-    for(size_t i=0; i<getTotalNumberOfBins(); ++i) {
+    for (size_t i = 0; i < getTotalNumberOfBins(); ++i) {
         double diff = Numeric::GetRelativeDifference(getBinContent(i), rhs.getBinContent(i));
         result->setBinContent(i, diff);
     }
diff --git a/Core/Instrument/IHistogram.h b/Core/Instrument/IHistogram.h
index 58f260d7665..0a523d1f49e 100644
--- a/Core/Instrument/IHistogram.h
+++ b/Core/Instrument/IHistogram.h
@@ -27,16 +27,11 @@ class Histogram1D;
 class BA_CORE_API_ IHistogram
 {
 public:
-    enum DataType {
-        INTEGRAL,
-        AVERAGE,
-        STANDARD_ERROR,
-        NENTRIES
-    };
+    enum DataType { INTEGRAL, AVERAGE, STANDARD_ERROR, NENTRIES };
 
     IHistogram();
     IHistogram(const IHistogram& other);
-    virtual ~IHistogram(){}
+    virtual ~IHistogram() {}
 
     IHistogram(const IAxis& axis_x);
     IHistogram(const IAxis& axis_x, const IAxis& axis_y);
@@ -160,9 +155,8 @@ public:
     //! @brief Returns integral of bins content (computed as a sum of all bin content).
     double integral() const;
 
-//    double& operator[](size_t index);
-//    const double& operator[](size_t index) const;
-
+    //    double& operator[](size_t index);
+    //    const double& operator[](size_t index) const;
 
 #ifdef BORNAGAIN_PYTHON
     //! Returns numpy array with bin content (accumulated values).
diff --git a/Core/Instrument/IIntensityFunction.cpp b/Core/Instrument/IIntensityFunction.cpp
index 1e230274b93..bbcecaaa7a8 100644
--- a/Core/Instrument/IIntensityFunction.cpp
+++ b/Core/Instrument/IIntensityFunction.cpp
@@ -18,17 +18,22 @@
 
 IIntensityFunction::~IIntensityFunction() = default;
 
-IntensityFunctionLog* IntensityFunctionLog::clone() const { return new IntensityFunctionLog; }
+IntensityFunctionLog* IntensityFunctionLog::clone() const
+{
+    return new IntensityFunctionLog;
+}
 
 double IntensityFunctionLog::evaluate(double value) const
 {
     return value > 0 ? std::log(value) : std::numeric_limits<double>::lowest();
 }
 
-IntensityFunctionSqrt* IntensityFunctionSqrt::clone() const { return new IntensityFunctionSqrt; }
+IntensityFunctionSqrt* IntensityFunctionSqrt::clone() const
+{
+    return new IntensityFunctionSqrt;
+}
 
 double IntensityFunctionSqrt::evaluate(double value) const
 {
     return value > 0 ? std::sqrt(value) : std::numeric_limits<double>::lowest();
 }
-
diff --git a/Core/Instrument/IIntensityFunction.h b/Core/Instrument/IIntensityFunction.h
index 711c13f9623..bdc75093640 100644
--- a/Core/Instrument/IIntensityFunction.h
+++ b/Core/Instrument/IIntensityFunction.h
@@ -25,29 +25,27 @@ class BA_CORE_API_ IIntensityFunction
 {
 public:
     virtual ~IIntensityFunction();
-    virtual IIntensityFunction *clone() const =0;
-    virtual double evaluate(double value) const =0;
+    virtual IIntensityFunction* clone() const = 0;
+    virtual double evaluate(double value) const = 0;
 };
 
-
 //! Algorithm for applying log function to the measured intensity.
 //! @ingroup algorithms_internal
 
 class BA_CORE_API_ IntensityFunctionLog : public IIntensityFunction
 {
 public:
-    virtual IntensityFunctionLog *clone() const;
+    virtual IntensityFunctionLog* clone() const;
     virtual double evaluate(double value) const;
 };
 
-
 //! Algorithm for applying sqrt function to the measured intensity.
 //! @ingroup algorithms_internal
 
 class BA_CORE_API_ IntensityFunctionSqrt : public IIntensityFunction
 {
 public:
-    virtual IntensityFunctionSqrt *clone() const;
+    virtual IntensityFunctionSqrt* clone() const;
     virtual double evaluate(double value) const;
 };
 
diff --git a/Core/Instrument/IIntensityNormalizer.cpp b/Core/Instrument/IIntensityNormalizer.cpp
index c078edc3a3b..25745b6b390 100644
--- a/Core/Instrument/IIntensityNormalizer.cpp
+++ b/Core/Instrument/IIntensityNormalizer.cpp
@@ -28,10 +28,9 @@ IntensityNormalizer* IntensityNormalizer::clone() const
     return result;
 }
 
-OutputData<double>* IntensityNormalizer::createNormalizedData(
-        const OutputData<double>& data) const
+OutputData<double>* IntensityNormalizer::createNormalizedData(const OutputData<double>& data) const
 {
-    OutputData<double >* normalized_data = data.clone();
+    OutputData<double>* normalized_data = data.clone();
     apply(*normalized_data);
     return normalized_data;
 }
@@ -39,17 +38,16 @@ OutputData<double>* IntensityNormalizer::createNormalizedData(
 void IntensityNormalizer::apply(OutputData<double>& data) const
 {
     double factor = m_max_intensity;
-    if(factor == 0) {
+    if (factor == 0) {
         // using self maximum amplitude for normalization
         OutputData<double>::const_iterator it = std::max_element(data.begin(), data.end());
         factor = *it;
     }
-    if(factor == 0)
-        throw Exceptions::DivisionByZeroException(
-                "IntensityNormalizer::apply() -> "
-                "Error! Maximum intensity is 0.");
+    if (factor == 0)
+        throw Exceptions::DivisionByZeroException("IntensityNormalizer::apply() -> "
+                                                  "Error! Maximum intensity is 0.");
 
-    for(auto& value : data) {
-        value = m_scale*(value/factor) + m_shift;
+    for (auto& value : data) {
+        value = m_scale * (value / factor) + m_shift;
     }
 }
diff --git a/Core/Instrument/IIntensityNormalizer.h b/Core/Instrument/IIntensityNormalizer.h
index 2879f8729ce..373311a6bed 100644
--- a/Core/Instrument/IIntensityNormalizer.h
+++ b/Core/Instrument/IIntensityNormalizer.h
@@ -28,24 +28,22 @@ class BA_CORE_API_ IIntensityNormalizer : public ICloneable, public INode
 public:
     virtual ~IIntensityNormalizer() {}
 
-    virtual IIntensityNormalizer* clone() const=0;
+    virtual IIntensityNormalizer* clone() const = 0;
 
-    virtual OutputData<double>* createNormalizedData(
-            const OutputData<double>& data) const=0;
+    virtual OutputData<double>* createNormalizedData(const OutputData<double>& data) const = 0;
 
-    virtual void apply(OutputData<double>& data) const=0;
+    virtual void apply(OutputData<double>& data) const = 0;
 
-    virtual void setMaximumIntensity(double) =0;
+    virtual void setMaximumIntensity(double) = 0;
 };
 
-
 //! Standard OutputData normalizer, with configurable max_intensity.
 //! @ingroup algorithms_internal
 
 class BA_CORE_API_ IntensityNormalizer : public IIntensityNormalizer
 {
 public:
-    IntensityNormalizer(double scale=1.0, double shift=0.0)
+    IntensityNormalizer(double scale = 1.0, double shift = 0.0)
         : m_scale(scale), m_shift(shift), m_max_intensity(0.0)
     {
         setName("Normalizer");
@@ -58,12 +56,11 @@ public:
 
     void accept(INodeVisitor* visitor) const { visitor->visit(this); }
 
-    virtual OutputData<double>* createNormalizedData(const OutputData<double >& data) const;
+    virtual OutputData<double>* createNormalizedData(const OutputData<double>& data) const;
 
     void apply(OutputData<double>& data) const final;
 
-    virtual void setMaximumIntensity(double max_intensity) {
-        m_max_intensity = max_intensity; }
+    virtual void setMaximumIntensity(double max_intensity) { m_max_intensity = max_intensity; }
 
 protected:
     //! Registers some class members for later access via parameter pool
@@ -74,15 +71,17 @@ protected:
     double m_max_intensity;
 };
 
-
 //! Simplified OutputData normalizer, with max_intensity=1.
 //! @ingroup algorithms_internal
 
 class BA_CORE_API_ IntensityScaleAndShiftNormalizer : public IntensityNormalizer
 {
 public:
-    IntensityScaleAndShiftNormalizer(double scale=1.0, double shift=0.0)
-        : IntensityNormalizer(scale, shift) { m_max_intensity = 1.0; }
+    IntensityScaleAndShiftNormalizer(double scale = 1.0, double shift = 0.0)
+        : IntensityNormalizer(scale, shift)
+    {
+        m_max_intensity = 1.0;
+    }
 
     ~IntensityScaleAndShiftNormalizer() final {}
 
@@ -90,8 +89,10 @@ public:
 
     void setMaximumIntensity(double) final {}
 
-    IntensityScaleAndShiftNormalizer* clone() const final {
-        return new IntensityScaleAndShiftNormalizer(m_scale, m_shift); }
+    IntensityScaleAndShiftNormalizer* clone() const final
+    {
+        return new IntensityScaleAndShiftNormalizer(m_scale, m_shift);
+    }
 };
 
 #endif // IINTENSITYNORMALIZER_H
diff --git a/Core/Instrument/IResolutionFunction2D.h b/Core/Instrument/IResolutionFunction2D.h
index 6dfc0e8a719..21b6b4a5b91 100644
--- a/Core/Instrument/IResolutionFunction2D.h
+++ b/Core/Instrument/IResolutionFunction2D.h
@@ -26,8 +26,8 @@ class BA_CORE_API_ IResolutionFunction2D : public ICloneable, public INode
 public:
     virtual ~IResolutionFunction2D() {}
 
-    virtual double evaluateCDF(double x, double y) const =0;
-    virtual IResolutionFunction2D* clone() const =0;
+    virtual double evaluateCDF(double x, double y) const = 0;
+    virtual IResolutionFunction2D* clone() const = 0;
 };
 
 #endif // IRESOLUTIONFUNCTION2D_H
diff --git a/Core/Instrument/ISpecularScan.cpp b/Core/Instrument/ISpecularScan.cpp
index 8f92dc375bd..2a8b1962c92 100644
--- a/Core/Instrument/ISpecularScan.cpp
+++ b/Core/Instrument/ISpecularScan.cpp
@@ -14,8 +14,6 @@
 
 #include "ISpecularScan.h"
 
-ISpecularScan::ISpecularScan(SPECULAR_DATA_TYPE data_type)
-    : m_data_type(data_type)
-{}
+ISpecularScan::ISpecularScan(SPECULAR_DATA_TYPE data_type) : m_data_type(data_type) {}
 
 ISpecularScan::~ISpecularScan() = default;
diff --git a/Core/Instrument/ISpecularScan.h b/Core/Instrument/ISpecularScan.h
index 14784ad86f9..101a730da0e 100644
--- a/Core/Instrument/ISpecularScan.h
+++ b/Core/Instrument/ISpecularScan.h
@@ -17,9 +17,9 @@
 
 #include "ICloneable.h"
 
+#include <sstream>
 #include <string>
 #include <vector>
-#include <sstream>
 
 class IAxis;
 class IFootprintFactor;
@@ -29,7 +29,7 @@ class SpecularSimulationElement;
 class BA_CORE_API_ ISpecularScan : public ICloneable
 {
 public:
-    enum SPECULAR_DATA_TYPE {angle, q};
+    enum SPECULAR_DATA_TYPE { angle, q };
 
     ISpecularScan(SPECULAR_DATA_TYPE data_type);
     ~ISpecularScan() override;
@@ -58,9 +58,9 @@ public:
 
     //! Print scan definition in python format
     virtual std::string print() const = 0;
-#endif //SWIG
+#endif // SWIG
 
-    SPECULAR_DATA_TYPE dataType() const {return m_data_type;}
+    SPECULAR_DATA_TYPE dataType() const { return m_data_type; }
 
 private:
     SPECULAR_DATA_TYPE m_data_type;
diff --git a/Core/Instrument/IUnitConverter.cpp b/Core/Instrument/IUnitConverter.cpp
index b27cd6d5903..efee6ae9438 100644
--- a/Core/Instrument/IUnitConverter.cpp
+++ b/Core/Instrument/IUnitConverter.cpp
@@ -16,12 +16,13 @@
 #include "OutputData.h"
 #include "UnitConverterUtils.h"
 
-namespace {
+namespace
+{
 const std::map<AxesUnits, std::string> unit_names = {
     {AxesUnits::NBINS, "AxesUnits::NBINS"},     {AxesUnits::RADIANS, "AxesUnits::RADIANS"},
     {AxesUnits::DEGREES, "AxesUnits::DEGREES"}, {AxesUnits::MM, "AxesUnits::MM"},
     {AxesUnits::QSPACE, "AxesUnits::QSPACE"},   {AxesUnits::QXQY, "AxesUnits::QXQY"},
-    {AxesUnits::RQ4, "AxesUnits::RQ4"} };
+    {AxesUnits::RQ4, "AxesUnits::RQ4"}};
 }
 
 std::string AxesUnitsWrap::unitName(AxesUnits unit)
@@ -32,7 +33,7 @@ std::string AxesUnitsWrap::unitName(AxesUnits unit)
     return "Unknown units";
 }
 
-IUnitConverter::~IUnitConverter() =default;
+IUnitConverter::~IUnitConverter() = default;
 
 std::string IUnitConverter::axisName(size_t i_axis, AxesUnits units_type) const
 {
@@ -62,7 +63,8 @@ IUnitConverter::createConvertedData(const OutputData<double>& data, AxesUnits un
 
 void IUnitConverter::checkIndex(size_t i_axis) const
 {
-    if (i_axis < dimension()) return;
+    if (i_axis < dimension())
+        return;
     throw std::runtime_error("Error in IUnitConverter::checkIndex: passed axis index too big: "
                              + std::to_string(static_cast<int>(i_axis)));
 }
@@ -70,9 +72,10 @@ void IUnitConverter::checkIndex(size_t i_axis) const
 void IUnitConverter::throwUnitsError(std::string method, std::vector<AxesUnits> available) const
 {
     std::stringstream ss;
-    ss << "Unit type error in " << method << ": unknown or unsupported unit type. Available units "
+    ss << "Unit type error in " << method
+       << ": unknown or unsupported unit type. Available units "
           "are:\n";
-    for (auto unit: available)
+    for (auto unit : available)
         ss << AxesUnitsWrap::unitName(unit) << "\n";
     throw std::runtime_error(ss.str());
 }
diff --git a/Core/Instrument/IUnitConverter.h b/Core/Instrument/IUnitConverter.h
index 81e8649c6d3..2ec6a994b20 100644
--- a/Core/Instrument/IUnitConverter.h
+++ b/Core/Instrument/IUnitConverter.h
@@ -15,14 +15,14 @@
 #ifndef IUNITCONVERTER_H
 #define IUNITCONVERTER_H
 
+#include "ICloneable.h"
 #include <map>
 #include <memory>
 #include <string>
 #include <vector>
-#include "ICloneable.h"
 
 class IAxis;
-template<class T> class OutputData;
+template <class T> class OutputData;
 
 //! Wrapper for detector axes units, required for a better representation of
 //! detector axes units in python
@@ -32,7 +32,7 @@ template<class T> class OutputData;
 struct BA_CORE_API_ AxesUnitsWrap {
     enum AxesUnits { DEFAULT, NBINS, RADIANS, DEGREES, MM, QSPACE, QXQY, RQ4 };
 #ifndef SWIG
-    // TODO: to automatize enum to string convertion, one can possibly use this solution 
+    // TODO: to automatize enum to string convertion, one can possibly use this solution
     // https://stackoverflow.com/questions/147267/easy-way-to-use-variables-of-enum-types-as-string-in-c#202511
     static std::string unitName(AxesUnits unit);
 #endif
@@ -47,18 +47,18 @@ class BA_CORE_API_ IUnitConverter : public ICloneable
 public:
     virtual ~IUnitConverter();
 
-    virtual IUnitConverter* clone() const=0;
+    virtual IUnitConverter* clone() const = 0;
 
-    virtual size_t dimension() const=0;
+    virtual size_t dimension() const = 0;
 
-    virtual double calculateMin(size_t i_axis, AxesUnits units_type) const=0;
-    virtual double calculateMax(size_t i_axis, AxesUnits units_type) const=0;
-    virtual size_t axisSize(size_t i_axis) const=0;
+    virtual double calculateMin(size_t i_axis, AxesUnits units_type) const = 0;
+    virtual double calculateMax(size_t i_axis, AxesUnits units_type) const = 0;
+    virtual size_t axisSize(size_t i_axis) const = 0;
 
     std::string axisName(size_t i_axis, AxesUnits units_type = AxesUnits::DEFAULT) const;
 
     virtual std::vector<AxesUnits> availableUnits() const = 0;
-    virtual AxesUnits defaultUnits() const=0;
+    virtual AxesUnits defaultUnits() const = 0;
 
 #ifndef SWIG
     virtual std::unique_ptr<IAxis> createConvertedAxis(size_t i_axis, AxesUnits units) const = 0;
@@ -75,7 +75,7 @@ protected:
 #endif // SWIG
 
 private:
-    virtual std::vector<std::map<AxesUnits, std::string>> createNameMaps() const=0;
+    virtual std::vector<std::map<AxesUnits, std::string>> createNameMaps() const = 0;
 };
 
 #endif // IUNITCONVERTER_H
diff --git a/Core/Instrument/Instrument.cpp b/Core/Instrument/Instrument.cpp
index b99c59f54b4..0f51f9b82ed 100644
--- a/Core/Instrument/Instrument.cpp
+++ b/Core/Instrument/Instrument.cpp
@@ -14,15 +14,14 @@
 
 #include "Instrument.h"
 #include "Beam.h"
-#include "IResolutionFunction2D.h"
-#include "SimulationElement.h"
-#include "SphericalDetector.h"
 #include "BornAgainNamespace.h"
 #include "DetectorFunctions.h"
 #include "Histogram2D.h"
+#include "IResolutionFunction2D.h"
+#include "SimulationElement.h"
+#include "SphericalDetector.h"
 
-Instrument::Instrument()
-    : mP_detector(new SphericalDetector)
+Instrument::Instrument() : mP_detector(new SphericalDetector)
 {
     setName(BornAgain::InstrumentType);
     registerChild(mP_detector.get());
@@ -32,7 +31,7 @@ Instrument::Instrument()
 
 Instrument::Instrument(const Instrument& other) : m_beam(other.m_beam)
 {
-    if(other.mP_detector)
+    if (other.mP_detector)
         setDetector(*other.mP_detector);
     registerChild(&m_beam);
     setName(other.getName());
@@ -46,7 +45,7 @@ Instrument& Instrument::operator=(const Instrument& other)
     if (this != &other) {
         m_beam = other.m_beam;
         registerChild(&m_beam);
-        if(other.mP_detector)
+        if (other.mP_detector)
             setDetector(*other.mP_detector);
         init_parameters();
     }
@@ -62,7 +61,7 @@ void Instrument::setDetector(const IDetector& detector)
 
 void Instrument::initDetector()
 {
-    if(!mP_detector)
+    if (!mP_detector)
         throw Exceptions::RuntimeErrorException(
             "Instrument::initDetector() -> Error. Detector is not initialized.");
     getDetector()->init(getBeam());
@@ -72,12 +71,11 @@ std::vector<const INode*> Instrument::getChildren() const
 {
     std::vector<const INode*> result;
     result.push_back(&m_beam);
-    if(mP_detector)
+    if (mP_detector)
         result.push_back(mP_detector.get());
     return result;
 }
 
-
 void Instrument::setDetectorResolutionFunction(const IResolutionFunction2D& p_resolution_function)
 {
     mP_detector->setResolutionFunction(p_resolution_function);
@@ -102,7 +100,8 @@ Instrument::createDetectorIntensity(const std::vector<SimulationElement>& elemen
 void Instrument::setBeamParameters(double wavelength, double alpha_i, double phi_i)
 {
     m_beam.setCentralK(wavelength, alpha_i, phi_i);
-    if(mP_detector) initDetector();
+    if (mP_detector)
+        initDetector();
 }
 
 const DetectorMask* Instrument::getDetectorMask() const
@@ -113,7 +112,8 @@ const DetectorMask* Instrument::getDetectorMask() const
 void Instrument::setBeam(const Beam& beam)
 {
     m_beam = beam;
-    if(mP_detector) initDetector();
+    if (mP_detector)
+        initDetector();
 }
 
 void Instrument::setBeamIntensity(double intensity)
diff --git a/Core/Instrument/Instrument.h b/Core/Instrument/Instrument.h
index adc23961e65..fae13981395 100644
--- a/Core/Instrument/Instrument.h
+++ b/Core/Instrument/Instrument.h
@@ -15,12 +15,12 @@
 #ifndef INSTRUMENT_H
 #define INSTRUMENT_H
 
+#include "Beam.h"
 #include "IDetector.h"
 #include "INode.h"
-#include "Beam.h"
 #include <memory>
 
-template<class T> class OutputData;
+template <class T> class OutputData;
 class Histogram2D;
 class DetectorMask;
 class IAxis;
@@ -87,8 +87,8 @@ public:
     void applyDetectorResolution(OutputData<double>* p_intensity_map) const;
 
     //! Returns new intensity map with detector resolution applied and axes in requested units
-    OutputData<double>* createDetectorIntensity(
-            const std::vector<SimulationElement> &elements) const;
+    OutputData<double>*
+    createDetectorIntensity(const std::vector<SimulationElement>& elements) const;
 
     //! init detector with beam settings
     void initDetector();
diff --git a/Core/Instrument/IntensityDataFunctions.cpp b/Core/Instrument/IntensityDataFunctions.cpp
index 1094b0924a9..4c794532d74 100644
--- a/Core/Instrument/IntensityDataFunctions.cpp
+++ b/Core/Instrument/IntensityDataFunctions.cpp
@@ -285,8 +285,8 @@ SimulationResult IntensityDataFunctions::ConvertData(const Simulation& simulatio
                                                      bool put_masked_areas_to_zero)
 {
     auto converter = UnitConverterUtils::createConverter(simulation);
-    auto roi_data
-        = UnitConverterUtils::createOutputData(*converter.get(), converter->defaultUnits());
+    auto roi_data =
+        UnitConverterUtils::createOutputData(*converter.get(), converter->defaultUnits());
 
     auto detector = simulation.getInstrument().getDetector();
 
@@ -296,7 +296,8 @@ SimulationResult IntensityDataFunctions::ConvertData(const Simulation& simulatio
             detector->iterate(
                 [&](IDetector::const_iterator it) {
                     (*roi_data)[it.roiIndex()] = data[it.roiIndex()];
-                }, /*visit_masked*/ false);
+                },
+                /*visit_masked*/ false);
         } else {
             roi_data->setRawDataVector(data.getRawDataVector());
         }
diff --git a/Core/Instrument/IsGISAXSDetector.cpp b/Core/Instrument/IsGISAXSDetector.cpp
index 15c95228090..a8777c7d064 100644
--- a/Core/Instrument/IsGISAXSDetector.cpp
+++ b/Core/Instrument/IsGISAXSDetector.cpp
@@ -16,7 +16,6 @@
 #include "BornAgainNamespace.h"
 #include "CustomBinAxis.h"
 
-
 IsGISAXSDetector::IsGISAXSDetector()
 {
     setName(BornAgain::IsGISAXSDetectorType);
@@ -29,18 +28,18 @@ IsGISAXSDetector::IsGISAXSDetector(size_t n_phi, double phi_min, double phi_max,
     setDetectorParameters(n_phi, phi_min, phi_max, n_alpha, alpha_min, alpha_max);
 }
 
-IsGISAXSDetector::IsGISAXSDetector(const IsGISAXSDetector &other)
-    : SphericalDetector(other)
+IsGISAXSDetector::IsGISAXSDetector(const IsGISAXSDetector& other) : SphericalDetector(other)
 {
     setName(BornAgain::IsGISAXSDetectorType);
 }
 
-IsGISAXSDetector *IsGISAXSDetector::clone() const
+IsGISAXSDetector* IsGISAXSDetector::clone() const
 {
     return new IsGISAXSDetector(*this);
 }
 
-std::unique_ptr<IAxis> IsGISAXSDetector::createAxis(size_t index, size_t n_bins, double min, double max) const
+std::unique_ptr<IAxis> IsGISAXSDetector::createAxis(size_t index, size_t n_bins, double min,
+                                                    double max) const
 {
     if (max <= min) {
         throw Exceptions::LogicErrorException(
diff --git a/Core/Instrument/IsGISAXSDetector.h b/Core/Instrument/IsGISAXSDetector.h
index 7ddcc18dd3f..84bf08cb996 100644
--- a/Core/Instrument/IsGISAXSDetector.h
+++ b/Core/Instrument/IsGISAXSDetector.h
@@ -24,9 +24,9 @@ class BA_CORE_API_ IsGISAXSDetector : public SphericalDetector
 {
 public:
     IsGISAXSDetector();
-    IsGISAXSDetector(size_t n_phi, double phi_min, double phi_max,
-                     size_t n_alpha, double alpha_min, double alpha_max);
-    IsGISAXSDetector(const IsGISAXSDetector &other);
+    IsGISAXSDetector(size_t n_phi, double phi_min, double phi_max, size_t n_alpha, double alpha_min,
+                     double alpha_max);
+    IsGISAXSDetector(const IsGISAXSDetector& other);
 
     IsGISAXSDetector* clone() const override;
 
@@ -34,8 +34,8 @@ public:
 
 protected:
     //! Generates an axis with correct name and default binning for given index
-    std::unique_ptr<IAxis> createAxis(size_t index, size_t n_bins,
-                                      double min, double max) const override;
+    std::unique_ptr<IAxis> createAxis(size_t index, size_t n_bins, double min,
+                                      double max) const override;
 
     //! Returns index of pixel that contains the specular wavevector.
     //! If no pixel contains this specular wavevector, the number of pixels is
diff --git a/Core/Instrument/LLData.cpp b/Core/Instrument/LLData.cpp
index 14264b53503..ceb810c64d8 100644
--- a/Core/Instrument/LLData.cpp
+++ b/Core/Instrument/LLData.cpp
@@ -14,10 +14,8 @@
 
 #include "LLData.h"
 
-template <>
-Eigen::Matrix2d LLData<Eigen::Matrix2d>::getZeroElement() const
+template <> Eigen::Matrix2d LLData<Eigen::Matrix2d>::getZeroElement() const
 {
     Eigen::Matrix2d result = Eigen::Matrix2d::Zero();
     return result;
 }
-
diff --git a/Core/Instrument/LLData.h b/Core/Instrument/LLData.h
index e8d9d9154e4..dcbd38b9836 100644
--- a/Core/Instrument/LLData.h
+++ b/Core/Instrument/LLData.h
@@ -71,8 +71,7 @@ private:
 };
 
 #ifndef SWIG
-template <>
-BA_CORE_API_ Eigen::Matrix2d LLData<Eigen::Matrix2d>::getZeroElement() const;
+template <> BA_CORE_API_ Eigen::Matrix2d LLData<Eigen::Matrix2d>::getZeroElement() const;
 #endif
 
 // Global helper functions for arithmetic
@@ -84,143 +83,130 @@ template <class T> LLData<T> operator/(const LLData<T>& left, const LLData<T>& r
 // Global helper functions for comparison
 template <class T> bool HaveSameDimensions(const LLData<T>& left, const LLData<T>& right);
 
-
-template<class T>
-inline LLData<T>::LLData(size_t rank, const int* dimensions)
-    : m_rank(0)
-    , m_dims(0)
-    , m_data_array(0)
+template <class T>
+inline LLData<T>::LLData(size_t rank, const int* dimensions) : m_rank(0), m_dims(0), m_data_array(0)
 {
     allocate(rank, dimensions);
 }
 
-template<class T>
-LLData<T>::LLData(const LLData<T>& right)
-    : m_rank(0)
-    , m_dims(0)
-    , m_data_array(0)
+template <class T> LLData<T>::LLData(const LLData<T>& right) : m_rank(0), m_dims(0), m_data_array(0)
 {
     allocate(right.getRank(), right.getDimensions());
-    for (size_t i=0; i<getTotalSize(); ++i) {
+    for (size_t i = 0; i < getTotalSize(); ++i) {
         m_data_array[i] = right[i];
     }
 }
 
-template<class T>
-LLData<T>::~LLData()
+template <class T> LLData<T>::~LLData()
 {
     clear();
 }
 
-template<class T> LLData<T>& LLData<T>::operator=(const LLData<T>& right)
+template <class T> LLData<T>& LLData<T>::operator=(const LLData<T>& right)
 {
-    if( this !=& right) {
+    if (this != &right) {
         LLData<T> copy(right);
         swapContents(copy);
     }
     return *this;
 }
 
-template<class T>
-inline T& LLData<T>::operator[](size_t i)
+template <class T> inline T& LLData<T>::operator[](size_t i)
 {
     return m_data_array[i];
 }
 
-template<class T>
-inline const T& LLData<T>::operator[](size_t i) const
+template <class T> inline const T& LLData<T>::operator[](size_t i) const
 {
     return m_data_array[i];
 }
 
-template<class T>
-inline T& LLData<T>::atCoordinate(int* coordinate)
+template <class T> inline T& LLData<T>::atCoordinate(int* coordinate)
 {
     return m_data_array[convertCoordinate(coordinate)];
 }
 
-template<class T>
-inline const T& LLData<T>::atCoordinate(int* coordinate) const
+template <class T> inline const T& LLData<T>::atCoordinate(int* coordinate) const
 {
     return m_data_array[convertCoordinate(coordinate)];
 }
 
-template<class T> LLData<T>& LLData<T>::operator+=(const LLData<T>& right)
+template <class T> LLData<T>& LLData<T>::operator+=(const LLData<T>& right)
 {
     if (!HaveSameDimensions(*this, right))
         throw Exceptions::RuntimeErrorException(
             "Operation += on LLData requires both operands to have the same dimensions");
-    for (size_t i=0; i<getTotalSize(); ++i) {
+    for (size_t i = 0; i < getTotalSize(); ++i) {
         m_data_array[i] += right[i];
     }
     return *this;
 }
 
-template<class T> LLData<T>& LLData<T>::operator-=(const LLData& right)
+template <class T> LLData<T>& LLData<T>::operator-=(const LLData& right)
 {
     if (!HaveSameDimensions(*this, right))
         throw Exceptions::RuntimeErrorException(
             "Operation -= on LLData requires both operands to have the same dimensions");
-    for (size_t i=0; i<getTotalSize(); ++i) {
+    for (size_t i = 0; i < getTotalSize(); ++i) {
         m_data_array[i] -= right[i];
     }
     return *this;
 }
 
-template<class T> LLData<T>& LLData<T>::operator*=(const LLData& right)
+template <class T> LLData<T>& LLData<T>::operator*=(const LLData& right)
 {
     if (!HaveSameDimensions(*this, right))
         throw Exceptions::RuntimeErrorException(
             "Operation *= on LLData requires both operands to have the same dimensions");
-    for (size_t i=0; i<getTotalSize(); ++i) {
+    for (size_t i = 0; i < getTotalSize(); ++i) {
         m_data_array[i] *= right[i];
     }
     return *this;
 }
 
-template<class T> LLData<T>& LLData<T>::operator/=(const LLData& right)
+template <class T> LLData<T>& LLData<T>::operator/=(const LLData& right)
 {
     if (!HaveSameDimensions(*this, right))
         throw Exceptions::RuntimeErrorException(
             "Operation /= on LLData requires both operands to have the same dimensions");
-    for (size_t i=0; i<getTotalSize(); ++i) {
+    for (size_t i = 0; i < getTotalSize(); ++i) {
         double ratio;
-        if( std::abs(m_data_array[i]-right[i]) <=
-            std::numeric_limits<double>::epsilon()*std::abs(right[i])) {
+        if (std::abs(m_data_array[i] - right[i])
+            <= std::numeric_limits<double>::epsilon() * std::abs(right[i])) {
             ratio = 1.0;
         } else if (std::abs(right[i]) <= std::numeric_limits<double>::min()) {
-            ratio = double(m_data_array[i])/std::numeric_limits<double>::min();
+            ratio = double(m_data_array[i]) / std::numeric_limits<double>::min();
         } else {
-            ratio = double(m_data_array[i]/right[i]);
+            ratio = double(m_data_array[i] / right[i]);
         }
         m_data_array[i] = (T)ratio;
     }
     return *this;
 }
 
-template<class T> void LLData<T>::setAll(const T& value)
+template <class T> void LLData<T>::setAll(const T& value)
 {
     std::fill(m_data_array, m_data_array + getTotalSize(), value);
 }
 
-template<class T> void LLData<T>::scaleAll(const T& factor)
+template <class T> void LLData<T>::scaleAll(const T& factor)
 {
     std::transform(m_data_array, m_data_array + getTotalSize(), m_data_array,
-            [&factor](const T& value) -> T { return value*factor; });
+                   [&factor](const T& value) -> T { return value * factor; });
 }
 
-template<class T> inline size_t LLData<T>::getTotalSize() const
+template <class T> inline size_t LLData<T>::getTotalSize() const
 {
     int result = std::accumulate(m_dims, m_dims + m_rank, 1, std::multiplies<int>{});
     return static_cast<size_t>(result);
 }
 
-template<class T> T LLData<T>::getTotalSum() const
+template <class T> T LLData<T>::getTotalSum() const
 {
     return std::accumulate(m_data_array, m_data_array + getTotalSize(), getZeroElement());
 }
 
-template<class T> void LLData<T>::allocate(size_t rank, const int* dimensions)
+template <class T> void LLData<T>::allocate(size_t rank, const int* dimensions)
 {
     clear();
     if (!checkDimensions(rank, dimensions)) {
@@ -231,15 +217,14 @@ template<class T> void LLData<T>::allocate(size_t rank, const int* dimensions)
         m_dims = new int[m_rank];
         std::copy(dimensions, dimensions + rank, m_dims);
         m_data_array = new T[getTotalSize()];
-    }
-    else {
+    } else {
         m_data_array = new T[1];
     }
 }
 
-template<class T> void LLData<T>::clear()
+template <class T> void LLData<T>::clear()
 {
-    if (m_rank>0) {
+    if (m_rank > 0) {
         m_rank = 0;
         delete[] m_data_array;
         delete[] m_dims;
@@ -250,72 +235,71 @@ template<class T> void LLData<T>::clear()
     }
 }
 
-template<class T> inline
-bool LLData<T>::checkDimensions(size_t rank, const int* dimensions) const
+template <class T> inline bool LLData<T>::checkDimensions(size_t rank, const int* dimensions) const
 {
     return std::all_of(dimensions, dimensions + rank,
                        [](const int& dim) -> bool { return dim > 0; });
 }
 
-template<class T> inline size_t LLData<T>::convertCoordinate(int* coordinate) const
+template <class T> inline size_t LLData<T>::convertCoordinate(int* coordinate) const
 {
     size_t offset = 1;
     size_t result = 0;
-    for (size_t i = m_rank; i>0; --i) {
-        result += offset*coordinate[i-1];
-        offset *= m_dims[i-1];
+    for (size_t i = m_rank; i > 0; --i) {
+        result += offset * coordinate[i - 1];
+        offset *= m_dims[i - 1];
     }
     return result;
 }
 
-template<class T> void LLData<T>::swapContents(LLData<T>& other)
+template <class T> void LLData<T>::swapContents(LLData<T>& other)
 {
     std::swap(this->m_rank, other.m_rank);
     std::swap(this->m_dims, other.m_dims);
     std::swap(this->m_data_array, other.m_data_array);
 }
 
-template<class T> T LLData<T>::getZeroElement() const
+template <class T> T LLData<T>::getZeroElement() const
 {
     T result = 0;
     return result;
 }
 
-template<class T> LLData<T> operator+(const LLData<T>& left, const LLData<T>& right)
+template <class T> LLData<T> operator+(const LLData<T>& left, const LLData<T>& right)
 {
-    LLData<T> *p_result = new LLData<T>(left);
+    LLData<T>* p_result = new LLData<T>(left);
     (*p_result) += right;
     return *p_result;
 }
 
-template<class T> LLData<T> operator-(const LLData<T>& left, const LLData<T>& right)
+template <class T> LLData<T> operator-(const LLData<T>& left, const LLData<T>& right)
 {
-    LLData<T> *p_result = new LLData<T>(left);
+    LLData<T>* p_result = new LLData<T>(left);
     (*p_result) -= right;
     return *p_result;
 }
 
-template<class T> LLData<T> operator*(const LLData<T>& left, const LLData<T>& right)
+template <class T> LLData<T> operator*(const LLData<T>& left, const LLData<T>& right)
 {
-    LLData<T> *p_result = new LLData<T>(left);
+    LLData<T>* p_result = new LLData<T>(left);
     (*p_result) *= right;
     return *p_result;
 }
 
-template<class T> LLData<T> operator/(const LLData<T>& left, const LLData<T>& right)
+template <class T> LLData<T> operator/(const LLData<T>& left, const LLData<T>& right)
 {
-    LLData<T> *p_result = new LLData<T>(left);
+    LLData<T>* p_result = new LLData<T>(left);
     *p_result /= right;
     return *p_result;
 }
 
-template<class T> bool HaveSameDimensions(const LLData<T>& left, const LLData<T>& right)
+template <class T> bool HaveSameDimensions(const LLData<T>& left, const LLData<T>& right)
 {
     if (left.getRank() != right.getRank())
         return false;
     const int* ldims = left.getDimensions();
     const int* rdims = right.getDimensions();
-    for (size_t i=0; i<left.getRank(); ++i) {
+    for (size_t i = 0; i < left.getRank(); ++i) {
         if (ldims[i] != rdims[i])
             return false;
     }
diff --git a/Core/Instrument/OutputData.cpp b/Core/Instrument/OutputData.cpp
index 96ccbfb31bc..48aa07dea28 100644
--- a/Core/Instrument/OutputData.cpp
+++ b/Core/Instrument/OutputData.cpp
@@ -14,15 +14,14 @@
 
 #ifdef BORNAGAIN_PYTHON
 
-#include "CumulativeValue.h"
 #include "OutputData.h"
+#include "CumulativeValue.h"
 #include "PythonCore.h"
 
-template<>
-PyObject* OutputData<double>::getArray() const
+template <> PyObject* OutputData<double>::getArray() const
 {
-    std::vector<size_t > dimensions;
-    for (size_t i=0; i<getRank(); i++)
+    std::vector<size_t> dimensions;
+    for (size_t i = 0; i < getRank(); i++)
         dimensions.push_back(getAxis(i).size());
 
     // for rot90 of 2-dim arrays to conform with numpy
@@ -30,45 +29,44 @@ PyObject* OutputData<double>::getArray() const
         std::swap(dimensions[0], dimensions[1]);
 
     // creating ndarray objects describing size of dimensions
-    npy_int ndim_numpy= (int)dimensions.size();
+    npy_int ndim_numpy = (int)dimensions.size();
     npy_intp* ndimsizes_numpy = new npy_intp[dimensions.size()];
-    for (size_t i=0; i<dimensions.size(); i++)
+    for (size_t i = 0; i < dimensions.size(); i++)
         ndimsizes_numpy[i] = dimensions[i];
 
     // creating standalone numpy array
     PyObject* pyarray = PyArray_SimpleNew(ndim_numpy, ndimsizes_numpy, NPY_DOUBLE);
-    delete [] ndimsizes_numpy;
+    delete[] ndimsizes_numpy;
     if (pyarray == nullptr)
         throw Exceptions::RuntimeErrorException("ExportOutputData() -> Panic in PyArray_SimpleNew");
 
     // getting pointer to data buffer of numpy array
-    double* array_buffer = (double *)PyArray_DATA((PyArrayObject*)pyarray);
+    double* array_buffer = (double*)PyArray_DATA((PyArrayObject*)pyarray);
 
     // filling numpy array with output_data
     if (getRank() == 2) {
-        for (size_t index=0; index<getAllocatedSize(); ++index) {
+        for (size_t index = 0; index < getAllocatedSize(); ++index) {
             std::vector<int> axes_indices = getAxesBinIndices(index);
-            size_t offset = axes_indices[0] +
-                m_value_axes[0]->size()*(m_value_axes[1]->size() - 1 - axes_indices[1]);
+            size_t offset =
+                axes_indices[0]
+                + m_value_axes[0]->size() * (m_value_axes[1]->size() - 1 - axes_indices[1]);
             array_buffer[offset] = (*this)[index];
         }
 
     } else {
-        for (size_t index=0; index<getAllocatedSize(); ++index)
+        for (size_t index = 0; index < getAllocatedSize(); ++index)
             *array_buffer++ = (*this)[index];
     }
 
     return pyarray;
 }
 
-template<>
-double OutputData<double>::getValue(size_t index) const
+template <> double OutputData<double>::getValue(size_t index) const
 {
     return (*this)[index];
 }
 
-template<>
-double OutputData<CumulativeValue>::getValue(size_t index) const
+template <> double OutputData<CumulativeValue>::getValue(size_t index) const
 {
     return (*this)[index].getContent();
 }
diff --git a/Core/Instrument/OutputData.h b/Core/Instrument/OutputData.h
index 03a11e5f970..3b35786d423 100644
--- a/Core/Instrument/OutputData.h
+++ b/Core/Instrument/OutputData.h
@@ -18,19 +18,18 @@
 #include "FixedBinAxis.h"
 #include "LLData.h"
 #include "OutputDataIterator.h"
+#include "PyObject.h"
 #include "SafePointerVector.h"
 #include "ThreadInfo.h"
-#include "PyObject.h"
-#include <sstream>
 #include <cassert>
+#include <sstream>
 
 using std::size_t;
 
 //! Template class to store data of any type in multi-dimensional space.
 //! @ingroup tools
 
-template <class T>
-class OutputData
+template <class T> class OutputData
 {
 public:
     using value_type = T;
@@ -59,8 +58,9 @@ public:
     //! Returns number of dimensions.
     size_t getRank() const { return m_value_axes.size(); }
 
-   //! Returns total size of data buffer (product of bin number in every dimension).
-    size_t getAllocatedSize() const {
+    //! Returns total size of data buffer (product of bin number in every dimension).
+    size_t getAllocatedSize() const
+    {
         if (mp_ll_data)
             return mp_ll_data->getTotalSize();
         return 0;
@@ -96,9 +96,7 @@ public:
     iterator end() { return iterator(this, getAllocatedSize()); }
 
     //! Returns  read-only iterator that points to the one past last element
-    const_iterator end() const {
-        return const_iterator(this, getAllocatedSize());
-    }
+    const_iterator end() const { return const_iterator(this, getAllocatedSize()); }
 
     // coordinate and index functions
 
@@ -117,17 +115,17 @@ public:
     //! @param global_index The global index of this data structure.
     //! @param axis_name The name of selected axis.
     //! @return Corresponding bin index for selected axis
-    size_t getAxisBinIndex(size_t global_index, const std::string &axis_name) const;
+    size_t getAxisBinIndex(size_t global_index, const std::string& axis_name) const;
 
     //! Returns global index for specified indices of axes
     //! @param axes_indices Vector of axes indices for all specified axes in this dataset
     //! @return Corresponding global index
-    size_t toGlobalIndex(const std::vector<unsigned> &axes_indices) const;
+    size_t toGlobalIndex(const std::vector<unsigned>& axes_indices) const;
 
     //! Returns global index for specified axes values
     //! @param coordinates Vector of axes coordinates for all specified axes in this dataset
     //! @return Closest global index
-    size_t findGlobalIndex(const std::vector<double> &coordinates) const;
+    size_t findGlobalIndex(const std::vector<double>& coordinates) const;
 
     //! Returns the value of selected axis for given global_index.
     //! @param global_index The global index of this data structure.
@@ -144,7 +142,7 @@ public:
     //! Returns values on all defined axes for given globalbin number
     //! @param global_index The global index of this data structure.
     //! @return Vector of corresponding bin centers
-    std::vector<double > getAxesValues(size_t global_index) const;
+    std::vector<double> getAxesValues(size_t global_index) const;
 
     //! Returns bin of selected axis for given global_index.
     //! @param global_index The global index of this data structure.
@@ -194,13 +192,15 @@ public:
     double getValue(size_t index) const;
 
     //! indexed accessor
-    T& operator[](size_t index) {
+    T& operator[](size_t index)
+    {
         assert(mp_ll_data);
         return (*mp_ll_data)[index];
     }
 
     //! indexed accessor (const)
-    const T& operator[](size_t index) const {
+    const T& operator[](size_t index) const
+    {
         assert(mp_ll_data);
         return (*mp_ll_data)[index];
     }
@@ -239,21 +239,18 @@ private:
 // Implementation
 // --------------------------------------------------------------------- //
 
-template <class T>
-OutputData<T>::OutputData()
-    : m_value_axes()
-    , mp_ll_data(nullptr)
+template <class T> OutputData<T>::OutputData() : m_value_axes(), mp_ll_data(nullptr)
 {
     allocate();
 }
 
-template <class T> OutputData<T>::~OutputData() {
+template <class T> OutputData<T>::~OutputData()
+{
     clear();
     delete mp_ll_data;
 }
 
-template <class T>
-OutputData<T>* OutputData<T>::clone() const
+template <class T> OutputData<T>* OutputData<T>::clone() const
 {
     OutputData<T>* ret = new OutputData<T>();
     ret->m_value_axes = m_value_axes;
@@ -261,47 +258,42 @@ OutputData<T>* OutputData<T>::clone() const
     return ret;
 }
 
-template <class T>
-void OutputData<T>::copyFrom(const OutputData<T>& other)
+template <class T> void OutputData<T>::copyFrom(const OutputData<T>& other)
 {
     clear();
     m_value_axes = other.m_value_axes;
     delete mp_ll_data;
     mp_ll_data = 0;
-    if(other.mp_ll_data)
+    if (other.mp_ll_data)
         mp_ll_data = new LLData<T>(*other.mp_ll_data);
 }
 
-template <class T>
-template <class U>
-void OutputData<T>::copyShapeFrom(const OutputData<U>& other)
+template <class T> template <class U> void OutputData<T>::copyShapeFrom(const OutputData<U>& other)
 {
     clear();
     size_t rank = other.getRank();
-    for (size_t i=0; i<rank; ++i)
+    for (size_t i = 0; i < rank; ++i)
         addAxis(other.getAxis(i));
 }
 
-template <class T>
-OutputData<double>* OutputData<T>::meanValues() const
+template <class T> OutputData<double>* OutputData<T>::meanValues() const
 {
     auto ret = new OutputData<double>();
     ret->copyShapeFrom(*this);
     ret->allocate();
-    for (size_t i=0; i<mp_ll_data->getTotalSize(); ++i)
+    for (size_t i = 0; i < mp_ll_data->getTotalSize(); ++i)
         (*ret)[i] = getValue(i);
     return ret;
 }
 
-template <class T>
-void OutputData<T>::addAxis(const IAxis& new_axis)
+template <class T> void OutputData<T>::addAxis(const IAxis& new_axis)
 {
-    if( axisNameExists(new_axis.getName()) )
+    if (axisNameExists(new_axis.getName()))
         throw Exceptions::LogicErrorException(
             "OutputData<T>::addAxis(const IAxis& new_axis) -> "
-            "Error! Attempt to add axis with already existing name '" +
-            new_axis.getName() + "'");
-    if (new_axis.size()>0) {
+            "Error! Attempt to add axis with already existing name '"
+            + new_axis.getName() + "'");
+    if (new_axis.size() > 0) {
         m_value_axes.push_back(new_axis.clone());
         allocate();
     }
@@ -310,102 +302,95 @@ void OutputData<T>::addAxis(const IAxis& new_axis)
 template <class T>
 void OutputData<T>::addAxis(const std::string& name, size_t size, double start, double end)
 {
-    if( axisNameExists(name) )
+    if (axisNameExists(name))
         throw Exceptions::LogicErrorException(
             "OutputData<T>::addAxis(std::string name) -> "
-            "Error! Attempt to add axis with already existing name '" +
-            name+"'");
+            "Error! Attempt to add axis with already existing name '"
+            + name + "'");
     FixedBinAxis new_axis(name, size, start, end);
     addAxis(new_axis);
 }
 
-template <class T>
-const IAxis& OutputData<T>::getAxis(size_t serial_number) const
+template <class T> const IAxis& OutputData<T>::getAxis(size_t serial_number) const
 {
     return *m_value_axes[serial_number];
 }
 
-template <class T>
-const IAxis& OutputData<T>::getAxis(const std::string& axis_name) const
+template <class T> const IAxis& OutputData<T>::getAxis(const std::string& axis_name) const
 {
     return getAxis(getAxisIndex(axis_name));
 }
 
-template<class T>
-inline std::vector<size_t> OutputData<T>::getAllSizes() const
+template <class T> inline std::vector<size_t> OutputData<T>::getAllSizes() const
 {
     assert(mp_ll_data);
     std::vector<size_t> result;
-    for (size_t i=0; i<getRank(); ++i) {
+    for (size_t i = 0; i < getRank(); ++i) {
         int dim = mp_ll_data->getDimensions()[i];
         result.push_back(dim);
     }
     return result;
 }
 
-template <class T>
-inline std::vector<T> OutputData<T>::getRawDataVector() const
+template <class T> inline std::vector<T> OutputData<T>::getRawDataVector() const
 {
     assert(mp_ll_data);
     std::vector<T> result;
-    for (size_t i=0; i<getAllocatedSize(); ++i)
+    for (size_t i = 0; i < getAllocatedSize(); ++i)
         result.push_back((*mp_ll_data)[i]);
     return result;
 }
 
-template <class T>
-typename OutputData<T>::iterator OutputData<T>::begin()
+template <class T> typename OutputData<T>::iterator OutputData<T>::begin()
 {
     typename OutputData<T>::iterator result(this);
     return result;
 }
 
-template <class T>
-typename OutputData<T>::const_iterator OutputData<T>::begin() const
+template <class T> typename OutputData<T>::const_iterator OutputData<T>::begin() const
 {
     typename OutputData<T>::const_iterator result(this);
     return result;
 }
 
-template<class T>
-std::vector<int> OutputData<T>::getAxesBinIndices(size_t global_index) const
+template <class T> std::vector<int> OutputData<T>::getAxesBinIndices(size_t global_index) const
 {
     assert(mp_ll_data);
     size_t remainder = global_index;
     std::vector<int> result;
     result.resize(mp_ll_data->getRank());
-    for (size_t i=0; i<mp_ll_data->getRank(); ++i) {
-        result[mp_ll_data->getRank()-1-i] =
-            (int)(remainder % m_value_axes[mp_ll_data->getRank()-1-i]->size());
-        remainder /= m_value_axes[mp_ll_data->getRank()-1-i]->size();
+    for (size_t i = 0; i < mp_ll_data->getRank(); ++i) {
+        result[mp_ll_data->getRank() - 1 - i] =
+            (int)(remainder % m_value_axes[mp_ll_data->getRank() - 1 - i]->size());
+        remainder /= m_value_axes[mp_ll_data->getRank() - 1 - i]->size();
     }
     return result;
 }
 
-template<class T>
+template <class T>
 size_t OutputData<T>::getAxisBinIndex(size_t global_index, size_t i_selected_axis) const
 {
     assert(mp_ll_data);
     size_t remainder(global_index);
-    for (size_t i=0; i<mp_ll_data->getRank(); ++i) {
-        size_t i_axis = mp_ll_data->getRank()-1-i;
+    for (size_t i = 0; i < mp_ll_data->getRank(); ++i) {
+        size_t i_axis = mp_ll_data->getRank() - 1 - i;
         size_t result = remainder % m_value_axes[i_axis]->size();
-        if(i_selected_axis == i_axis ) return result;
+        if (i_selected_axis == i_axis)
+            return result;
         remainder /= m_value_axes[i_axis]->size();
     }
     throw Exceptions::LogicErrorException("OutputData<T>::getAxisBinIndex() -> "
                                           "Error! No axis with given number");
 }
 
-
-template<class T>
-size_t OutputData<T>::getAxisBinIndex(size_t global_index, const std::string &axis_name) const
+template <class T>
+size_t OutputData<T>::getAxisBinIndex(size_t global_index, const std::string& axis_name) const
 {
     return getAxisBinIndex(global_index, getAxisIndex(axis_name));
 }
 
 template <class T>
-size_t OutputData<T>::toGlobalIndex(const std::vector<unsigned> &axes_indices) const
+size_t OutputData<T>::toGlobalIndex(const std::vector<unsigned>& axes_indices) const
 {
     assert(mp_ll_data);
     if (axes_indices.size() != mp_ll_data->getRank())
@@ -414,23 +399,23 @@ size_t OutputData<T>::toGlobalIndex(const std::vector<unsigned> &axes_indices) c
             "Error! Number of coordinates must match rank of data structure");
     size_t result = 0;
     size_t step_size = 1;
-    for (size_t i=mp_ll_data->getRank(); i>0; --i) {
-        if(axes_indices[i-1] >= m_value_axes[i-1]->size()) {
+    for (size_t i = mp_ll_data->getRank(); i > 0; --i) {
+        if (axes_indices[i - 1] >= m_value_axes[i - 1]->size()) {
             std::ostringstream message;
             message << "size_t OutputData<T>::toGlobalIndex() -> Error. Index ";
-            message << axes_indices[i-1] << " is out of range. Axis ";
-            message << m_value_axes[i-1]->getName();
-            message << " size " << m_value_axes[i-1]->size() << ".\n";
+            message << axes_indices[i - 1] << " is out of range. Axis ";
+            message << m_value_axes[i - 1]->getName();
+            message << " size " << m_value_axes[i - 1]->size() << ".\n";
             throw Exceptions::LogicErrorException(message.str());
         }
-        result += axes_indices[i-1]*step_size;
-        step_size *= m_value_axes[i-1]->size();
+        result += axes_indices[i - 1] * step_size;
+        step_size *= m_value_axes[i - 1]->size();
     }
     return result;
 }
 
 template <class T>
-size_t OutputData<T>::findGlobalIndex(const std::vector<double> &coordinates) const
+size_t OutputData<T>::findGlobalIndex(const std::vector<double>& coordinates) const
 {
     assert(mp_ll_data);
     if (coordinates.size() != mp_ll_data->getRank())
@@ -439,7 +424,7 @@ size_t OutputData<T>::findGlobalIndex(const std::vector<double> &coordinates) co
             "Error! Number of coordinates must match rank of data structure");
     std::vector<unsigned> axes_indexes;
     axes_indexes.resize(mp_ll_data->getRank());
-    for(size_t i = 0; i<mp_ll_data->getRank(); ++i)
+    for (size_t i = 0; i < mp_ll_data->getRank(); ++i)
         axes_indexes[i] = static_cast<unsigned>(m_value_axes[i]->findClosestIndex(coordinates[i]));
     return toGlobalIndex(axes_indexes);
 }
@@ -457,12 +442,11 @@ double OutputData<T>::getAxisValue(size_t global_index, const std::string& axis_
     return getAxisValue(global_index, getAxisIndex(axis_name));
 }
 
-template <class T>
-std::vector<double> OutputData<T>::getAxesValues(size_t global_index) const
+template <class T> std::vector<double> OutputData<T>::getAxesValues(size_t global_index) const
 {
     std::vector<int> indices = getAxesBinIndices(global_index);
-    std::vector<double > result;
-    for(size_t i_axis=0; i_axis<indices.size(); ++i_axis)
+    std::vector<double> result;
+    for (size_t i_axis = 0; i_axis < indices.size(); ++i_axis)
         result.push_back((*m_value_axes[i_axis])[indices[i_axis]]);
     return result;
 }
@@ -480,98 +464,90 @@ Bin1D OutputData<T>::getAxisBin(size_t global_index, const std::string& axis_nam
     return getAxisBin(global_index, getAxisIndex(axis_name));
 }
 
-template<class T>
-inline T OutputData<T>::totalSum() const
+template <class T> inline T OutputData<T>::totalSum() const
 {
     assert(mp_ll_data);
     return mp_ll_data->getTotalSum();
 }
 
-template <class T>
-void OutputData<T>::clear()
+template <class T> void OutputData<T>::clear()
 {
     m_value_axes.clear();
     allocate();
 }
 
-template <class T>
-void OutputData<T>::setAllTo(const T& value)
+template <class T> void OutputData<T>::setAllTo(const T& value)
 {
-    if(!mp_ll_data)
+    if (!mp_ll_data)
         throw Exceptions::ClassInitializationException(
             "OutputData::setAllTo() -> Error! Low-level data object was not yet initialized.");
     mp_ll_data->setAll(value);
 }
 
-template <class T>
-void OutputData<T>::scaleAll(const T& factor)
+template <class T> void OutputData<T>::scaleAll(const T& factor)
 {
-    if(!mp_ll_data)
+    if (!mp_ll_data)
         throw Exceptions::ClassInitializationException(
             "OutputData::scaleAll() -> Error! Low-level data object was not yet initialized.");
     mp_ll_data->scaleAll(factor);
 }
 
-template <class T>
-void OutputData<T>::setAxisSizes(size_t rank, int* n_dims)
+template <class T> void OutputData<T>::setAxisSizes(size_t rank, int* n_dims)
 {
     clear();
     std::string basename("axis");
-    for (size_t i=0; i<rank; ++i) {
+    for (size_t i = 0; i < rank; ++i) {
         std::ostringstream name;
         name << basename << i;
-        addAxis(name.str(), n_dims[i], 0.0, (double)(n_dims[i]-1));
+        addAxis(name.str(), n_dims[i], 0.0, (double)(n_dims[i] - 1));
     }
 }
 
-template<class T>
-const OutputData<T>& OutputData<T>::operator+=(const OutputData<T>& right)
+template <class T> const OutputData<T>& OutputData<T>::operator+=(const OutputData<T>& right)
 {
     assert(mp_ll_data);
     *this->mp_ll_data += *right.mp_ll_data;
     return *this;
 }
 
-template<class T>
-const OutputData<T>& OutputData<T>::operator-=(const OutputData<T>& right)
+template <class T> const OutputData<T>& OutputData<T>::operator-=(const OutputData<T>& right)
 {
     assert(mp_ll_data);
     *this->mp_ll_data -= *right.mp_ll_data;
     return *this;
 }
 
-template<class T>
-const OutputData<T>& OutputData<T>::operator*=(const OutputData<T>& right)
+template <class T> const OutputData<T>& OutputData<T>::operator*=(const OutputData<T>& right)
 {
     assert(mp_ll_data);
     *this->mp_ll_data *= *right.mp_ll_data;
     return *this;
 }
 
-template<class T>
-bool OutputData<T>::isInitialized() const
+template <class T> bool OutputData<T>::isInitialized() const
 {
-    if(!mp_ll_data) return false;
-    if(getRank() != mp_ll_data->getRank()) return false;
-    if(!getRank()) return false;
+    if (!mp_ll_data)
+        return false;
+    if (getRank() != mp_ll_data->getRank())
+        return false;
+    if (!getRank())
+        return false;
     return true;
 }
 
-template<class T>
-const OutputData<T>& OutputData<T>::operator/=(const OutputData<T>& right)
+template <class T> const OutputData<T>& OutputData<T>::operator/=(const OutputData<T>& right)
 {
     assert(mp_ll_data);
     *this->mp_ll_data /= *right.mp_ll_data;
     return *this;
 }
 
-template <class T>
-void OutputData<T>::allocate()
+template <class T> void OutputData<T>::allocate()
 {
     delete mp_ll_data;
     size_t rank = m_value_axes.size();
-    int* dims =  new int[rank];
-    for (size_t i=0; i<rank; ++i) {
+    int* dims = new int[rank];
+    for (size_t i = 0; i < rank; ++i) {
         dims[i] = (int)getAxis(i).size();
     }
     mp_ll_data = new LLData<T>(rank, dims);
@@ -580,71 +556,74 @@ void OutputData<T>::allocate()
     delete[] dims;
 }
 
-template<class T>
-inline void OutputData<T>::setRawDataVector(const std::vector<T>& data_vector)
+template <class T> inline void OutputData<T>::setRawDataVector(const std::vector<T>& data_vector)
 {
     if (data_vector.size() != getAllocatedSize())
         throw Exceptions::RuntimeErrorException(
             "OutputData<T>::setRawDataVector() -> Error! "
-            "setRawDataVector can only be called with a data vector of the correct size." );
-    for (size_t i=0; i<getAllocatedSize(); ++i)
+            "setRawDataVector can only be called with a data vector of the correct size.");
+    for (size_t i = 0; i < getAllocatedSize(); ++i)
         (*mp_ll_data)[i] = data_vector[i];
 }
 
-template<class T>
-inline void OutputData<T>::setRawDataArray(const T* source)
+template <class T> inline void OutputData<T>::setRawDataArray(const T* source)
 {
-    for (size_t i=0; i<getAllocatedSize(); ++i)
+    for (size_t i = 0; i < getAllocatedSize(); ++i)
         (*mp_ll_data)[i] = source[i];
 }
 
 //! Returns true if object have same dimensions
-template<class T>
-template<class U>
+template <class T>
+template <class U>
 inline bool OutputData<T>::hasSameDimensions(const OutputData<U>& right) const
 {
-    if (!isInitialized()) return false;
-    if (!right.isInitialized()) return false;
-    if (getRank() != right.getRank()) return false;
-    for (size_t i_axis=0; i_axis<getRank(); ++i_axis)
-        if (getAxis(i_axis).size() != right.getAxis(i_axis).size()) return false;
+    if (!isInitialized())
+        return false;
+    if (!right.isInitialized())
+        return false;
+    if (getRank() != right.getRank())
+        return false;
+    for (size_t i_axis = 0; i_axis < getRank(); ++i_axis)
+        if (getAxis(i_axis).size() != right.getAxis(i_axis).size())
+            return false;
     return true;
 }
 
 //! Returns true if object have same dimensions and shape of axis
-template<class T>
-template<class U>
+template <class T>
+template <class U>
 bool OutputData<T>::hasSameShape(const OutputData<U>& right) const
 {
-    if (!hasSameDimensions(right)) return false;
+    if (!hasSameDimensions(right))
+        return false;
 
-    for (size_t i=0; i<m_value_axes.size(); ++i)
-        if (!HaveSameNameAndShape(getAxis(i), right.getAxis(i))) return false;
+    for (size_t i = 0; i < m_value_axes.size(); ++i)
+        if (!HaveSameNameAndShape(getAxis(i), right.getAxis(i)))
+            return false;
     return true;
 }
 
 //! returns data as Python numpy array
 #ifdef BORNAGAIN_PYTHON
-template<>
-PyObject* OutputData<double>::getArray() const;
+template <> PyObject* OutputData<double>::getArray() const;
 #endif
 
 // return index of axis
-template <class T>
-size_t OutputData<T>::getAxisIndex(const std::string &axis_name) const
+template <class T> size_t OutputData<T>::getAxisIndex(const std::string& axis_name) const
 {
     for (size_t i = 0; i < m_value_axes.size(); ++i)
-        if (m_value_axes[i]->getName() == axis_name) return i;
-    throw Exceptions::LogicErrorException(
-        "OutputData<T>::getAxisIndex() -> "
-        "Error! Axis with given name not found '"+axis_name+std::string("'"));
+        if (m_value_axes[i]->getName() == axis_name)
+            return i;
+    throw Exceptions::LogicErrorException("OutputData<T>::getAxisIndex() -> "
+                                          "Error! Axis with given name not found '"
+                                          + axis_name + std::string("'"));
 }
 
-template <class T>
-bool OutputData<T>::axisNameExists(const std::string &axis_name) const
+template <class T> bool OutputData<T>::axisNameExists(const std::string& axis_name) const
 {
     for (size_t i = 0; i < m_value_axes.size(); ++i)
-        if (m_value_axes[i]->getName() == axis_name) return true;
+        if (m_value_axes[i]->getName() == axis_name)
+            return true;
     return false;
 }
 
diff --git a/Core/Instrument/OutputDataIterator.h b/Core/Instrument/OutputDataIterator.h
index 58cf44857b2..9dafb76b1bc 100644
--- a/Core/Instrument/OutputDataIterator.h
+++ b/Core/Instrument/OutputDataIterator.h
@@ -22,7 +22,8 @@
 //! Iterator for underlying OutputData container.
 //! @ingroup tools_internal
 
-template <class TValue, class TContainer> class OutputDataIterator {
+template <class TValue, class TContainer> class OutputDataIterator
+{
 public:
     //! Empty constructor to comply with stl forward iterators
     OutputDataIterator();
@@ -88,7 +89,8 @@ private:
 //! make Swappable
 template <class TValue, class TContainer>
 void swap(OutputDataIterator<TValue, TContainer>& left,
-          OutputDataIterator<TValue, TContainer>& right) {
+          OutputDataIterator<TValue, TContainer>& right)
+{
     left.swap(right);
 }
 
@@ -103,19 +105,23 @@ bool operator!=(const OutputDataIterator<TValue1, TContainer1>& left,
                 const OutputDataIterator<TValue2, TContainer2>& right);
 
 template <class TValue, class TContainer>
-OutputDataIterator<TValue, TContainer>::OutputDataIterator()
-    : m_current_index(0), mp_output_data(0) {}
+OutputDataIterator<TValue, TContainer>::OutputDataIterator() : m_current_index(0), mp_output_data(0)
+{
+}
 
 template <class TValue, class TContainer>
-OutputDataIterator<TValue, TContainer>::OutputDataIterator(
-    TContainer* p_output_data, size_t start_at_index)
-    : m_current_index(start_at_index), mp_output_data(p_output_data) {}
+OutputDataIterator<TValue, TContainer>::OutputDataIterator(TContainer* p_output_data,
+                                                           size_t start_at_index)
+    : m_current_index(start_at_index), mp_output_data(p_output_data)
+{
+}
 
 template <class TValue, class TContainer>
 template <class TValue2, class TContainer2>
 OutputDataIterator<TValue, TContainer>::OutputDataIterator(
     const OutputDataIterator<TValue2, TContainer2>& other)
-    : m_current_index(0), mp_output_data(0) {
+    : m_current_index(0), mp_output_data(0)
+{
     mp_output_data = static_cast<TContainer*>(other.getContainer());
     m_current_index = other.getIndex();
 }
@@ -123,34 +129,39 @@ OutputDataIterator<TValue, TContainer>::OutputDataIterator(
 template <class TValue, class TContainer>
 OutputDataIterator<TValue, TContainer>::OutputDataIterator(
     const OutputDataIterator<TValue, TContainer>& other)
-    : m_current_index(0), mp_output_data(0) {
+    : m_current_index(0), mp_output_data(0)
+{
     mp_output_data = other.getContainer();
     m_current_index = other.getIndex();
 }
 
 template <class TValue, class TContainer>
 template <class TValue2, class TContainer2>
-OutputDataIterator<TValue, TContainer>& OutputDataIterator<TValue, TContainer>::
-operator=(const OutputDataIterator<TValue2, TContainer2>& right) {
+OutputDataIterator<TValue, TContainer>& OutputDataIterator<TValue, TContainer>::operator=(
+    const OutputDataIterator<TValue2, TContainer2>& right)
+{
     OutputDataIterator<TValue, TContainer> copy(right);
     swap(copy);
     return *this;
 }
 
 template <class TValue, class TContainer>
-OutputDataIterator<TValue, TContainer>& OutputDataIterator<TValue, TContainer>::
-operator=(const OutputDataIterator<TValue, TContainer>& right) {
+OutputDataIterator<TValue, TContainer>& OutputDataIterator<TValue, TContainer>::operator=(
+    const OutputDataIterator<TValue, TContainer>& right)
+{
     OutputDataIterator<TValue, TContainer> copy(right);
     swap(copy);
     return *this;
 }
 
 template <class TValue, class TContainer>
-OutputDataIterator<TValue, TContainer>::~OutputDataIterator() {}
+OutputDataIterator<TValue, TContainer>::~OutputDataIterator()
+{
+}
 
 template <class TValue, class TContainer>
-OutputDataIterator<TValue, TContainer>& OutputDataIterator<TValue, TContainer>::
-operator++() {
+OutputDataIterator<TValue, TContainer>& OutputDataIterator<TValue, TContainer>::operator++()
+{
     if (m_current_index < mp_output_data->getAllocatedSize()) {
         ++m_current_index;
     }
@@ -158,26 +169,28 @@ operator++() {
 }
 
 template <class TValue, class TContainer>
-OutputDataIterator<TValue, TContainer> OutputDataIterator<TValue, TContainer>::
-operator++(int /**/) {
+OutputDataIterator<TValue, TContainer> OutputDataIterator<TValue, TContainer>::operator++(int /**/)
+{
     OutputDataIterator<TValue, TContainer> result(*this);
     this->operator++();
     return result;
 }
 
 template <class TValue, class TContainer>
-TValue& OutputDataIterator<TValue, TContainer>::operator*() const {
+TValue& OutputDataIterator<TValue, TContainer>::operator*() const
+{
     return (*mp_output_data)[m_current_index];
 }
 
 template <class TValue, class TContainer>
-TValue* OutputDataIterator<TValue, TContainer>::operator->() const {
-    return& ((*mp_output_data)[m_current_index]);
+TValue* OutputDataIterator<TValue, TContainer>::operator->() const
+{
+    return &((*mp_output_data)[m_current_index]);
 }
 
 template <class TValue, class TContainer>
-void OutputDataIterator<TValue, TContainer>::swap(
-    OutputDataIterator<TValue, TContainer>& other) {
+void OutputDataIterator<TValue, TContainer>::swap(OutputDataIterator<TValue, TContainer>& other)
+{
     std::swap(this->m_current_index, other.m_current_index);
     std::swap(this->mp_output_data, other.mp_output_data);
 }
@@ -185,15 +198,16 @@ void OutputDataIterator<TValue, TContainer>::swap(
 //! test for equality
 template <class TValue1, class TContainer1, class TValue2, class TContainer2>
 bool operator==(const OutputDataIterator<TValue1, TContainer1>& left,
-                const OutputDataIterator<TValue2, TContainer2>& right) {
-    return left.getContainer() == right.getContainer() &&
-           left.getIndex() == right.getIndex();
+                const OutputDataIterator<TValue2, TContainer2>& right)
+{
+    return left.getContainer() == right.getContainer() && left.getIndex() == right.getIndex();
 }
 
 //! test for inequality
 template <class TValue1, class TContainer1, class TValue2, class TContainer2>
 bool operator!=(const OutputDataIterator<TValue1, TContainer1>& left,
-                const OutputDataIterator<TValue2, TContainer2>& right) {
+                const OutputDataIterator<TValue2, TContainer2>& right)
+{
     return !(left == right);
 }
 
diff --git a/Core/Instrument/PyArrayImportUtils.h b/Core/Instrument/PyArrayImportUtils.h
index 4c93e68194e..f74f8d79381 100644
--- a/Core/Instrument/PyArrayImportUtils.h
+++ b/Core/Instrument/PyArrayImportUtils.h
@@ -18,17 +18,19 @@
 #include "WinDllMacros.h"
 #include <vector>
 
-template<class T> class OutputData;
+template <class T> class OutputData;
 
 //! Functions for numpy array import to OutputData.
 //! Required solely as a shortcut to produce OutputData from numpy arrays of doubles.
 
-namespace PyArrayImport {
+namespace PyArrayImport
+{
 
-    //! for importing 1D array of doubles from python into OutputData
-    BA_CORE_API_ OutputData<double>* importArrayToOutputData(const std::vector<double>& vec);
-    //! for importing 2D array of doubles from python into OutputData
-    BA_CORE_API_ OutputData<double>* importArrayToOutputData(const std::vector<std::vector<double>>& vec);
+//! for importing 1D array of doubles from python into OutputData
+BA_CORE_API_ OutputData<double>* importArrayToOutputData(const std::vector<double>& vec);
+//! for importing 2D array of doubles from python into OutputData
+BA_CORE_API_ OutputData<double>*
+importArrayToOutputData(const std::vector<std::vector<double>>& vec);
 
 } // namespace PyArrayImport
 
diff --git a/Core/Instrument/QSpecScan.cpp b/Core/Instrument/QSpecScan.cpp
index 0d6842a33d7..37b95f1f5c2 100644
--- a/Core/Instrument/QSpecScan.cpp
+++ b/Core/Instrument/QSpecScan.cpp
@@ -23,30 +23,30 @@
 #include "ScanResolution.h"
 #include "SpecularSimulationElement.h"
 
-namespace {
+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)))
-    , m_resolution(ScanResolution::scanEmptyResolution())
+    : ISpecularScan(SPECULAR_DATA_TYPE::q),
+      m_qs(std::make_unique<PointwiseAxis>("qs", std::move(qs_nm))),
+      m_resolution(ScanResolution::scanEmptyResolution())
 {
     checkInitialization();
 }
 
 QSpecScan::QSpecScan(const IAxis& qs_nm)
-    : ISpecularScan(SPECULAR_DATA_TYPE::q)
-    , m_qs(qs_nm.clone())
-    , m_resolution(ScanResolution::scanEmptyResolution())
+    : ISpecularScan(SPECULAR_DATA_TYPE::q), m_qs(qs_nm.clone()),
+      m_resolution(ScanResolution::scanEmptyResolution())
 {
     checkInitialization();
 }
 
 QSpecScan::QSpecScan(int nbins, double qz_min, double qz_max)
-    : ISpecularScan(SPECULAR_DATA_TYPE::q)
-    , m_qs(std::make_unique<FixedBinAxis>("qs", nbins, qz_min, qz_max))
-    , m_resolution(ScanResolution::scanEmptyResolution())
+    : ISpecularScan(SPECULAR_DATA_TYPE::q),
+      m_qs(std::make_unique<FixedBinAxis>("qs", nbins, qz_min, qz_max)),
+      m_resolution(ScanResolution::scanEmptyResolution())
 {
     checkInitialization();
 }
@@ -114,8 +114,7 @@ std::string QSpecScan::print() const
     std::stringstream result;
     const std::string axis_def = PythonFormatting::indent() + "axis = ";
     result << axis_def
-           << PythonFormatting::printAxis(*coordinateAxis(), BornAgain::UnitsNone,
-                                          axis_def.size())
+           << PythonFormatting::printAxis(*coordinateAxis(), BornAgain::UnitsNone, axis_def.size())
            << "\n";
 
     result << PythonFormatting::indent() << "scan = ba.QSpecScan(axis)";
@@ -149,7 +148,7 @@ void QSpecScan::setRelativeQResolution(const RangedDistribution& distr,
     setQResolution(*resolution);
 }
 
-void QSpecScan::setAbsoluteQResolution(const RangedDistribution &distr, double std_dev)
+void QSpecScan::setAbsoluteQResolution(const RangedDistribution& distr, double std_dev)
 {
     std::unique_ptr<ScanResolution> resolution(
         ScanResolution::scanAbsoluteResolution(distr, std_dev));
@@ -188,7 +187,7 @@ std::vector<double> QSpecScan::generateQzVector() const
     return result;
 }
 
-std::vector<std::vector<ParameterSample> > QSpecScan::applyQResolution() const
+std::vector<std::vector<ParameterSample>> QSpecScan::applyQResolution() const
 {
     if (m_q_res_cache.empty())
         m_q_res_cache = m_resolution->generateSamples(m_qs->getBinCenters());
diff --git a/Core/Instrument/QSpecScan.h b/Core/Instrument/QSpecScan.h
index 94c2533fe57..e3afe763fb8 100644
--- a/Core/Instrument/QSpecScan.h
+++ b/Core/Instrument/QSpecScan.h
@@ -46,7 +46,7 @@ public:
     std::vector<SpecularSimulationElement> generateSimulationElements() const override;
 
     //! Returns coordinate axis assigned to the data holder
-    virtual const IAxis* coordinateAxis() const override {return m_qs.get();}
+    virtual const IAxis* coordinateAxis() const override { return m_qs.get(); }
 
     //! Returns IFootprintFactor object pointer
     virtual const IFootprintFactor* footprintFactor() const override { return nullptr; }
@@ -64,7 +64,7 @@ public:
 
     //! Print scan definition in python format
     std::string print() const override;
-#endif //SWIG
+#endif // SWIG
 
     //! Sets q resolution values via ScanResolution object.
     void setQResolution(const ScanResolution& resolution);
diff --git a/Core/Instrument/RectangularDetector.cpp b/Core/Instrument/RectangularDetector.cpp
index 8206694d01a..9398a009a57 100644
--- a/Core/Instrument/RectangularDetector.cpp
+++ b/Core/Instrument/RectangularDetector.cpp
@@ -16,36 +16,25 @@
 #include "Beam.h"
 #include "BornAgainNamespace.h"
 #include "IDetectorResolution.h"
+#include "MathConstants.h"
 #include "RegionOfInterest.h"
 #include "SimulationElement.h"
-#include "MathConstants.h"
 #include "Units.h"
 
 RectangularDetector::RectangularDetector(size_t nxbins, double width, size_t nybins, double height)
-    : m_u0(0.0)
-    , m_v0(0.0)
-    , m_direction(kvector_t(0.0, -1.0, 0.0))
-    , m_distance(0.0)
-    , m_dbeam_u0(0.0)
-    , m_dbeam_v0(0.0)
-    , m_detector_arrangement(GENERIC)
+    : m_u0(0.0), m_v0(0.0), m_direction(kvector_t(0.0, -1.0, 0.0)), m_distance(0.0),
+      m_dbeam_u0(0.0), m_dbeam_v0(0.0), m_detector_arrangement(GENERIC)
 {
     setDetectorParameters(nxbins, 0.0, width, nybins, 0.0, height);
     setName(BornAgain::RectangularDetectorType);
 }
 
 RectangularDetector::RectangularDetector(const RectangularDetector& other)
-    : IDetector2D(other)
-    , m_normal_to_detector(other.m_normal_to_detector)
-    , m_u0(other.m_u0)
-    , m_v0(other.m_v0)
-    , m_direction(other.m_direction)
-    , m_distance(other.m_distance)
-    , m_dbeam_u0(other.m_dbeam_u0)
-    , m_dbeam_v0(other.m_dbeam_v0)
-    , m_detector_arrangement(other.m_detector_arrangement)
-    , m_u_unit(other.m_u_unit)
-    , m_v_unit(other.m_v_unit)
+    : IDetector2D(other), m_normal_to_detector(other.m_normal_to_detector), m_u0(other.m_u0),
+      m_v0(other.m_v0), m_direction(other.m_direction), m_distance(other.m_distance),
+      m_dbeam_u0(other.m_dbeam_u0), m_dbeam_v0(other.m_dbeam_v0),
+      m_detector_arrangement(other.m_detector_arrangement), m_u_unit(other.m_u_unit),
+      m_v_unit(other.m_v_unit)
 {
     setName(BornAgain::RectangularDetectorType);
 }
@@ -65,8 +54,8 @@ void RectangularDetector::init(const Beam& beam)
     initUandV(alpha_i);
 }
 
-void RectangularDetector::setPosition(const kvector_t normal_to_detector,
-                                      double u0, double v0, const kvector_t direction)
+void RectangularDetector::setPosition(const kvector_t normal_to_detector, double u0, double v0,
+                                      const kvector_t direction)
 {
     m_detector_arrangement = GENERIC;
     m_normal_to_detector = normal_to_detector;
@@ -222,14 +211,16 @@ std::string RectangularDetector::axisName(size_t index) const
 
 size_t RectangularDetector::getIndexOfSpecular(const Beam& beam) const
 {
-    if (dimension()!=2) return totalSize();
+    if (dimension() != 2)
+        return totalSize();
     double alpha = beam.getAlpha();
     double phi = beam.getPhi();
     kvector_t k_spec = vecOfLambdaAlphaPhi(beam.getWavelength(), alpha, phi);
     kvector_t normal_unit = m_normal_to_detector.unit();
     double kd = k_spec.dot(normal_unit);
-    if (kd<=0.0) return totalSize();
-    kvector_t k_orth = (k_spec/kd - normal_unit)*m_distance;
+    if (kd <= 0.0)
+        return totalSize();
+    kvector_t k_orth = (k_spec / kd - normal_unit) * m_distance;
     double u = k_orth.dot(m_u_unit) + m_u0;
     double v = k_orth.dot(m_v_unit) + m_v0;
     const IAxis& u_axis = getAxis(BornAgain::X_AXIS_INDEX);
@@ -241,7 +232,7 @@ size_t RectangularDetector::getIndexOfSpecular(const Beam& beam) const
 
 void RectangularDetector::setDistanceAndOffset(double distance, double u0, double v0)
 {
-    if(distance <= 0.0) {
+    if (distance <= 0.0) {
         std::ostringstream message;
         message << "RectangularDetector::setPerpendicularToSample() -> Error. "
                 << "Distance to sample can't be negative or zero";
@@ -260,21 +251,21 @@ void RectangularDetector::initNormalVector(const kvector_t central_k)
         // do nothing
     }
 
-    else if(m_detector_arrangement == PERPENDICULAR_TO_SAMPLE) {
+    else if (m_detector_arrangement == PERPENDICULAR_TO_SAMPLE) {
         m_normal_to_detector = kvector_t(m_distance, 0.0, 0.0);
     }
 
-    else if(m_detector_arrangement == PERPENDICULAR_TO_DIRECT_BEAM) {
-        m_normal_to_detector = m_distance*central_k_unit;
+    else if (m_detector_arrangement == PERPENDICULAR_TO_DIRECT_BEAM) {
+        m_normal_to_detector = m_distance * central_k_unit;
     }
 
-    else if(m_detector_arrangement == PERPENDICULAR_TO_REFLECTED_BEAM) {
-        m_normal_to_detector = m_distance*central_k_unit;
+    else if (m_detector_arrangement == PERPENDICULAR_TO_REFLECTED_BEAM) {
+        m_normal_to_detector = m_distance * central_k_unit;
         m_normal_to_detector.setZ(-m_normal_to_detector.z());
     }
 
-    else if(m_detector_arrangement == PERPENDICULAR_TO_REFLECTED_BEAM_DPOS) {
-        m_normal_to_detector = m_distance*central_k_unit;
+    else if (m_detector_arrangement == PERPENDICULAR_TO_REFLECTED_BEAM_DPOS) {
+        m_normal_to_detector = m_distance * central_k_unit;
         m_normal_to_detector.setZ(-m_normal_to_detector.z());
     }
 
@@ -288,18 +279,18 @@ void RectangularDetector::initUandV(double alpha_i)
 {
     double d2 = m_normal_to_detector.dot(m_normal_to_detector);
     kvector_t u_direction =
-            d2 * m_direction - m_direction.dot(m_normal_to_detector) * m_normal_to_detector;
+        d2 * m_direction - m_direction.dot(m_normal_to_detector) * m_normal_to_detector;
     m_u_unit = u_direction.unit();
     m_v_unit = m_u_unit.cross(m_normal_to_detector).unit();
 
-    if(m_detector_arrangement == PERPENDICULAR_TO_REFLECTED_BEAM_DPOS) {
+    if (m_detector_arrangement == PERPENDICULAR_TO_REFLECTED_BEAM_DPOS) {
         kvector_t z(0.0, 0.0, 1.0);
         kvector_t normal_unit = m_normal_to_detector.unit();
-        kvector_t zp = z - z.dot(normal_unit)*normal_unit;
-        double uz = zp.dot(m_u_unit)/zp.mag();
-        double vz = zp.dot(m_v_unit)/zp.mag();
-        m_u0 = m_dbeam_u0 + m_distance*std::tan(2*alpha_i)*uz;
-        m_v0 = m_dbeam_v0 + m_distance*std::tan(2*alpha_i)*vz;
+        kvector_t zp = z - z.dot(normal_unit) * normal_unit;
+        double uz = zp.dot(m_u_unit) / zp.mag();
+        double vz = zp.dot(m_v_unit) / zp.mag();
+        m_u0 = m_dbeam_u0 + m_distance * std::tan(2 * alpha_i) * uz;
+        m_v0 = m_dbeam_v0 + m_distance * std::tan(2 * alpha_i) * vz;
     }
 }
 
@@ -318,29 +309,30 @@ RectangularPixel* RectangularPixel::clone() const
 
 RectangularPixel* RectangularPixel::createZeroSizePixel(double x, double y) const
 {
-    kvector_t position = m_corner_pos + x*m_width + y*m_height;
+    kvector_t position = m_corner_pos + x * m_width + y * m_height;
     kvector_t null_vector;
     return new RectangularPixel(position, null_vector, null_vector);
 }
 
 kvector_t RectangularPixel::getK(double x, double y, double wavelength) const
 {
-    kvector_t direction = m_corner_pos + x*m_width + y*m_height;
-    double length = M_TWOPI/wavelength;
+    kvector_t direction = m_corner_pos + x * m_width + y * m_height;
+    double length = M_TWOPI / wavelength;
     return normalizeLength(direction, length);
 }
 
 kvector_t RectangularPixel::getPosition(double x, double y) const
 {
-    return m_corner_pos + x*m_width + y*m_height;
+    return m_corner_pos + x * m_width + y * m_height;
 }
 
 double RectangularPixel::getIntegrationFactor(double x, double y) const
 {
-    if (m_solid_angle==0.0) return 1.0;
-    kvector_t position = m_corner_pos + x*m_width + y*m_height;
+    if (m_solid_angle == 0.0)
+        return 1.0;
+    kvector_t position = m_corner_pos + x * m_width + y * m_height;
     double length = position.mag();
-    return std::abs(position.dot(m_normal))/std::pow(length, 3)/m_solid_angle;
+    return std::abs(position.dot(m_normal)) / std::pow(length, 3) / m_solid_angle;
 }
 
 double RectangularPixel::getSolidAngle() const
@@ -350,12 +342,12 @@ double RectangularPixel::getSolidAngle() const
 
 kvector_t RectangularPixel::normalizeLength(const kvector_t direction, double length) const
 {
-    return direction.unit()*length;
+    return direction.unit() * length;
 }
 
 double RectangularPixel::calculateSolidAngle() const
 {
-    kvector_t position = m_corner_pos + 0.5*m_width + 0.5*m_height;
+    kvector_t position = m_corner_pos + 0.5 * m_width + 0.5 * m_height;
     double length = position.mag();
-    return std::abs(position.dot(m_normal))/std::pow(length, 3);
+    return std::abs(position.dot(m_normal)) / std::pow(length, 3);
 }
diff --git a/Core/Instrument/RectangularDetector.h b/Core/Instrument/RectangularDetector.h
index 65fc1d5a8de..c23ff1e8880 100644
--- a/Core/Instrument/RectangularDetector.h
+++ b/Core/Instrument/RectangularDetector.h
@@ -92,15 +92,16 @@ protected:
 
     //! swap function
     void swapContent(RectangularDetector& other);
+
 private:
     void setDistanceAndOffset(double distance, double u0, double v0);
     void initNormalVector(const kvector_t central_k);
     void initUandV(double alpha_i);
 
     kvector_t m_normal_to_detector;
-    double m_u0, m_v0; //!< position of normal vector hitting point in detector coordinates
+    double m_u0, m_v0;     //!< position of normal vector hitting point in detector coordinates
     kvector_t m_direction; //!< direction vector of detector coordinate system
-    double m_distance; //!< distance from sample origin to the detector plane
+    double m_distance;     //!< distance from sample origin to the detector plane
     double m_dbeam_u0, m_dbeam_v0; //!< position of direct beam in detector coordinates
     EDetectorArrangement m_detector_arrangement;
     kvector_t m_u_unit;
@@ -118,6 +119,7 @@ public:
     kvector_t getPosition(double x, double y) const;
     double getIntegrationFactor(double x, double y) const override;
     double getSolidAngle() const override;
+
 private:
     kvector_t normalizeLength(const kvector_t direction, double length) const;
     double calculateSolidAngle() const;
diff --git a/Core/Instrument/RegionOfInterest.cpp b/Core/Instrument/RegionOfInterest.cpp
index 15d4a2aa11b..62c4c505dff 100644
--- a/Core/Instrument/RegionOfInterest.cpp
+++ b/Core/Instrument/RegionOfInterest.cpp
@@ -13,23 +13,23 @@
 // ************************************************************************** //
 
 #include "RegionOfInterest.h"
-#include "Rectangle.h"
-#include "IDetector2D.h"
 #include "BornAgainNamespace.h"
 #include "Exceptions.h"
+#include "IDetector2D.h"
+#include "Rectangle.h"
 
-RegionOfInterest::RegionOfInterest(const IDetector2D &detector,
-                                   double xlow, double ylow, double xup, double yup)
+RegionOfInterest::RegionOfInterest(const IDetector2D& detector, double xlow, double ylow,
+                                   double xup, double yup)
     : RegionOfInterest(xlow, ylow, xup, yup)
 {
     initFrom(detector.getAxis(BornAgain::X_AXIS_INDEX), detector.getAxis(BornAgain::Y_AXIS_INDEX));
 }
 
-RegionOfInterest::RegionOfInterest(const OutputData<double> &data,
-                                   double xlow, double ylow, double xup, double yup)
+RegionOfInterest::RegionOfInterest(const OutputData<double>& data, double xlow, double ylow,
+                                   double xup, double yup)
     : RegionOfInterest(xlow, ylow, xup, yup)
 {
-    if(data.getRank() != 2)
+    if (data.getRank() != 2)
         throw Exceptions::RuntimeErrorException("RegionOfInterest::RegionOfInterest() -> Error. "
                                                 "Data is not two-dimensional.");
 
@@ -37,32 +37,24 @@ RegionOfInterest::RegionOfInterest(const OutputData<double> &data,
 }
 
 RegionOfInterest::RegionOfInterest(double xlow, double ylow, double xup, double yup)
-    : m_rectangle(new Rectangle(xlow, ylow, xup, yup))
-    , m_ax1(0)
-    , m_ay1(0)
-    , m_ax2(0)
-    , m_ay2(0)
-    , m_glob_index0(0)
-{}
+    : m_rectangle(new Rectangle(xlow, ylow, xup, yup)), m_ax1(0), m_ay1(0), m_ax2(0), m_ay2(0),
+      m_glob_index0(0)
+{
+}
 
-RegionOfInterest *RegionOfInterest::clone() const
+RegionOfInterest* RegionOfInterest::clone() const
 {
     return new RegionOfInterest(*this);
 }
 
 RegionOfInterest::~RegionOfInterest() {}
 
-RegionOfInterest::RegionOfInterest(const RegionOfInterest &other)
-    : ICloneable()
-    , m_rectangle(other.m_rectangle->clone())
-    , m_ax1(other.m_ax1)
-    , m_ay1(other.m_ay1)
-    , m_ax2(other.m_ax2)
-    , m_ay2(other.m_ay2)
-    , m_glob_index0(other.m_glob_index0)
-    , m_detector_dims(other.m_detector_dims)
-    , m_roi_dims(other.m_roi_dims)
-{}
+RegionOfInterest::RegionOfInterest(const RegionOfInterest& other)
+    : ICloneable(), m_rectangle(other.m_rectangle->clone()), m_ax1(other.m_ax1), m_ay1(other.m_ay1),
+      m_ax2(other.m_ax2), m_ay2(other.m_ay2), m_glob_index0(other.m_glob_index0),
+      m_detector_dims(other.m_detector_dims), m_roi_dims(other.m_roi_dims)
+{
+}
 
 double RegionOfInterest::getXlow() const
 {
@@ -87,50 +79,52 @@ double RegionOfInterest::getYup() const
 size_t RegionOfInterest::detectorIndex(size_t roiIndex) const
 {
     return m_glob_index0 + ycoord(roiIndex, m_roi_dims)
-            + xcoord(roiIndex, m_roi_dims)*m_detector_dims[1];
+           + xcoord(roiIndex, m_roi_dims) * m_detector_dims[1];
 }
 
 size_t RegionOfInterest::roiIndex(size_t globalIndex) const
 {
     size_t ny = ycoord(globalIndex, m_detector_dims);
-    if(ny < m_ay1 || ny > m_ay2)
+    if (ny < m_ay1 || ny > m_ay2)
         throw Exceptions::RuntimeErrorException("RegionOfInterest::roiIndex() -> Error.");
 
     size_t nx = xcoord(globalIndex, m_detector_dims);
-    if(nx < m_ax1 || nx > m_ax2)
+    if (nx < m_ax1 || nx > m_ax2)
         throw Exceptions::RuntimeErrorException("RegionOfInterest::roiIndex() -> Error.");
 
-    return ny - m_ay1 + (nx - m_ax1)*m_roi_dims[1];
+    return ny - m_ay1 + (nx - m_ax1) * m_roi_dims[1];
 }
 
 size_t RegionOfInterest::roiSize() const
 {
-    return m_roi_dims[0]*m_roi_dims[1];
+    return m_roi_dims[0] * m_roi_dims[1];
 }
 
 size_t RegionOfInterest::detectorSize() const
 {
-    return m_detector_dims[0]*m_detector_dims[1];
+    return m_detector_dims[0] * m_detector_dims[1];
 }
 
 bool RegionOfInterest::isInROI(size_t detectorIndex) const
 {
     size_t ny = ycoord(detectorIndex, m_detector_dims);
-    if(ny<m_ay1 || ny>m_ay2) return false;
+    if (ny < m_ay1 || ny > m_ay2)
+        return false;
     size_t nx = xcoord(detectorIndex, m_detector_dims);
-    if(nx<m_ax1 || nx>m_ax2) return false;
+    if (nx < m_ax1 || nx > m_ax2)
+        return false;
     return true;
 }
 
-std::unique_ptr<IAxis> RegionOfInterest::clipAxisToRoi(size_t axis_index, const IAxis &axis) const
+std::unique_ptr<IAxis> RegionOfInterest::clipAxisToRoi(size_t axis_index, const IAxis& axis) const
 {
     size_t nbin1 = (axis_index == BornAgain::X_AXIS_INDEX ? m_ax1 : m_ay1);
     size_t nbin2 = (axis_index == BornAgain::X_AXIS_INDEX ? m_ax2 : m_ay2);
-    return std::unique_ptr<IAxis>(new FixedBinAxis(axis.getName(), nbin2-nbin1+1,
-                                    axis.getBin(nbin1).m_lower, axis.getBin(nbin2).m_upper));
+    return std::unique_ptr<IAxis>(new FixedBinAxis(
+        axis.getName(), nbin2 - nbin1 + 1, axis.getBin(nbin1).m_lower, axis.getBin(nbin2).m_upper));
 }
 
-void RegionOfInterest::initFrom(const IAxis &x_axis, const IAxis &y_axis)
+void RegionOfInterest::initFrom(const IAxis& x_axis, const IAxis& y_axis)
 {
     m_detector_dims.push_back(x_axis.size());
     m_detector_dims.push_back(y_axis.size());
@@ -140,9 +134,8 @@ void RegionOfInterest::initFrom(const IAxis &x_axis, const IAxis &y_axis)
     m_ay1 = y_axis.findClosestIndex(getYlow());
     m_ay2 = y_axis.findClosestIndex(getYup());
 
-    m_roi_dims.push_back(m_ax2-m_ax1+1);
-    m_roi_dims.push_back(m_ay2-m_ay1+1);
+    m_roi_dims.push_back(m_ax2 - m_ax1 + 1);
+    m_roi_dims.push_back(m_ay2 - m_ay1 + 1);
 
-    m_glob_index0 = m_ay1 + m_ax1*m_detector_dims[1];
+    m_glob_index0 = m_ay1 + m_ax1 * m_detector_dims[1];
 }
-
diff --git a/Core/Instrument/RegionOfInterest.h b/Core/Instrument/RegionOfInterest.h
index 8f4173f1367..fbbdb491d09 100644
--- a/Core/Instrument/RegionOfInterest.h
+++ b/Core/Instrument/RegionOfInterest.h
@@ -22,7 +22,7 @@
 class Rectangle;
 class IDetector2D;
 class IAxis;
-template<class T> class OutputData;
+template <class T> class OutputData;
 
 //! Defines rectangular area for the detector which will be simulated/fitted.
 //! @ingroup simulation
@@ -30,19 +30,18 @@ template<class T> class OutputData;
 class BA_CORE_API_ RegionOfInterest : public ICloneable
 {
 public:
-    RegionOfInterest(const IDetector2D& detector,
-                     double xlow, double ylow, double xup, double yup);
-    RegionOfInterest(const OutputData<double>& data,
-                     double xlow, double ylow, double xup, double yup);
+    RegionOfInterest(const IDetector2D& detector, double xlow, double ylow, double xup, double yup);
+    RegionOfInterest(const OutputData<double>& data, double xlow, double ylow, double xup,
+                     double yup);
 
-    RegionOfInterest& operator=(const RegionOfInterest &other) = delete;
+    RegionOfInterest& operator=(const RegionOfInterest& other) = delete;
     RegionOfInterest* clone() const;
     ~RegionOfInterest();
 
     double getXlow() const;
     double getYlow() const;
-    double getXup()  const;
-    double getYup()  const;
+    double getXup() const;
+    double getYup() const;
 
     //! Converts roi index to the detector index.
     size_t detectorIndex(size_t roiIndex) const;
@@ -58,14 +57,14 @@ public:
 
     bool isInROI(size_t detectorIndex) const;
 
-    std::unique_ptr<IAxis> clipAxisToRoi(size_t axis_index, const IAxis &axis) const;
+    std::unique_ptr<IAxis> clipAxisToRoi(size_t axis_index, const IAxis& axis) const;
 
 private:
     RegionOfInterest(double xlow, double ylow, double xup, double yup);
     RegionOfInterest(const RegionOfInterest& other);
 
-    size_t xcoord(size_t index, const std::vector<size_t> &dims) const;
-    size_t ycoord(size_t index, const std::vector<size_t> &dims) const;
+    size_t xcoord(size_t index, const std::vector<size_t>& dims) const;
+    size_t ycoord(size_t index, const std::vector<size_t>& dims) const;
 
     void initFrom(const IAxis& x_axis, const IAxis& y_axis);
 
@@ -78,14 +77,12 @@ private:
     std::vector<size_t> m_roi_dims;
 };
 
-inline
-size_t RegionOfInterest::xcoord(size_t index, const std::vector<size_t>& dims) const
+inline size_t RegionOfInterest::xcoord(size_t index, const std::vector<size_t>& dims) const
 {
-    return index/dims[1] % dims[0];
+    return index / dims[1] % dims[0];
 }
 
-inline
-size_t RegionOfInterest::ycoord(size_t index, const std::vector<size_t>& dims) const
+inline size_t RegionOfInterest::ycoord(size_t index, const std::vector<size_t>& dims) const
 {
     return index % dims[1];
 }
diff --git a/Core/Instrument/ResolutionFunction2DGaussian.cpp b/Core/Instrument/ResolutionFunction2DGaussian.cpp
index 2ab3fb5962d..4da7aa3309a 100644
--- a/Core/Instrument/ResolutionFunction2DGaussian.cpp
+++ b/Core/Instrument/ResolutionFunction2DGaussian.cpp
@@ -28,5 +28,5 @@ ResolutionFunction2DGaussian::ResolutionFunction2DGaussian(double sigma_x, doubl
 double ResolutionFunction2DGaussian::evaluateCDF(double x, double y) const
 {
     return MathFunctions::IntegratedGaussian(x, 0.0, m_sigma_x)
-                * MathFunctions::IntegratedGaussian(y, 0.0, m_sigma_y);
+           * MathFunctions::IntegratedGaussian(y, 0.0, m_sigma_y);
 }
diff --git a/Core/Instrument/ResolutionFunction2DGaussian.h b/Core/Instrument/ResolutionFunction2DGaussian.h
index 7ceb8c86cb6..ba9e92f343a 100644
--- a/Core/Instrument/ResolutionFunction2DGaussian.h
+++ b/Core/Instrument/ResolutionFunction2DGaussian.h
@@ -27,8 +27,10 @@ public:
 
     virtual double evaluateCDF(double x, double y) const;
 
-    ResolutionFunction2DGaussian* clone() const {
-        return new ResolutionFunction2DGaussian(m_sigma_x, m_sigma_y); }
+    ResolutionFunction2DGaussian* clone() const
+    {
+        return new ResolutionFunction2DGaussian(m_sigma_x, m_sigma_y);
+    }
 
     void accept(INodeVisitor* visitor) const final { visitor->visit(this); }
 
diff --git a/Core/Instrument/SampleBuilderNode.cpp b/Core/Instrument/SampleBuilderNode.cpp
index 0c095f473af..846b54fda7e 100644
--- a/Core/Instrument/SampleBuilderNode.cpp
+++ b/Core/Instrument/SampleBuilderNode.cpp
@@ -13,12 +13,13 @@
 // ************************************************************************** //
 
 #include "SampleBuilderNode.h"
-#include "ParameterPool.h"
-#include "MultiLayer.h"
 #include "IMultiLayerBuilder.h"
+#include "MultiLayer.h"
+#include "ParameterPool.h"
 #include <stdexcept>
 
-namespace {
+namespace
+{
 const std::string& default_name = "SampleBuilderNode";
 }
 
@@ -102,4 +103,3 @@ void SampleBuilderNode::borrow_builder_parameters()
 
     m_sample_builder->parameterPool()->copyToExternalPool("", parameterPool());
 }
-
diff --git a/Core/Instrument/SampleProvider.cpp b/Core/Instrument/SampleProvider.cpp
index db8357d0429..b53e797329f 100644
--- a/Core/Instrument/SampleProvider.cpp
+++ b/Core/Instrument/SampleProvider.cpp
@@ -16,32 +16,27 @@
 #include "MultiLayer.h"
 #include <cassert>
 
-SampleProvider::SampleProvider()
-{
-}
+SampleProvider::SampleProvider() {}
 
 SampleProvider::SampleProvider(const SampleProvider& other)
 {
     if (other.m_multilayer)
         setSample(*other.m_multilayer);
 
-    if(other.m_sample_builder)
+    if (other.m_sample_builder)
         setSampleBuilder(other.m_sample_builder.builder());
 }
 
 SampleProvider& SampleProvider::operator=(const SampleProvider& other)
 {
-    if ( this != &other ) {
+    if (this != &other) {
         SampleProvider tmp(other);
         tmp.swapContent(*this);
     }
     return *this;
 }
 
-SampleProvider::~SampleProvider()
-{
-
-}
+SampleProvider::~SampleProvider() {}
 
 void SampleProvider::setSample(const MultiLayer& multilayer)
 {
@@ -68,7 +63,7 @@ const MultiLayer* SampleProvider::sample() const
 
 void SampleProvider::updateSample()
 {
-    if(m_sample_builder)
+    if (m_sample_builder)
         m_multilayer = m_sample_builder.createMultiLayer();
 
     if (!m_multilayer)
@@ -81,7 +76,7 @@ std::vector<const INode*> SampleProvider::getChildren() const
     if (m_sample_builder) {
         result.push_back(&m_sample_builder);
     } else {
-        if(m_multilayer)
+        if (m_multilayer)
             result.push_back(m_multilayer.get());
     }
     return result;
@@ -90,7 +85,7 @@ std::vector<const INode*> SampleProvider::getChildren() const
 void SampleProvider::setParent(const INode* newParent)
 {
     INode::setParent(newParent);
-    if ( m_sample_builder) {
+    if (m_sample_builder) {
         m_sample_builder.setParent(parent());
     } else {
         if (m_multilayer)
@@ -103,6 +98,3 @@ void SampleProvider::swapContent(SampleProvider& other)
     std::swap(m_multilayer, other.m_multilayer);
     std::swap(m_sample_builder, other.m_sample_builder);
 }
-
-
-
diff --git a/Core/Instrument/SampleProvider.h b/Core/Instrument/SampleProvider.h
index ed15a22f7c4..49b54bf6483 100644
--- a/Core/Instrument/SampleProvider.h
+++ b/Core/Instrument/SampleProvider.h
@@ -24,7 +24,7 @@ class MultiLayer;
 //! the user or from SampleBuilder.
 //! @ingroup simulation_internal
 
-class BA_CORE_API_ SampleProvider: public INode
+class BA_CORE_API_ SampleProvider : public INode
 {
 public:
     SampleProvider();
diff --git a/Core/Instrument/ScanResolution.cpp b/Core/Instrument/ScanResolution.cpp
index ff57a90481c..b89991956d2 100644
--- a/Core/Instrument/ScanResolution.cpp
+++ b/Core/Instrument/ScanResolution.cpp
@@ -16,19 +16,21 @@
 #include "PythonFormatting.h"
 #include "RangedDistributions.h"
 
-namespace {
+namespace
+{
 void checkIfEmpty(const std::vector<double>& input);
 std::string printDeltas(const std::vector<double>& deltas);
 
 const std::string relative_resolution = "ScanRelativeResolution";
 const std::string absolute_resolution = "ScanAbsoluteResolution";
 
-class ScanSingleRelativeResolution : public ScanResolution {
+class ScanSingleRelativeResolution : public ScanResolution
+{
 public:
     ScanSingleRelativeResolution(const RangedDistribution& distr, double reldev)
-        : ScanResolution(distr)
-        , m_reldev(reldev)
-    {}
+        : ScanResolution(distr), m_reldev(reldev)
+    {
+    }
     ~ScanSingleRelativeResolution() override = default;
 
     ScanResolution* clone() const override
@@ -49,12 +51,13 @@ private:
     double m_reldev; //!< deltas for computing resolutions
 };
 
-class ScanSingleAbsoluteResolution : public ScanResolution {
+class ScanSingleAbsoluteResolution : public ScanResolution
+{
 public:
     ScanSingleAbsoluteResolution(const RangedDistribution& distr, double stddev)
-        : ScanResolution(distr)
-        , m_stddev(stddev)
-    {}
+        : ScanResolution(distr), m_stddev(stddev)
+    {
+    }
     ~ScanSingleAbsoluteResolution() override = default;
 
     ScanResolution* clone() const override
@@ -75,11 +78,11 @@ private:
     double m_stddev; //!< deltas for computing resolutions
 };
 
-class ScanVectorRelativeResolution : public ScanResolution {
+class ScanVectorRelativeResolution : public ScanResolution
+{
 public:
     ScanVectorRelativeResolution(const RangedDistribution& distr, const std::vector<double>& reldev)
-        : ScanResolution(distr)
-        , m_reldev(reldev)
+        : ScanResolution(distr), m_reldev(reldev)
     {
         checkIfEmpty(m_reldev);
     }
@@ -103,11 +106,11 @@ private:
     std::vector<double> m_reldev; //!< deltas for computing resolutions
 };
 
-class ScanVectorAbsoluteResolution : public ScanResolution {
+class ScanVectorAbsoluteResolution : public ScanResolution
+{
 public:
     ScanVectorAbsoluteResolution(const RangedDistribution& distr, const std::vector<double>& stddev)
-        : ScanResolution(distr)
-        , m_stddev(stddev)
+        : ScanResolution(distr), m_stddev(stddev)
     {
         checkIfEmpty(m_stddev);
     }
@@ -131,18 +134,14 @@ private:
     std::vector<double> m_stddev; //!< deltas for computing resolutions
 };
 
-class ScanEmptyResolution : public ScanResolution {
+class ScanEmptyResolution : public ScanResolution
+{
 public:
-    ScanEmptyResolution()
-        : ScanResolution()
-    {}
+    ScanEmptyResolution() : ScanResolution() {}
 
     ~ScanEmptyResolution() override = default;
 
-    ScanResolution* clone() const override
-    {
-        return new ScanEmptyResolution();
-    }
+    ScanResolution* clone() const override { return new ScanEmptyResolution(); }
 
     DistrOutput generateSamples(double mean, size_t n_times) const override;
     DistrOutput generateSamples(const std::vector<double>& mean) const override;
@@ -153,7 +152,7 @@ protected:
     std::string name() const override;
     std::string printStdDevs() const override;
 };
-}
+} // namespace
 
 ScanResolution::~ScanResolution() = default;
 
@@ -199,22 +198,22 @@ std::string ScanResolution::print() const
     result << *m_distr << "\n";
     result << PythonFormatting::indent() << "resolution = ";
     result << "ba." << name();
-    result << "(" << "distribution" << ", ";
+    result << "("
+           << "distribution"
+           << ", ";
     result << printStdDevs();
     result << ")";
     return result.str();
 }
 
-ScanResolution::ScanResolution()
-{}
+ScanResolution::ScanResolution() {}
 
-ScanResolution::ScanResolution(const RangedDistribution& distr)
-    : m_distr(distr.clone())
-{}
+ScanResolution::ScanResolution(const RangedDistribution& distr) : m_distr(distr.clone()) {}
 
-namespace {
-ScanResolution::DistrOutput
-ScanSingleRelativeResolution::generateSamples(double mean, size_t n_times) const
+namespace
+{
+ScanResolution::DistrOutput ScanSingleRelativeResolution::generateSamples(double mean,
+                                                                          size_t n_times) const
 {
     const double stddev = mean * m_reldev;
     return DistrOutput(n_times, distribution()->generateSamples(mean, stddev));
@@ -246,8 +245,8 @@ std::vector<double> ScanSingleRelativeResolution::stdDevs(const std::vector<doub
     return result;
 }
 
-ScanResolution::DistrOutput
-ScanVectorRelativeResolution::generateSamples(double mean, size_t n_times) const
+ScanResolution::DistrOutput ScanVectorRelativeResolution::generateSamples(double mean,
+                                                                          size_t n_times) const
 {
     return generateSamples(std::vector<double>(n_times, mean));
 }
@@ -272,15 +271,14 @@ std::vector<double> ScanVectorRelativeResolution::stdDevs(const std::vector<doub
             "Error in ScanVectorRelativeResolution::stdDevs: passed mean values vector "
             "size shall be of the same size with relative deviations vector");
 
-
     std::vector<double> stddevs(result_size);
     for (size_t i = 0; i < result_size; ++i)
         stddevs[i] = m_reldev[i] * mean[i];
     return stddevs;
 }
 
-ScanResolution::DistrOutput
-ScanSingleAbsoluteResolution::generateSamples(double mean, size_t n_times) const
+ScanResolution::DistrOutput ScanSingleAbsoluteResolution::generateSamples(double mean,
+                                                                          size_t n_times) const
 {
     return DistrOutput(n_times, distribution()->generateSamples(mean, m_stddev));
 }
@@ -307,8 +305,8 @@ std::vector<double> ScanSingleAbsoluteResolution::stdDevs(const std::vector<doub
     return std::vector<double>(mean.size(), m_stddev);
 }
 
-ScanResolution::DistrOutput
-ScanVectorAbsoluteResolution::generateSamples(double mean, size_t n_times) const
+ScanResolution::DistrOutput ScanVectorAbsoluteResolution::generateSamples(double mean,
+                                                                          size_t n_times) const
 {
     return generateSamples(std::vector<double>(n_times, mean));
 }
@@ -339,8 +337,8 @@ std::vector<double> ScanVectorAbsoluteResolution::stdDevs(const std::vector<doub
     return m_stddev;
 }
 
-ScanEmptyResolution::DistrOutput
-ScanEmptyResolution::generateSamples(double mean, size_t n_times) const
+ScanEmptyResolution::DistrOutput ScanEmptyResolution::generateSamples(double mean,
+                                                                      size_t n_times) const
 {
     return DistrOutput(n_times, std::vector<ParameterSample>{ParameterSample(mean, 1.)});
 }
@@ -387,4 +385,4 @@ void checkIfEmpty(const std::vector<double>& input)
     if (input.empty())
         throw std::runtime_error("Error in ScanResolution: passed vector is empty");
 }
-}
+} // namespace
diff --git a/Core/Instrument/ScanResolution.h b/Core/Instrument/ScanResolution.h
index 11fab8b3184..ed27e21790b 100644
--- a/Core/Instrument/ScanResolution.h
+++ b/Core/Instrument/ScanResolution.h
@@ -25,9 +25,11 @@ class RangedDistribution;
 class RealLimits;
 
 //! Container for reflectivity resolution data.
-class BA_CORE_API_ ScanResolution : public ICloneable {
+class BA_CORE_API_ ScanResolution : public ICloneable
+{
 protected:
     using DistrOutput = std::vector<std::vector<ParameterSample>>;
+
 public:
     ~ScanResolution() override;
     static ScanResolution* scanRelativeResolution(const RangedDistribution& distr, double stddev);
@@ -51,7 +53,7 @@ public:
 
     //! Prints object definition in python format.
     std::string print() const;
-#endif //SWIG
+#endif // SWIG
 protected:
     ScanResolution();
     ScanResolution(const RangedDistribution& distr);
diff --git a/Core/Instrument/SimpleUnitConverters.cpp b/Core/Instrument/SimpleUnitConverters.cpp
index e7a281144a1..6feeeac1ecf 100644
--- a/Core/Instrument/SimpleUnitConverters.cpp
+++ b/Core/Instrument/SimpleUnitConverters.cpp
@@ -27,18 +27,18 @@
 #include "UnitConverterUtils.h"
 #include "Units.h"
 
-namespace {
+namespace
+{
 double getQ(double wavelength, double angle)
 {
     return 4.0 * M_PI * std::sin(angle) / wavelength;
 }
-}
+} // namespace
 
 UnitConverterSimple::UnitConverterSimple(const Beam& beam)
-    : m_wavelength(beam.getWavelength())
-    , m_alpha_i(-beam.getAlpha())
-    , m_phi_i(beam.getPhi())
-{}
+    : m_wavelength(beam.getWavelength()), m_alpha_i(-beam.getAlpha()), m_phi_i(beam.getPhi())
+{
+}
 
 size_t UnitConverterSimple::dimension() const
 {
@@ -48,7 +48,7 @@ size_t UnitConverterSimple::dimension() const
 void UnitConverterSimple::addAxisData(std::string name, double min, double max,
                                       AxesUnits default_units, size_t nbins)
 {
-    AxisData axis_data { name, min, max, default_units, nbins };
+    AxisData axis_data{name, min, max, default_units, nbins};
     m_axis_data_table.push_back(axis_data);
 }
 
@@ -57,7 +57,7 @@ double UnitConverterSimple::calculateMin(size_t i_axis, AxesUnits units_type) co
     checkIndex(i_axis);
     units_type = UnitConverterUtils::substituteDefaultUnits(*this, units_type);
     auto axis_data = m_axis_data_table[i_axis];
-    if (units_type==AxesUnits::NBINS) {
+    if (units_type == AxesUnits::NBINS) {
         return 0.0;
     }
     return calculateValue(i_axis, units_type, axis_data.min);
@@ -68,7 +68,7 @@ double UnitConverterSimple::calculateMax(size_t i_axis, AxesUnits units_type) co
     checkIndex(i_axis);
     units_type = UnitConverterUtils::substituteDefaultUnits(*this, units_type);
     auto axis_data = m_axis_data_table[i_axis];
-    if (units_type==AxesUnits::NBINS) {
+    if (units_type == AxesUnits::NBINS) {
         return static_cast<double>(axis_data.nbins);
     }
     return calculateValue(i_axis, units_type, axis_data.max);
@@ -97,11 +97,10 @@ std::unique_ptr<IAxis> UnitConverterSimple::createConvertedAxis(size_t i_axis,
 }
 
 UnitConverterSimple::UnitConverterSimple(const UnitConverterSimple& other)
-    : m_axis_data_table(other.m_axis_data_table)
-    , m_wavelength(other.m_wavelength)
-    , m_alpha_i(other.m_alpha_i)
-    , m_phi_i(other.m_phi_i)
-{}
+    : m_axis_data_table(other.m_axis_data_table), m_wavelength(other.m_wavelength),
+      m_alpha_i(other.m_alpha_i), m_phi_i(other.m_phi_i)
+{
+}
 
 void UnitConverterSimple::addDetectorAxis(const IDetector& detector, size_t i_axis)
 {
@@ -130,7 +129,7 @@ SphericalConverter::SphericalConverter(const SphericalDetector& detector, const
     addDetectorAxis(detector, 1);
 }
 
-SphericalConverter::~SphericalConverter() =default;
+SphericalConverter::~SphericalConverter() = default;
 
 SphericalConverter* SphericalConverter::clone() const
 {
@@ -144,21 +143,23 @@ std::vector<AxesUnits> SphericalConverter::availableUnits() const
     return result;
 }
 
-AxesUnits SphericalConverter::defaultUnits() const { return AxesUnits::DEGREES; }
+AxesUnits SphericalConverter::defaultUnits() const
+{
+    return AxesUnits::DEGREES;
+}
 
-SphericalConverter::SphericalConverter(const SphericalConverter& other)
-    : UnitConverterSimple(other)
-{}
+SphericalConverter::SphericalConverter(const SphericalConverter& other) : UnitConverterSimple(other)
+{
+}
 
 double SphericalConverter::calculateValue(size_t i_axis, AxesUnits units_type, double value) const
 {
-    switch(units_type) {
+    switch (units_type) {
     case AxesUnits::RADIANS:
         return value;
     case AxesUnits::DEGREES:
         return Units::rad2deg(value);
-    case AxesUnits::QSPACE:
-    {
+    case AxesUnits::QSPACE: {
         auto k_i = vecOfLambdaAlphaPhi(m_wavelength, m_alpha_i, m_phi_i);
         if (i_axis == BornAgain::X_AXIS_INDEX) {
             auto k_f = vecOfLambdaAlphaPhi(m_wavelength, 0.0, value);
@@ -171,8 +172,7 @@ double SphericalConverter::calculateValue(size_t i_axis, AxesUnits units_type, d
                                  "incorrect axis index: "
                                  + std::to_string(static_cast<int>(i_axis)));
     }
-    case AxesUnits::QXQY:
-    {
+    case AxesUnits::QXQY: {
         auto k_i = vecOfLambdaAlphaPhi(m_wavelength, m_alpha_i, m_phi_i);
         if (i_axis == BornAgain::X_AXIS_INDEX) {
             auto k_f = vecOfLambdaAlphaPhi(m_wavelength, 0.0, value);
@@ -190,7 +190,7 @@ double SphericalConverter::calculateValue(size_t i_axis, AxesUnits units_type, d
     }
 }
 
-std::vector<std::map<AxesUnits, std::string> > SphericalConverter::createNameMaps() const
+std::vector<std::map<AxesUnits, std::string>> SphericalConverter::createNameMaps() const
 {
     std::vector<std::map<AxesUnits, std::string>> result;
     result.push_back(AxisNames::InitSphericalAxis0());
@@ -212,7 +212,7 @@ RectangularConverter::RectangularConverter(const RectangularDetector& detector,
     mP_detector_pixel.reset(detector.regionOfInterestPixel());
 }
 
-RectangularConverter::~RectangularConverter() =default;
+RectangularConverter::~RectangularConverter() = default;
 
 RectangularConverter* RectangularConverter::clone() const
 {
@@ -227,12 +227,15 @@ std::vector<AxesUnits> RectangularConverter::availableUnits() const
     return result;
 }
 
-AxesUnits RectangularConverter::defaultUnits() const { return AxesUnits::MM; }
+AxesUnits RectangularConverter::defaultUnits() const
+{
+    return AxesUnits::MM;
+}
 
 RectangularConverter::RectangularConverter(const RectangularConverter& other)
-    : UnitConverterSimple(other)
-    , mP_detector_pixel(other.mP_detector_pixel->clone())
-{}
+    : UnitConverterSimple(other), mP_detector_pixel(other.mP_detector_pixel->clone())
+{
+}
 
 double RectangularConverter::calculateValue(size_t i_axis, AxesUnits units_type, double value) const
 {
@@ -241,16 +244,15 @@ double RectangularConverter::calculateValue(size_t i_axis, AxesUnits units_type,
     const auto k00 = mP_detector_pixel->getPosition(0.0, 0.0);
     const auto k01 = mP_detector_pixel->getPosition(0.0, 1.0);
     const auto k10 = mP_detector_pixel->getPosition(1.0, 0.0);
-    const auto& max_pos = i_axis == 0 ? k10 : k01;  // position of max along given axis
+    const auto& max_pos = i_axis == 0 ? k10 : k01; // position of max along given axis
     const double shift = value - m_axis_data_table[i_axis].min;
-    auto k_f = normalizeToWavelength(k00 + shift*(max_pos - k00).unit());
-    switch(units_type) {
+    auto k_f = normalizeToWavelength(k00 + shift * (max_pos - k00).unit());
+    switch (units_type) {
     case AxesUnits::RADIANS:
         return axisAngle(i_axis, k_f);
     case AxesUnits::DEGREES:
         return Units::rad2deg(axisAngle(i_axis, k_f));
-    case AxesUnits::QSPACE:
-    {
+    case AxesUnits::QSPACE: {
         auto k_i = vecOfLambdaAlphaPhi(m_wavelength, m_alpha_i, m_phi_i);
         if (i_axis == BornAgain::X_AXIS_INDEX) {
             return (k_i - k_f).y();
@@ -261,8 +263,7 @@ double RectangularConverter::calculateValue(size_t i_axis, AxesUnits units_type,
                                  "incorrect axis index: "
                                  + std::to_string(static_cast<int>(i_axis)));
     }
-    case AxesUnits::QXQY:
-    {
+    case AxesUnits::QXQY: {
         auto k_i = vecOfLambdaAlphaPhi(m_wavelength, m_alpha_i, m_phi_i);
         if (i_axis == BornAgain::X_AXIS_INDEX) {
             return (k_i - k_f).y();
@@ -291,8 +292,8 @@ kvector_t RectangularConverter::normalizeToWavelength(kvector_t vector) const
     if (m_wavelength <= 0.0)
         throw std::runtime_error("Error in RectangularConverter::normalizeToWavelength: "
                                  "wavelength <= 0");
-    double K = M_TWOPI/m_wavelength;
-    return vector.unit()*K;
+    double K = M_TWOPI / m_wavelength;
+    return vector.unit() * K;
 }
 
 double RectangularConverter::axisAngle(size_t i_axis, kvector_t k_f) const
@@ -323,22 +324,26 @@ OffSpecularConverter::OffSpecularConverter(const IDetector2D& detector, const Be
     addDetectorYAxis(detector);
 }
 
-OffSpecularConverter::~OffSpecularConverter() =default;
+OffSpecularConverter::~OffSpecularConverter() = default;
 
 OffSpecularConverter* OffSpecularConverter::clone() const
 {
     return new OffSpecularConverter(*this);
 }
 
-AxesUnits OffSpecularConverter::defaultUnits() const { return AxesUnits::DEGREES; }
+AxesUnits OffSpecularConverter::defaultUnits() const
+{
+    return AxesUnits::DEGREES;
+}
 
 OffSpecularConverter::OffSpecularConverter(const OffSpecularConverter& other)
     : UnitConverterSimple(other)
-{}
+{
+}
 
 double OffSpecularConverter::calculateValue(size_t, AxesUnits units_type, double value) const
 {
-    switch(units_type) {
+    switch (units_type) {
     case AxesUnits::RADIANS:
         return value;
     case AxesUnits::DEGREES:
@@ -418,14 +423,15 @@ std::vector<AxesUnits> DepthProbeConverter::availableUnits() const
 
 DepthProbeConverter::DepthProbeConverter(const DepthProbeConverter& other)
     : UnitConverterSimple(other)
-{}
+{
+}
 
 double DepthProbeConverter::calculateValue(size_t i_axis, AxesUnits units_type, double value) const
 {
     checkUnits(units_type);
     if (i_axis == 1)
         return value; // unit conversions are not applied to sample position axis
-    switch(units_type) {
+    switch (units_type) {
     case AxesUnits::DEGREES:
         return Units::rad2deg(value);
     case AxesUnits::QSPACE:
diff --git a/Core/Instrument/SimpleUnitConverters.h b/Core/Instrument/SimpleUnitConverters.h
index f8ca829cd65..267bc6a28c1 100644
--- a/Core/Instrument/SimpleUnitConverters.h
+++ b/Core/Instrument/SimpleUnitConverters.h
@@ -49,8 +49,8 @@ protected:
     UnitConverterSimple(const UnitConverterSimple& other);
     void addDetectorAxis(const IDetector& detector, size_t i_axis);
 
-    void addAxisData(std::string name, double min, double max,
-                     AxesUnits default_units, size_t nbins);
+    void addAxisData(std::string name, double min, double max, AxesUnits default_units,
+                     size_t nbins);
 
 #ifndef SWIG
     struct AxisData {
@@ -66,7 +66,7 @@ protected:
     double m_phi_i;
 
 private:
-    virtual double calculateValue(size_t i_axis, AxesUnits units_type, double value) const=0;
+    virtual double calculateValue(size_t i_axis, AxesUnits units_type, double value) const = 0;
 };
 
 //! IUnitConverter class that handles the unit translations for spherical detectors
diff --git a/Core/Instrument/SimulationArea.cpp b/Core/Instrument/SimulationArea.cpp
index 7b097d637bb..2b08614ec85 100644
--- a/Core/Instrument/SimulationArea.cpp
+++ b/Core/Instrument/SimulationArea.cpp
@@ -13,18 +13,16 @@
 // ************************************************************************** //
 
 #include "SimulationArea.h"
-#include "IDetector.h"
-#include "Exceptions.h"
+#include "BornAgainNamespace.h"
 #include "DetectorMask.h"
-#include "Rectangle.h"
+#include "Exceptions.h"
+#include "IDetector.h"
 #include "IntensityDataFunctions.h"
-#include "BornAgainNamespace.h"
+#include "Rectangle.h"
 #include "RegionOfInterest.h"
 #include <sstream>
 
-SimulationArea::SimulationArea(const IDetector* detector)
-    : m_detector(detector)
-    , m_max_index(0)
+SimulationArea::SimulationArea(const IDetector* detector) : m_detector(detector), m_max_index(0)
 {
     if (m_detector == nullptr)
         throw std::runtime_error("SimulationArea::SimulationArea: null pointer passed"
@@ -34,7 +32,7 @@ SimulationArea::SimulationArea(const IDetector* detector)
         throw std::runtime_error(
             "SimulationArea::SimulationArea: detector of unspecified dimensionality");
 
-    if(m_detector->regionOfInterest())
+    if (m_detector->regionOfInterest())
         m_max_index = m_detector->regionOfInterest()->roiSize();
     else
         m_max_index = m_detector->totalSize();
@@ -63,7 +61,7 @@ size_t SimulationArea::roiIndex(size_t index) const
 
 size_t SimulationArea::detectorIndex(size_t index) const
 {
-    if(!m_detector->regionOfInterest())
+    if (!m_detector->regionOfInterest())
         return index;
 
     return m_detector->regionOfInterest()->detectorIndex(index);
@@ -71,9 +69,7 @@ size_t SimulationArea::detectorIndex(size_t index) const
 
 // --------------------------------------------------------------------------------------
 
-SimulationRoiArea::SimulationRoiArea(const IDetector *detector)
-    : SimulationArea(detector)
-{}
+SimulationRoiArea::SimulationRoiArea(const IDetector* detector) : SimulationArea(detector) {}
 
 bool SimulationRoiArea::isMasked(size_t) const
 {
diff --git a/Core/Instrument/SimulationArea.h b/Core/Instrument/SimulationArea.h
index 45c0ad05e18..83290bb526a 100644
--- a/Core/Instrument/SimulationArea.h
+++ b/Core/Instrument/SimulationArea.h
@@ -15,8 +15,8 @@
 #ifndef SIMULATIONAREA_H
 #define SIMULATIONAREA_H
 
-#include "WinDllMacros.h"
 #include "SimulationAreaIterator.h"
+#include "WinDllMacros.h"
 
 class IDetector;
 
@@ -55,7 +55,6 @@ inline size_t SimulationArea::totalSize() const
     return m_max_index;
 }
 
-
 //! Holds iteration logic over active detector channels in the presence of ROI. On the contrary
 //! to SimulationArea class, iterates also over masked areas.
 //! @ingroup simulation
@@ -66,7 +65,6 @@ public:
     explicit SimulationRoiArea(const IDetector* detector);
 
     virtual bool isMasked(size_t) const;
-
 };
 
 #endif // SIMULATIONAREA_H
diff --git a/Core/Instrument/SimulationAreaIterator.cpp b/Core/Instrument/SimulationAreaIterator.cpp
index cbb42309e8e..61ddb0c001d 100644
--- a/Core/Instrument/SimulationAreaIterator.cpp
+++ b/Core/Instrument/SimulationAreaIterator.cpp
@@ -13,19 +13,17 @@
 // ************************************************************************** //
 
 #include "SimulationAreaIterator.h"
-#include "SimulationArea.h"
 #include "IDetector2D.h"
+#include "SimulationArea.h"
 
-SimulationAreaIterator::SimulationAreaIterator(const SimulationArea *area, size_t start_at_index)
-    : m_area(area)
-    , m_index(start_at_index)
-    , m_element_index(0)
+SimulationAreaIterator::SimulationAreaIterator(const SimulationArea* area, size_t start_at_index)
+    : m_area(area), m_index(start_at_index), m_element_index(0)
 {
-    if(m_index > m_area->totalSize())
+    if (m_index > m_area->totalSize())
         throw Exceptions::RuntimeErrorException("SimulationAreaIterator::SimulationAreaIterator() "
                                                 "-> Error. Invalid initial index");
 
-    if(m_index != m_area->totalSize() && m_area->isMasked(m_index))
+    if (m_index != m_area->totalSize() && m_area->isMasked(m_index))
         m_index = nextIndex(m_index);
 }
 
@@ -39,10 +37,10 @@ size_t SimulationAreaIterator::detectorIndex() const
     return m_area->detectorIndex(m_index);
 }
 
-SimulationAreaIterator &SimulationAreaIterator::operator++()
+SimulationAreaIterator& SimulationAreaIterator::operator++()
 {
     size_t index = nextIndex(m_index);
-    if(index != m_index) {
+    if (index != m_index) {
         ++m_element_index;
         m_index = index;
     }
@@ -59,10 +57,10 @@ SimulationAreaIterator SimulationAreaIterator::operator++(int)
 size_t SimulationAreaIterator::nextIndex(size_t currentIndex)
 {
     size_t result = ++currentIndex;
-    if(result < m_area->totalSize()) {
-        while(m_area->isMasked(result)) {
+    if (result < m_area->totalSize()) {
+        while (m_area->isMasked(result)) {
             ++result;
-            if(result == m_area->totalSize())
+            if (result == m_area->totalSize())
                 break;
         }
     } else {
@@ -70,4 +68,3 @@ size_t SimulationAreaIterator::nextIndex(size_t currentIndex)
     }
     return result;
 }
-
diff --git a/Core/Instrument/SimulationAreaIterator.h b/Core/Instrument/SimulationAreaIterator.h
index e16ac4d1fa6..0cce544e90b 100644
--- a/Core/Instrument/SimulationAreaIterator.h
+++ b/Core/Instrument/SimulationAreaIterator.h
@@ -25,15 +25,15 @@ class SimulationArea;
 class BA_CORE_API_ SimulationAreaIterator
 {
 public:
-    explicit SimulationAreaIterator(const SimulationArea *area, size_t start_at_index);
+    explicit SimulationAreaIterator(const SimulationArea* area, size_t start_at_index);
 
     size_t index() const { return m_index; }
-    size_t elementIndex() const { return m_element_index;}
-	size_t roiIndex() const;
-	size_t detectorIndex() const;
+    size_t elementIndex() const { return m_element_index; }
+    size_t roiIndex() const;
+    size_t detectorIndex() const;
 
-    bool operator==(const SimulationAreaIterator &other) const;
-    bool operator!=(const SimulationAreaIterator &other) const;
+    bool operator==(const SimulationAreaIterator& other) const;
+    bool operator!=(const SimulationAreaIterator& other) const;
 
     //! prefix increment
     SimulationAreaIterator& operator++();
@@ -43,17 +43,17 @@ public:
 
 private:
     size_t nextIndex(size_t currentIndex);
-    const SimulationArea *m_area;
-    size_t m_index;  //!< global index in detector plane defined by its axes
+    const SimulationArea* m_area;
+    size_t m_index;         //!< global index in detector plane defined by its axes
     size_t m_element_index; //!< sequential number for SimulationElementVector
 };
 
-inline bool SimulationAreaIterator::operator==(const SimulationAreaIterator &other) const
+inline bool SimulationAreaIterator::operator==(const SimulationAreaIterator& other) const
 {
-  return m_area == other.m_area && m_index == other.m_index;
+    return m_area == other.m_area && m_index == other.m_index;
 }
 
-inline bool SimulationAreaIterator::operator!=(const SimulationAreaIterator &right) const
+inline bool SimulationAreaIterator::operator!=(const SimulationAreaIterator& right) const
 {
     return !(*this == right);
 }
diff --git a/Core/Instrument/SimulationResult.cpp b/Core/Instrument/SimulationResult.cpp
index a4f4b279a01..42d52917c42 100644
--- a/Core/Instrument/SimulationResult.cpp
+++ b/Core/Instrument/SimulationResult.cpp
@@ -13,15 +13,13 @@
 // ************************************************************************** //
 
 #include "SimulationResult.h"
-#include "Histogram2D.h"
 #include "FixedBinAxis.h"
+#include "Histogram2D.h"
 #include "OutputData.h"
 
-
 SimulationResult::SimulationResult(const OutputData<double>& data,
-                                     const IUnitConverter& unit_converter)
-    : mP_data(data.clone())
-    , mP_unit_converter(unit_converter.clone())
+                                   const IUnitConverter& unit_converter)
+    : mP_data(data.clone()), mP_unit_converter(unit_converter.clone())
 {
     checkDimensions();
 }
@@ -36,9 +34,9 @@ SimulationResult::SimulationResult(const SimulationResult& other)
 }
 
 SimulationResult::SimulationResult(SimulationResult&& other)
-    : mP_data(std::move(other.mP_data))
-    , mP_unit_converter(std::move(other.mP_unit_converter))
-{}
+    : mP_data(std::move(other.mP_data)), mP_unit_converter(std::move(other.mP_unit_converter))
+{
+}
 
 SimulationResult& SimulationResult::operator=(const SimulationResult& other)
 {
@@ -58,7 +56,7 @@ SimulationResult& SimulationResult::operator=(SimulationResult&& other)
     return *this;
 }
 
-std::unique_ptr<OutputData<double> > SimulationResult::data(AxesUnits units) const
+std::unique_ptr<OutputData<double>> SimulationResult::data(AxesUnits units) const
 {
     if (!mP_data)
         throw std::runtime_error(
@@ -78,13 +76,14 @@ Histogram2D* SimulationResult::histogram2d(AxesUnits units) const
 
 std::vector<AxisInfo> SimulationResult::axisInfo(AxesUnits units) const
 {
-    if (!mP_unit_converter) return {};
+    if (!mP_unit_converter)
+        return {};
     std::vector<AxisInfo> result;
     auto dim = mP_unit_converter->dimension();
-    for (size_t i=0; i<dim; ++i) {
-        AxisInfo info = { mP_unit_converter->axisName(i, units),
-                          mP_unit_converter->calculateMin(i, units),
-                          mP_unit_converter->calculateMax(i, units) };
+    for (size_t i = 0; i < dim; ++i) {
+        AxisInfo info = {mP_unit_converter->axisName(i, units),
+                         mP_unit_converter->calculateMin(i, units),
+                         mP_unit_converter->calculateMax(i, units)};
         result.push_back(info);
     }
     return result;
@@ -100,14 +99,16 @@ const IUnitConverter& SimulationResult::converter() const
 
 double& SimulationResult::operator[](size_t i)
 {
-    if (mP_data) return (*mP_data)[i];
+    if (mP_data)
+        return (*mP_data)[i];
     throw std::runtime_error("Error in SimulationResult::operator[]: "
                              "no data initialized");
 }
 
 const double& SimulationResult::operator[](size_t i) const
 {
-    if (mP_data) return (*mP_data)[i];
+    if (mP_data)
+        return (*mP_data)[i];
     throw std::runtime_error("Error in SimulationResult::operator[]: "
                              "no data initialized");
 }
diff --git a/Core/Instrument/SimulationResult.h b/Core/Instrument/SimulationResult.h
index 22d2ba03274..8701d1a7680 100644
--- a/Core/Instrument/SimulationResult.h
+++ b/Core/Instrument/SimulationResult.h
@@ -16,21 +16,20 @@
 #define SIMULATIONRESULT_H
 
 #include "IUnitConverter.h"
-#include "WinDllMacros.h"
 #include "PyObject.h"
+#include "WinDllMacros.h"
 #include <memory>
 #include <vector>
 
 class Histogram1D;
 class Histogram2D;
 class IAxis;
-template<class T> class OutputData;
+template <class T> class OutputData;
 
 //! Information about an axis in specific units. Can be used for plotting.
 //! @ingroup simulation
 
-struct AxisInfo
-{
+struct AxisInfo {
     std::string m_name;
     double m_min;
     double m_max;
@@ -42,7 +41,7 @@ struct AxisInfo
 class BA_CORE_API_ SimulationResult
 {
 public:
-    SimulationResult() =default;
+    SimulationResult() = default;
     SimulationResult(const OutputData<double>& data, const IUnitConverter& unit_converter);
     SimulationResult(const SimulationResult& other);
     SimulationResult(SimulationResult&& other);
diff --git a/Core/Instrument/SpecularDetector1D.cpp b/Core/Instrument/SpecularDetector1D.cpp
index 17300bb3ed8..61c6f95ff0b 100644
--- a/Core/Instrument/SpecularDetector1D.cpp
+++ b/Core/Instrument/SpecularDetector1D.cpp
@@ -27,11 +27,13 @@ SpecularDetector1D::SpecularDetector1D(const SpecularDetector1D& detector) : IDe
 
 SpecularDetector1D::~SpecularDetector1D() = default;
 
-SpecularDetector1D* SpecularDetector1D::clone() const {
+SpecularDetector1D* SpecularDetector1D::clone() const
+{
     return new SpecularDetector1D(*this);
 }
 
-AxesUnits SpecularDetector1D::defaultAxesUnits() const {
+AxesUnits SpecularDetector1D::defaultAxesUnits() const
+{
     return AxesUnits::RADIANS;
 }
 
diff --git a/Core/Instrument/SpecularDetector1D.h b/Core/Instrument/SpecularDetector1D.h
index 7dd646099ba..c5a355b6fe5 100644
--- a/Core/Instrument/SpecularDetector1D.h
+++ b/Core/Instrument/SpecularDetector1D.h
@@ -22,7 +22,8 @@ class SpecularSimulationElement;
 //! 1D detector for specular simulations. Use of this detector is deprecated.
 //! @ingroup simulation
 
-class BA_CORE_API_ SpecularDetector1D : public IDetector {
+class BA_CORE_API_ SpecularDetector1D : public IDetector
+{
 public:
     SpecularDetector1D(const IAxis& axis);
     virtual ~SpecularDetector1D();
diff --git a/Core/Instrument/SphericalDetector.cpp b/Core/Instrument/SphericalDetector.cpp
index 8a296640724..b9b2c088964 100644
--- a/Core/Instrument/SphericalDetector.cpp
+++ b/Core/Instrument/SphericalDetector.cpp
@@ -12,14 +12,14 @@
 //
 // ************************************************************************** //
 
-#include "Beam.h"
 #include "SphericalDetector.h"
+#include "Beam.h"
 #include "BornAgainNamespace.h"
 #include "IDetectorResolution.h"
 #include "IPixel.h"
+#include "MathConstants.h"
 #include "SimulationElement.h"
 #include "Units.h"
-#include "MathConstants.h"
 
 SphericalDetector::SphericalDetector()
 {
@@ -33,8 +33,7 @@ SphericalDetector::SphericalDetector(size_t n_phi, double phi_min, double phi_ma
     setDetectorParameters(n_phi, phi_min, phi_max, n_alpha, alpha_min, alpha_max);
 }
 
-SphericalDetector::SphericalDetector(const SphericalDetector& other)
-    : IDetector2D(other)
+SphericalDetector::SphericalDetector(const SphericalDetector& other) : IDetector2D(other)
 {
     setName(BornAgain::SphericalDetectorType);
 }
@@ -76,7 +75,8 @@ std::string SphericalDetector::axisName(size_t index) const
 
 size_t SphericalDetector::getIndexOfSpecular(const Beam& beam) const
 {
-    if (dimension()!=2) return totalSize();
+    if (dimension() != 2)
+        return totalSize();
     double alpha = beam.getAlpha();
     double phi = beam.getPhi();
     const IAxis& phi_axis = getAxis(BornAgain::X_AXIS_INDEX);
@@ -87,10 +87,10 @@ size_t SphericalDetector::getIndexOfSpecular(const Beam& beam) const
 }
 
 SphericalPixel::SphericalPixel(const Bin1D& alpha_bin, const Bin1D& phi_bin)
-    : m_alpha(alpha_bin.m_lower), m_phi(phi_bin.m_lower),
-      m_dalpha(alpha_bin.getBinSize()), m_dphi(phi_bin.getBinSize())
+    : m_alpha(alpha_bin.m_lower), m_phi(phi_bin.m_lower), m_dalpha(alpha_bin.getBinSize()),
+      m_dphi(phi_bin.getBinSize())
 {
-    auto solid_angle_value = std::abs(m_dphi*(std::sin(m_alpha+m_dalpha) - std::sin(m_alpha)));
+    auto solid_angle_value = std::abs(m_dphi * (std::sin(m_alpha + m_dalpha) - std::sin(m_alpha)));
     m_solid_angle = solid_angle_value <= 0.0 ? 1.0 : solid_angle_value;
 }
 
@@ -101,8 +101,8 @@ SphericalPixel* SphericalPixel::clone() const
 
 SphericalPixel* SphericalPixel::createZeroSizePixel(double x, double y) const
 {
-    double phi = m_phi + x*m_dphi;
-    double alpha = m_alpha + y*m_dalpha;
+    double phi = m_phi + x * m_dphi;
+    double alpha = m_alpha + y * m_dalpha;
     Bin1D alpha_bin(alpha, alpha);
     Bin1D phi_bin(phi, phi);
     return new SphericalPixel(alpha_bin, phi_bin);
@@ -110,16 +110,17 @@ SphericalPixel* SphericalPixel::createZeroSizePixel(double x, double y) const
 
 kvector_t SphericalPixel::getK(double x, double y, double wavelength) const
 {
-    double phi = m_phi + x*m_dphi;
-    double alpha = m_alpha + y*m_dalpha;
+    double phi = m_phi + x * m_dphi;
+    double alpha = m_alpha + y * m_dalpha;
     return vecOfLambdaAlphaPhi(wavelength, alpha, phi);
 }
 
 double SphericalPixel::getIntegrationFactor(double /* x */, double y) const
 {
-    if (m_dalpha==0.0) return 1.0;
-    double alpha = m_alpha + y*m_dalpha;
-    return std::cos(alpha)*m_dalpha/(std::sin(m_alpha+m_dalpha)-std::sin(m_alpha));
+    if (m_dalpha == 0.0)
+        return 1.0;
+    double alpha = m_alpha + y * m_dalpha;
+    return std::cos(alpha) * m_dalpha / (std::sin(m_alpha + m_dalpha) - std::sin(m_alpha));
 }
 
 double SphericalPixel::getSolidAngle() const
diff --git a/Core/Instrument/SphericalDetector.h b/Core/Instrument/SphericalDetector.h
index a373a8a97db..f74b2622ef3 100644
--- a/Core/Instrument/SphericalDetector.h
+++ b/Core/Instrument/SphericalDetector.h
@@ -34,10 +34,10 @@ public:
     //! @param n_alpha number of alpha-axis bins
     //! @param alpha_min low edge of first alpha-bin
     //! @param alpha_max upper edge of last alpha-bin
-    SphericalDetector(size_t n_phi, double phi_min, double phi_max,
-                      size_t n_alpha, double alpha_min, double alpha_max);
+    SphericalDetector(size_t n_phi, double phi_min, double phi_max, size_t n_alpha,
+                      double alpha_min, double alpha_max);
 
-    SphericalDetector(const SphericalDetector &other);
+    SphericalDetector(const SphericalDetector& other);
 
     SphericalDetector* clone() const override;
 
@@ -71,6 +71,7 @@ public:
     kvector_t getK(double x, double y, double wavelength) const override;
     double getIntegrationFactor(double x, double y) const override;
     double getSolidAngle() const override;
+
 private:
     double m_alpha, m_phi;
     double m_dalpha, m_dphi;
diff --git a/Core/Instrument/UnitConverter1D.cpp b/Core/Instrument/UnitConverter1D.cpp
index 8a0af1e3aff..3d58bc8a26b 100644
--- a/Core/Instrument/UnitConverter1D.cpp
+++ b/Core/Instrument/UnitConverter1D.cpp
@@ -34,16 +34,14 @@ std::unique_ptr<PointwiseAxis>
 createTranslatedAxis(const IAxis& axis, std::function<double(double)> translator, std::string name);
 } // namespace
 
-std::unique_ptr<UnitConverter1D>
-UnitConverter1D::createUnitConverter(const ISpecularScan& handler)
+std::unique_ptr<UnitConverter1D> UnitConverter1D::createUnitConverter(const ISpecularScan& handler)
 {
     if (handler.dataType() == ISpecularScan::angle)
         return std::make_unique<UnitConverterConvSpec>(
             static_cast<const AngularSpecScan&>(handler));
 
     if (handler.dataType() == ISpecularScan::q)
-        return std::make_unique<UnitConverterQSpec>(
-            static_cast<const QSpecScan&>(handler));
+        return std::make_unique<UnitConverterQSpec>(static_cast<const QSpecScan&>(handler));
 
     throw std::runtime_error("No known unit conversions for passed type of specular data handler.");
 }
@@ -115,9 +113,9 @@ UnitConverterConvSpec::UnitConverterConvSpec(const Beam& beam, const IAxis& axis
 }
 
 UnitConverterConvSpec::UnitConverterConvSpec(const AngularSpecScan& handler)
-    : m_wavelength(handler.wavelength())
-    , m_axis(handler.coordinateAxis()->clone())
-{}
+    : m_wavelength(handler.wavelength()), m_axis(handler.coordinateAxis()->clone())
+{
+}
 
 UnitConverterConvSpec::~UnitConverterConvSpec() = default;
 
@@ -126,7 +124,6 @@ UnitConverterConvSpec* UnitConverterConvSpec::clone() const
     return new UnitConverterConvSpec(*this);
 }
 
-
 size_t UnitConverterConvSpec::axisSize(size_t i_axis) const
 {
     checkIndex(i_axis);
@@ -145,8 +142,7 @@ AxesUnits UnitConverterConvSpec::defaultUnits() const
 }
 
 UnitConverterConvSpec::UnitConverterConvSpec(const UnitConverterConvSpec& other)
-    : m_wavelength(other.m_wavelength)
-    , m_axis(other.m_axis->clone())
+    : m_wavelength(other.m_wavelength), m_axis(other.m_axis->clone())
 {
 }
 
@@ -180,9 +176,9 @@ std::function<double(double)> UnitConverterConvSpec::getTraslatorTo(AxesUnits un
     case AxesUnits::DEGREES:
         return [](double value) { return Units::rad2deg(value); };
     case AxesUnits::QSPACE:
-        return [wl=m_wavelength](double value) { return getQ(wl, value); };
+        return [wl = m_wavelength](double value) { return getQ(wl, value); };
     case AxesUnits::RQ4:
-        return [wl=m_wavelength](double value) { return getQ(wl, value); };
+        return [wl = m_wavelength](double value) { return getQ(wl, value); };
     default:
         throwUnitsError("UnitConverterConvSpec::getTraslatorTo", availableUnits());
     }
@@ -190,7 +186,8 @@ std::function<double(double)> UnitConverterConvSpec::getTraslatorTo(AxesUnits un
 
 UnitConverterQSpec::UnitConverterQSpec(const QSpecScan& handler)
     : m_axis(handler.coordinateAxis()->clone())
-{}
+{
+}
 
 UnitConverterQSpec::~UnitConverterQSpec() = default;
 
@@ -220,7 +217,8 @@ AxesUnits UnitConverterQSpec::defaultUnits() const
 
 UnitConverterQSpec::UnitConverterQSpec(const UnitConverterQSpec& other)
     : m_axis(std::unique_ptr<IAxis>(other.coordinateAxis()->clone()))
-{}
+{
+}
 
 //! Creates name map for axis in various units
 std::vector<std::map<AxesUnits, std::string>> UnitConverterQSpec::createNameMaps() const
diff --git a/Core/Instrument/UnitConverter1D.h b/Core/Instrument/UnitConverter1D.h
index bb676623f37..c0a58eaa27a 100644
--- a/Core/Instrument/UnitConverter1D.h
+++ b/Core/Instrument/UnitConverter1D.h
@@ -30,8 +30,7 @@ class BA_CORE_API_ UnitConverter1D : public IUnitConverter
 {
 public:
     //! Factory function to create unit converter for particular type of specular data
-    static std::unique_ptr<UnitConverter1D>
-    createUnitConverter(const ISpecularScan& handler);
+    static std::unique_ptr<UnitConverter1D> createUnitConverter(const ISpecularScan& handler);
 
     ~UnitConverter1D() override = default;
 
@@ -93,7 +92,7 @@ protected:
     //! Returns translating functional (rads --> desired units)
     std::function<double(double)> getTraslatorTo(AxesUnits units_type) const override;
 
-    const IAxis* coordinateAxis() const override {return m_axis.get();}
+    const IAxis* coordinateAxis() const override { return m_axis.get(); }
 
     double m_wavelength;           //!< basic wavelength in nm (for translation to q-space).
     std::unique_ptr<IAxis> m_axis; //!< basic inclination angles (in rads).
diff --git a/Core/Instrument/UnitConverterUtils.cpp b/Core/Instrument/UnitConverterUtils.cpp
index cabb6a135ee..323f6ab847e 100644
--- a/Core/Instrument/UnitConverterUtils.cpp
+++ b/Core/Instrument/UnitConverterUtils.cpp
@@ -13,16 +13,16 @@
 // ************************************************************************** //
 
 #include "UnitConverterUtils.h"
+#include "DepthProbeSimulation.h"
+#include "GISASSimulation.h"
 #include "Instrument.h"
+#include "OffSpecSimulation.h"
 #include "OutputData.h"
 #include "RectangularDetector.h"
 #include "SimpleUnitConverters.h"
+#include "SpecularSimulation.h"
 #include "SphericalDetector.h"
 #include "UnitConverter1D.h"
-#include "GISASSimulation.h"
-#include "OffSpecSimulation.h"
-#include "SpecularSimulation.h"
-#include "DepthProbeSimulation.h"
 
 std::unique_ptr<OutputData<double>>
 UnitConverterUtils::createOutputData(const IUnitConverter& converter, AxesUnits units)
@@ -44,13 +44,12 @@ UnitConverterUtils::createConverterForGISAS(const Instrument& instrument)
     else if (const auto rect_detector = dynamic_cast<const RectangularDetector*>(detector))
         return std::make_unique<RectangularConverter>(*rect_detector, instrument.getBeam());
 
-    throw std::runtime_error(
-        "Error in createConverterForGISAS: wrong or absent detector type");
+    throw std::runtime_error("Error in createConverterForGISAS: wrong or absent detector type");
 }
 
 std::unique_ptr<IUnitConverter> UnitConverterUtils::createConverter(const Simulation& simulation)
 {
-    if(auto gisas = dynamic_cast<const GISASSimulation*>(&simulation)) {
+    if (auto gisas = dynamic_cast<const GISASSimulation*>(&simulation)) {
         return createConverterForGISAS(gisas->getInstrument());
 
     } else if (auto spec = dynamic_cast<const SpecularSimulation*>(&simulation)) {
diff --git a/Core/Instrument/UnitConverterUtils.h b/Core/Instrument/UnitConverterUtils.h
index 5f3bb1ec0ff..0770fde04f8 100644
--- a/Core/Instrument/UnitConverterUtils.h
+++ b/Core/Instrument/UnitConverterUtils.h
@@ -19,16 +19,16 @@
 
 class Instrument;
 class Simulation;
-template<class T> class OutputData;
+template <class T> class OutputData;
 
 //! Namespace enclosing a number of utilities/helpers for unit converters
 
-namespace UnitConverterUtils {
+namespace UnitConverterUtils
+{
 
 inline AxesUnits substituteDefaultUnits(const IUnitConverter& converter, AxesUnits units)
 {
-    return units == AxesUnits::DEFAULT ? converter.defaultUnits()
-                                       : units;
+    return units == AxesUnits::DEFAULT ? converter.defaultUnits() : units;
 }
 
 //! Returns zero-valued output data array in specified units
@@ -40,6 +40,6 @@ BA_CORE_API_ std::unique_ptr<OutputData<double>> createOutputData(const IUnitCon
 BA_CORE_API_ std::unique_ptr<IUnitConverter> createConverterForGISAS(const Instrument& instrument);
 
 BA_CORE_API_ std::unique_ptr<IUnitConverter> createConverter(const Simulation& simulation);
-}
+} // namespace UnitConverterUtils
 
 #endif // UNITCONVERTERUTILS_H
diff --git a/Core/Instrument/VarianceFunctions.cpp b/Core/Instrument/VarianceFunctions.cpp
index 16e3565957d..cf68e5cbf93 100644
--- a/Core/Instrument/VarianceFunctions.cpp
+++ b/Core/Instrument/VarianceFunctions.cpp
@@ -28,9 +28,7 @@ double VarianceConstantFunction::variance(double, double) const
     return 1.0;
 }
 
-VarianceSimFunction::VarianceSimFunction(double epsilon) : m_epsilon(epsilon)
-{
-}
+VarianceSimFunction::VarianceSimFunction(double epsilon) : m_epsilon(epsilon) {}
 
 VarianceSimFunction* VarianceSimFunction::clone() const
 {
diff --git a/Core/Lattice/ILatticeOrientation.cpp b/Core/Lattice/ILatticeOrientation.cpp
index bee6baa1832..92ed62cd3f1 100644
--- a/Core/Lattice/ILatticeOrientation.cpp
+++ b/Core/Lattice/ILatticeOrientation.cpp
@@ -15,32 +15,27 @@
 #include "ILatticeOrientation.h"
 #include "EigenCore.h"
 
-namespace {
+namespace
+{
 bool ValidMillerIndex(MillerIndex index);
-bool ParallelMillerIndices(MillerIndex index1,
-                           MillerIndex index2);
+bool ParallelMillerIndices(MillerIndex index1, MillerIndex index2);
 double SignForCrossProduct(MillerIndexOrientation::QComponent q1,
                            MillerIndexOrientation::QComponent q2);
 MillerIndexOrientation::QComponent ThirdQComponent(MillerIndexOrientation::QComponent q1,
                                                    MillerIndexOrientation::QComponent q2);
 void FillVectorInRow(Eigen::Matrix3d& matrix, kvector_t vec,
                      MillerIndexOrientation::QComponent row);
-}  // unnamed namespace
-
+} // unnamed namespace
 
-ILatticeOrientation::~ILatticeOrientation() =default;
+ILatticeOrientation::~ILatticeOrientation() = default;
 
-MillerIndex::MillerIndex(double h_, double k_, double l_)
-    : h(h_), k(k_), l(l_)
-{}
+MillerIndex::MillerIndex(double h_, double k_, double l_) : h(h_), k(k_), l(l_) {}
 
-MillerIndexOrientation::MillerIndexOrientation(
-        MillerIndexOrientation::QComponent q1, MillerIndex index1,
-        MillerIndexOrientation::QComponent q2, MillerIndex index2)
-    : m_prim_lattice()
-    , m_q1(q1), m_q2(q2)
-    , m_ind1 { index1 }
-    , m_ind2 { index2 }
+MillerIndexOrientation::MillerIndexOrientation(MillerIndexOrientation::QComponent q1,
+                                               MillerIndex index1,
+                                               MillerIndexOrientation::QComponent q2,
+                                               MillerIndex index2)
+    : m_prim_lattice(), m_q1(q1), m_q2(q2), m_ind1{index1}, m_ind2{index2}
 {
     if (!checkAlignment())
         throw std::runtime_error("MillerIndexOrientation constructor: "
@@ -54,7 +49,7 @@ MillerIndexOrientation* MillerIndexOrientation::clone() const
     return P_result.release();
 }
 
-MillerIndexOrientation::~MillerIndexOrientation() =default;
+MillerIndexOrientation::~MillerIndexOrientation() = default;
 
 void MillerIndexOrientation::usePrimitiveLattice(const Lattice& lattice)
 {
@@ -88,13 +83,13 @@ bool MillerIndexOrientation::checkAlignment() const
     return true;
 }
 
-namespace {
+namespace
+{
 bool ValidMillerIndex(MillerIndex index)
 {
     return (index.h != 0.0 || index.k != 0.0 || index.l != 0.0);
 }
-bool ParallelMillerIndices(MillerIndex index1,
-                           MillerIndex index2)
+bool ParallelMillerIndices(MillerIndex index1, MillerIndex index2)
 {
     double ratio = 0.0;
     if (index2.h != 0.0) {
@@ -104,15 +99,17 @@ bool ParallelMillerIndices(MillerIndex index1,
     } else if (index2.l != 0.0) {
         ratio = index1.l / index2.l;
     }
-    if (ratio == 0.0) return false;
-    return (index1.h == ratio*index2.h && index1.k == ratio*index2.k && index1.l == ratio*index2.l);
+    if (ratio == 0.0)
+        return false;
+    return (index1.h == ratio * index2.h && index1.k == ratio * index2.k
+            && index1.l == ratio * index2.l);
 }
 double SignForCrossProduct(MillerIndexOrientation::QComponent q1,
                            MillerIndexOrientation::QComponent q2)
 {
-    if ((q1 == MillerIndexOrientation::QX && q2 == MillerIndexOrientation::QY) ||
-        (q1 == MillerIndexOrientation::QY && q2 == MillerIndexOrientation::QZ) ||
-        (q1 == MillerIndexOrientation::QZ && q2 == MillerIndexOrientation::QX) )
+    if ((q1 == MillerIndexOrientation::QX && q2 == MillerIndexOrientation::QY)
+        || (q1 == MillerIndexOrientation::QY && q2 == MillerIndexOrientation::QZ)
+        || (q1 == MillerIndexOrientation::QZ && q2 == MillerIndexOrientation::QX))
         return 1.0;
     return -1.0;
 }
@@ -125,13 +122,10 @@ MillerIndexOrientation::QComponent ThirdQComponent(MillerIndexOrientation::QComp
         return MillerIndexOrientation::QY;
     return MillerIndexOrientation::QZ;
 }
-void FillVectorInRow(Eigen::Matrix3d& mat, kvector_t vec,
-                     MillerIndexOrientation::QComponent row)
+void FillVectorInRow(Eigen::Matrix3d& mat, kvector_t vec, MillerIndexOrientation::QComponent row)
 {
-    int i = row == MillerIndexOrientation::QX ? 0
-          : row == MillerIndexOrientation::QY ? 1 : 2;
-    for (int j=0; j<3; ++j)
+    int i = row == MillerIndexOrientation::QX ? 0 : row == MillerIndexOrientation::QY ? 1 : 2;
+    for (int j = 0; j < 3; ++j)
         mat(i, j) = vec[j];
 }
-}  // unnamed namespace
-
+} // unnamed namespace
diff --git a/Core/Lattice/ILatticeOrientation.h b/Core/Lattice/ILatticeOrientation.h
index b5f34607493..2c3d251a690 100644
--- a/Core/Lattice/ILatticeOrientation.h
+++ b/Core/Lattice/ILatticeOrientation.h
@@ -23,11 +23,11 @@ class BA_CORE_API_ ILatticeOrientation
 public:
     virtual ~ILatticeOrientation();
 
-    virtual ILatticeOrientation* clone() const=0;
+    virtual ILatticeOrientation* clone() const = 0;
 
-    virtual void usePrimitiveLattice(const Lattice& lattice) =0;
+    virtual void usePrimitiveLattice(const Lattice& lattice) = 0;
 
-    virtual Transform3D transformationMatrix() const=0;
+    virtual Transform3D transformationMatrix() const = 0;
 };
 
 //! A direction in reciprocal space, specified by double-valued indices hkl.
@@ -47,8 +47,7 @@ public:
     //! Arguments QX, (1,1,0), QY, (0,2,1) mean:
     //! Rotate the lattice such that the axis [110] points into x direction,
     //! and the axis [021], projected into the yz plane, points into z direction.
-    MillerIndexOrientation(QComponent q1, MillerIndex index1,
-                           QComponent q2, MillerIndex index2);
+    MillerIndexOrientation(QComponent q1, MillerIndex index1, QComponent q2, MillerIndex index2);
     ~MillerIndexOrientation() override;
 
     MillerIndexOrientation* clone() const override;
@@ -56,6 +55,7 @@ public:
     void usePrimitiveLattice(const Lattice& lattice) override;
 
     Transform3D transformationMatrix() const override;
+
 private:
     bool checkAlignment() const;
     Lattice m_prim_lattice;
diff --git a/Core/Lattice/ISelectionRule.h b/Core/Lattice/ISelectionRule.h
index 338036dc71c..8add12f5df2 100644
--- a/Core/Lattice/ISelectionRule.h
+++ b/Core/Lattice/ISelectionRule.h
@@ -25,9 +25,9 @@ class BA_CORE_API_ ISelectionRule
 public:
     virtual ~ISelectionRule() {}
 
-    virtual ISelectionRule* clone() const=0;
+    virtual ISelectionRule* clone() const = 0;
 
-    virtual bool coordinateSelected(const ivector_t& coordinate) const=0;
+    virtual bool coordinateSelected(const ivector_t& coordinate) const = 0;
 };
 
 //! Selection rule (v*q)%modulus!=0, defined by vector v(a,b,c) and modulus.
@@ -42,13 +42,16 @@ public:
     virtual SimpleSelectionRule* clone() const;
 
     virtual bool coordinateSelected(const ivector_t& coordinate) const;
+
 private:
     int m_a, m_b, m_c;
     int m_mod;
 };
 
 inline SimpleSelectionRule::SimpleSelectionRule(int a, int b, int c, int modulus)
-    : m_a(a), m_b(b), m_c(c), m_mod(modulus) {}
+    : m_a(a), m_b(b), m_c(c), m_mod(modulus)
+{
+}
 
 inline SimpleSelectionRule* SimpleSelectionRule::clone() const
 {
@@ -57,7 +60,7 @@ inline SimpleSelectionRule* SimpleSelectionRule::clone() const
 
 inline bool SimpleSelectionRule::coordinateSelected(const ivector_t& coordinate) const
 {
-    return (m_a*coordinate[0]+m_b*coordinate[1]+m_c*coordinate[2])%m_mod == 0;
+    return (m_a * coordinate[0] + m_b * coordinate[1] + m_c * coordinate[2]) % m_mod == 0;
 }
 
 #endif // ISELECTIONRULE_H
diff --git a/Core/Lattice/Lattice.cpp b/Core/Lattice/Lattice.cpp
index c28f79775c3..fd184efefd7 100644
--- a/Core/Lattice/Lattice.cpp
+++ b/Core/Lattice/Lattice.cpp
@@ -21,11 +21,8 @@
 #include <gsl/gsl_linalg.h>
 
 Lattice::Lattice()
-    : mp_selection_rule(nullptr)
-    , m_a( {1.0, 0.0, 0.0} )
-    , m_b( {0.0, 1.0, 0.0} )
-    , m_c( {0.0, 0.0, 1.0} )
-    , m_cache_ok(false)
+    : mp_selection_rule(nullptr), m_a({1.0, 0.0, 0.0}), m_b({0.0, 1.0, 0.0}), m_c({0.0, 0.0, 1.0}),
+      m_cache_ok(false)
 {
     setName(BornAgain::LatticeType);
     initialize();
@@ -33,11 +30,7 @@ Lattice::Lattice()
 }
 
 Lattice::Lattice(const kvector_t a1, const kvector_t a2, const kvector_t a3)
-    : mp_selection_rule(nullptr)
-    , m_a(a1)
-    , m_b(a2)
-    , m_c(a3)
-    , m_cache_ok(false)
+    : mp_selection_rule(nullptr), m_a(a1), m_b(a2), m_c(a3), m_cache_ok(false)
 {
     setName(BornAgain::LatticeType);
     initialize();
@@ -45,15 +38,13 @@ Lattice::Lattice(const kvector_t a1, const kvector_t a2, const kvector_t a3)
 }
 
 Lattice::Lattice(const Lattice& lattice)
-    : mp_selection_rule(nullptr)
-    , m_a(lattice.m_a)
-    , m_b(lattice.m_b)
-    , m_c(lattice.m_c)
-    , m_cache_ok(false)
+    : mp_selection_rule(nullptr), m_a(lattice.m_a), m_b(lattice.m_b), m_c(lattice.m_c),
+      m_cache_ok(false)
 {
     setName(BornAgain::LatticeType);
     initialize();
-    if( lattice.mp_selection_rule ) setSelectionRule(*lattice.mp_selection_rule);
+    if (lattice.mp_selection_rule)
+        setSelectionRule(*lattice.mp_selection_rule);
     registerBasisVectors();
 }
 
@@ -68,7 +59,8 @@ Lattice Lattice::createTransformedLattice(const Transform3D& transform) const
     kvector_t a2 = transform.transformed(m_b);
     kvector_t a3 = transform.transformed(m_c);
     Lattice result = Lattice(a1, a2, a3);
-    if (mp_selection_rule) result.setSelectionRule(*mp_selection_rule);
+    if (mp_selection_rule)
+        result.setSelectionRule(*mp_selection_rule);
     return result;
 }
 
@@ -90,17 +82,16 @@ kvector_t Lattice::getMillerDirection(double h, double k, double l) const
 {
     kvector_t b1, b2, b3;
     getReciprocalLatticeBasis(b1, b2, b3);
-    kvector_t direction = h*b1 + k*b2 + l*b3;
+    kvector_t direction = h * b1 + k * b2 + l * b3;
     return direction.unit();
 }
 
 double Lattice::volume() const
 {
-    return std::abs(m_a.dot( m_b.cross(m_c)));
+    return std::abs(m_a.dot(m_b.cross(m_c)));
 }
 
-void Lattice::getReciprocalLatticeBasis(kvector_t &b1, kvector_t &b2,
-        kvector_t &b3) const
+void Lattice::getReciprocalLatticeBasis(kvector_t& b1, kvector_t& b2, kvector_t& b3) const
 {
     if (!m_cache_ok) {
         initialize();
@@ -113,9 +104,9 @@ void Lattice::getReciprocalLatticeBasis(kvector_t &b1, kvector_t &b2,
 
 ivector_t Lattice::getNearestLatticeVectorCoordinates(const kvector_t vector_in) const
 {
-    double a1_coord = vector_in.dot(m_ra)/M_TWOPI;
-    double a2_coord = vector_in.dot(m_rb)/M_TWOPI;
-    double a3_coord = vector_in.dot(m_rc)/M_TWOPI;
+    double a1_coord = vector_in.dot(m_ra) / M_TWOPI;
+    double a2_coord = vector_in.dot(m_rb) / M_TWOPI;
+    double a3_coord = vector_in.dot(m_rc) / M_TWOPI;
     int c1 = static_cast<int>(std::floor(a1_coord + 0.5));
     int c2 = static_cast<int>(std::floor(a2_coord + 0.5));
     int c3 = static_cast<int>(std::floor(a3_coord + 0.5));
@@ -124,23 +115,23 @@ ivector_t Lattice::getNearestLatticeVectorCoordinates(const kvector_t vector_in)
 
 ivector_t Lattice::getNearestReciprocalLatticeVectorCoordinates(const kvector_t vector_in) const
 {
-    double b1_coord = vector_in.dot(m_a)/M_TWOPI;
-    double b2_coord = vector_in.dot(m_b)/M_TWOPI;
-    double b3_coord = vector_in.dot(m_c)/M_TWOPI;
+    double b1_coord = vector_in.dot(m_a) / M_TWOPI;
+    double b2_coord = vector_in.dot(m_b) / M_TWOPI;
+    double b3_coord = vector_in.dot(m_c) / M_TWOPI;
     int c1 = static_cast<int>(std::floor(b1_coord + 0.5));
     int c2 = static_cast<int>(std::floor(b2_coord + 0.5));
     int c3 = static_cast<int>(std::floor(b3_coord + 0.5));
     return ivector_t(c1, c2, c3);
 }
 
-std::vector<kvector_t> Lattice::reciprocalLatticeVectorsWithinRadius(
-        const kvector_t input_vector, double radius) const
+std::vector<kvector_t> Lattice::reciprocalLatticeVectorsWithinRadius(const kvector_t input_vector,
+                                                                     double radius) const
 {
     if (!m_cache_ok)
         initialize();
     ivector_t nearest_coords = getNearestReciprocalLatticeVectorCoordinates(input_vector);
-    return vectorsWithinRadius(
-        input_vector, nearest_coords, radius, m_ra, m_rb, m_rc, m_a, m_b, m_c);
+    return vectorsWithinRadius(input_vector, nearest_coords, radius, m_ra, m_rb, m_rc, m_a, m_b,
+                               m_c);
 }
 
 Lattice Lattice::createCubicLattice(double a)
@@ -153,7 +144,7 @@ Lattice Lattice::createCubicLattice(double a)
 
 Lattice Lattice::createFCCLattice(double a)
 {
-    double b = a/2.0;
+    double b = a / 2.0;
     kvector_t a1(0.0, b, b);
     kvector_t a2(b, 0.0, b);
     kvector_t a3(b, b, 0.0);
@@ -163,7 +154,7 @@ Lattice Lattice::createFCCLattice(double a)
 Lattice Lattice::createHexagonalLattice(double a, double c)
 {
     kvector_t a1(a, 0.0, 0.0);
-    kvector_t a2(-a/2.0, std::sqrt(3.0)*a/2.0, 0.0);
+    kvector_t a2(-a / 2.0, std::sqrt(3.0) * a / 2.0, 0.0);
     kvector_t a3(0.0, 0.0, c);
     return Lattice(a1, a2, a3);
 }
@@ -171,8 +162,8 @@ Lattice Lattice::createHexagonalLattice(double a, double c)
 Lattice Lattice::createHCPLattice(double a, double c)
 {
     kvector_t a1(a, 0.0, 0.0);
-    kvector_t a2(-a/2.0, std::sqrt(3.0)*a/2.0, 0);
-    kvector_t a3(a/2.0, a/std::sqrt(3.0)/2.0, c/2.0);
+    kvector_t a2(-a / 2.0, std::sqrt(3.0) * a / 2.0, 0);
+    kvector_t a3(a / 2.0, a / std::sqrt(3.0) / 2.0, c / 2.0);
     return Lattice(a1, a2, a3);
 }
 
@@ -188,7 +179,7 @@ Lattice Lattice::createBCTLattice(double a, double c)
 {
     kvector_t a1(a, 0.0, 0.0);
     kvector_t a2(0.0, a, 0.0);
-    kvector_t a3(a/2.0, a/2.0, c/2.0);
+    kvector_t a3(a / 2.0, a / 2.0, c / 2.0);
     return Lattice(a1, a2, a3);
 }
 
@@ -199,7 +190,7 @@ void Lattice::onChange()
 
 void Lattice::registerBasisVectors()
 {
-    if(!parameter(XComponentName(BornAgain::BasisVector_A))) {
+    if (!parameter(XComponentName(BornAgain::BasisVector_A))) {
         registerVector(BornAgain::BasisVector_A, &m_a, BornAgain::UnitsNm);
         registerVector(BornAgain::BasisVector_B, &m_b, BornAgain::UnitsNm);
         registerVector(BornAgain::BasisVector_C, &m_c, BornAgain::UnitsNm);
@@ -211,29 +202,31 @@ void Lattice::computeReciprocalVectors() const
     kvector_t a23 = m_b.cross(m_c);
     kvector_t a31 = m_c.cross(m_a);
     kvector_t a12 = m_a.cross(m_b);
-    m_ra = M_TWOPI/m_a.dot(a23)*a23;
-    m_rb = M_TWOPI/m_b.dot(a31)*a31;
-    m_rc = M_TWOPI/m_c.dot(a12)*a12;
+    m_ra = M_TWOPI / m_a.dot(a23) * a23;
+    m_rb = M_TWOPI / m_b.dot(a31) * a31;
+    m_rc = M_TWOPI / m_c.dot(a12) * a12;
 }
 
-std::vector<kvector_t> Lattice::vectorsWithinRadius(
-    const kvector_t input_vector, const ivector_t& nearest_coords, double radius,
-    const kvector_t v1, const kvector_t v2, const kvector_t v3,
-    const kvector_t rec1, const kvector_t rec2, const kvector_t rec3) const
+std::vector<kvector_t> Lattice::vectorsWithinRadius(const kvector_t input_vector,
+                                                    const ivector_t& nearest_coords, double radius,
+                                                    const kvector_t v1, const kvector_t v2,
+                                                    const kvector_t v3, const kvector_t rec1,
+                                                    const kvector_t rec2,
+                                                    const kvector_t rec3) const
 {
-    int max_X = static_cast<int>(std::floor(rec1.mag()*radius/M_TWOPI + 0.5));
-    int max_Y = static_cast<int>(std::floor(rec2.mag()*radius/M_TWOPI + 0.5));
-    int max_Z = static_cast<int>(std::floor(rec3.mag()*radius/M_TWOPI + 0.5));
+    int max_X = static_cast<int>(std::floor(rec1.mag() * radius / M_TWOPI + 0.5));
+    int max_Y = static_cast<int>(std::floor(rec2.mag() * radius / M_TWOPI + 0.5));
+    int max_Z = static_cast<int>(std::floor(rec3.mag() * radius / M_TWOPI + 0.5));
 
     std::vector<kvector_t> ret;
     for (int index_X = -max_X; index_X <= max_X; ++index_X) {
         for (int index_Y = -max_Y; index_Y <= max_Y; ++index_Y) {
             for (int index_Z = -max_Z; index_Z <= max_Z; ++index_Z) {
-                ivector_t coords(index_X + nearest_coords[0],
-                                 index_Y + nearest_coords[1], index_Z + nearest_coords[2]);
+                ivector_t coords(index_X + nearest_coords[0], index_Y + nearest_coords[1],
+                                 index_Z + nearest_coords[2]);
                 if (mp_selection_rule && !mp_selection_rule->coordinateSelected(coords))
                     continue;
-                kvector_t latticePoint = coords[0]*v1 + coords[1]*v2 + coords[2]*v3;
+                kvector_t latticePoint = coords[0] * v1 + coords[1] * v2 + coords[2] * v3;
                 if ((latticePoint - input_vector).mag() <= radius)
                     ret.push_back(latticePoint);
             }
@@ -242,12 +235,12 @@ std::vector<kvector_t> Lattice::vectorsWithinRadius(
     return ret;
 }
 
-void Lattice::computeInverseVectors(const kvector_t v1, const kvector_t v2,
-        const kvector_t v3, kvector_t o1, kvector_t o2, kvector_t o3)
+void Lattice::computeInverseVectors(const kvector_t v1, const kvector_t v2, const kvector_t v3,
+                                    kvector_t o1, kvector_t o2, kvector_t o3)
 {
     gsl_matrix* p_basisMatrix = gsl_matrix_alloc(3, 3);
     gsl_matrix* p_inverseMatrix = gsl_matrix_alloc(3, 3);
-    gsl_permutation* p_perm = gsl_permutation_alloc (3);
+    gsl_permutation* p_perm = gsl_permutation_alloc(3);
     int s;
 
     gsl_matrix_set(p_basisMatrix, 0, 0, v1.x());
@@ -282,7 +275,8 @@ void Lattice::computeInverseVectors(const kvector_t v1, const kvector_t v2,
     gsl_matrix_free(p_inverseMatrix);
 }
 
-void Lattice::setSelectionRule(const ISelectionRule& p_selection_rule) {
+void Lattice::setSelectionRule(const ISelectionRule& p_selection_rule)
+{
     delete mp_selection_rule;
     mp_selection_rule = p_selection_rule.clone();
 }
diff --git a/Core/Lattice/Lattice.h b/Core/Lattice/Lattice.h
index 50f3239f75c..894da9cd72f 100644
--- a/Core/Lattice/Lattice.h
+++ b/Core/Lattice/Lattice.h
@@ -69,8 +69,8 @@ public:
     ivector_t getNearestReciprocalLatticeVectorCoordinates(const kvector_t vector_in) const;
 
     //! Computes a list of reciprocal lattice vectors within a specified distance of a given vector
-    std::vector<kvector_t> reciprocalLatticeVectorsWithinRadius(
-        const kvector_t input_vector, double radius) const;
+    std::vector<kvector_t> reciprocalLatticeVectorsWithinRadius(const kvector_t input_vector,
+                                                                double radius) const;
 
     //! Sets a selection rule for the reciprocal vectors
     void setSelectionRule(const ISelectionRule& p_selection_rule);
@@ -101,17 +101,17 @@ private:
 
     void registerBasisVectors();
 
-    std::vector<kvector_t> vectorsWithinRadius(
-        const kvector_t input_vector, const ivector_t& nearest_coords, double radius,
-        const kvector_t v1, const kvector_t v2, const kvector_t v3,
-        const kvector_t rec1, const kvector_t rec2, const kvector_t rec3) const;
+    std::vector<kvector_t> vectorsWithinRadius(const kvector_t input_vector,
+                                               const ivector_t& nearest_coords, double radius,
+                                               const kvector_t v1, const kvector_t v2,
+                                               const kvector_t v3, const kvector_t rec1,
+                                               const kvector_t rec2, const kvector_t rec3) const;
 
     void computeReciprocalVectors() const;
-    static void computeInverseVectors(
-        const kvector_t v1, const kvector_t v2, const kvector_t v3,
-        kvector_t o1, kvector_t o2, kvector_t o3);
+    static void computeInverseVectors(const kvector_t v1, const kvector_t v2, const kvector_t v3,
+                                      kvector_t o1, kvector_t o2, kvector_t o3);
     ISelectionRule* mp_selection_rule;
-    kvector_t m_a, m_b, m_c; //!< Basis vectors in real space
+    kvector_t m_a, m_b, m_c;            //!< Basis vectors in real space
     mutable kvector_t m_ra, m_rb, m_rc; //!< Cache of basis vectors in reciprocal space
     //! Boolean indicating if the reciprocal vectors are already initialized in the cache
     mutable bool m_cache_ok;
diff --git a/Core/Lattice/Lattice2D.cpp b/Core/Lattice/Lattice2D.cpp
index 267a8d9f895..380053a5b1e 100644
--- a/Core/Lattice/Lattice2D.cpp
+++ b/Core/Lattice/Lattice2D.cpp
@@ -14,14 +14,12 @@
 
 #include "Lattice2D.h"
 #include "BornAgainNamespace.h"
-#include "RealParameter.h"
 #include "MathConstants.h"
 #include "ParameterPool.h"
+#include "RealParameter.h"
 #include <cmath>
 
-Lattice2D::Lattice2D(double rotation_angle)
-    : m_xi(rotation_angle)
-{}
+Lattice2D::Lattice2D(double rotation_angle) : m_xi(rotation_angle) {}
 
 Lattice2D::ReciprocalBases Lattice2D::reciprocalBases() const
 {
@@ -31,20 +29,17 @@ Lattice2D::ReciprocalBases Lattice2D::reciprocalBases() const
     double xi = rotationAngle();
     double xialpha = xi + latticeAngle();
 
-    return {+ainv * std::sin(xialpha),
-            -ainv * std::cos(xialpha),
-            -binv * std::sin(xi),
+    return {+ainv * std::sin(xialpha), -ainv * std::cos(xialpha), -binv * std::sin(xi),
             +binv * std::cos(xi)};
 }
 
 void Lattice2D::onChange()
 {
-    if(parent())
+    if (parent())
         parent()->onChange();
 }
 
-Lattice2D::Lattice2D(const Lattice2D& other)
-    : ICloneable()
+Lattice2D::Lattice2D(const Lattice2D& other) : ICloneable()
 {
     m_xi = other.m_xi;
     setName(other.getName());
@@ -52,8 +47,8 @@ Lattice2D::Lattice2D(const Lattice2D& other)
 
 void Lattice2D::setRotationEnabled(bool enabled)
 {
-    if(enabled) {
-        if(parameter(BornAgain::Xi))
+    if (enabled) {
+        if (parameter(BornAgain::Xi))
             return;
 
         registerParameter(BornAgain::Xi, &m_xi).setUnit(BornAgain::UnitsRad);
@@ -66,12 +61,9 @@ void Lattice2D::setRotationEnabled(bool enabled)
 // --------------------------------------------------------------------------------------------- //
 
 BasicLattice::BasicLattice(double length1, double length2, double angle, double rotation_angle)
-    : Lattice2D(rotation_angle)
-    , m_length1(length1)
-    , m_length2(length2)
-    , m_angle(angle)
+    : Lattice2D(rotation_angle), m_length1(length1), m_length2(length2), m_angle(angle)
 {
-    if(m_length1 <= 0.0 || m_length2 <= 0.0)
+    if (m_length1 <= 0.0 || m_length2 <= 0.0)
         throw std::runtime_error("BasicLattice::BasicLattice() -> Error. Lattice length can't be "
                                  "negative or zero.");
 
@@ -86,23 +78,23 @@ BasicLattice* BasicLattice::clone() const
 
 double BasicLattice::unitCellArea() const
 {
-    return std::abs(m_length1*m_length2*std::sin(m_angle));
+    return std::abs(m_length1 * m_length2 * std::sin(m_angle));
 }
 
 BasicLattice::BasicLattice(const BasicLattice& other)
-    : Lattice2D(other)
-    , m_length1(other.m_length1)
-    , m_length2(other.m_length2)
-    , m_angle(other.m_angle)
+    : Lattice2D(other), m_length1(other.m_length1), m_length2(other.m_length2),
+      m_angle(other.m_angle)
 {
     init_parameters();
 }
 
 void BasicLattice::init_parameters()
 {
-    registerParameter(BornAgain::LatticeLength1, &m_length1).setUnit(BornAgain::UnitsNm)
+    registerParameter(BornAgain::LatticeLength1, &m_length1)
+        .setUnit(BornAgain::UnitsNm)
         .setPositive();
-    registerParameter(BornAgain::LatticeLength2, &m_length2).setUnit(BornAgain::UnitsNm)
+    registerParameter(BornAgain::LatticeLength2, &m_length2)
+        .setUnit(BornAgain::UnitsNm)
         .setPositive();
     registerParameter(BornAgain::LatticeAngle, &m_angle).setUnit(BornAgain::UnitsRad);
     registerParameter(BornAgain::Xi, &m_xi).setUnit(BornAgain::UnitsRad);
@@ -111,10 +103,9 @@ void BasicLattice::init_parameters()
 // --------------------------------------------------------------------------------------------- //
 
 SquareLattice::SquareLattice(double length, double rotation_angle)
-    : Lattice2D(rotation_angle)
-    , m_length(length)
+    : Lattice2D(rotation_angle), m_length(length)
 {
-    if(m_length <= 0.0)
+    if (m_length <= 0.0)
         throw std::runtime_error("SquareLattice::SquareLattice() -> Error. Lattice length can't be "
                                  "negative or zero.");
 
@@ -129,24 +120,24 @@ SquareLattice* SquareLattice::clone() const
 
 double SquareLattice::latticeAngle() const
 {
-    return M_PI/2.0;
+    return M_PI / 2.0;
 }
 
 double SquareLattice::unitCellArea() const
 {
-    return std::abs(m_length*m_length);
+    return std::abs(m_length * m_length);
 }
 
 SquareLattice::SquareLattice(const SquareLattice& other)
-    : Lattice2D(other)
-    , m_length(other.m_length)
+    : Lattice2D(other), m_length(other.m_length)
 {
     init_parameters();
 }
 
 void SquareLattice::init_parameters()
 {
-    registerParameter(BornAgain::LatticeLength, &m_length).setUnit(BornAgain::UnitsNm)
+    registerParameter(BornAgain::LatticeLength, &m_length)
+        .setUnit(BornAgain::UnitsNm)
         .setPositive();
     registerParameter(BornAgain::Xi, &m_xi).setUnit(BornAgain::UnitsRad);
 }
@@ -154,10 +145,9 @@ void SquareLattice::init_parameters()
 // --------------------------------------------------------------------------------------------- //
 
 HexagonalLattice::HexagonalLattice(double length, double rotation_angle)
-    : Lattice2D(rotation_angle)
-    , m_length(length)
+    : Lattice2D(rotation_angle), m_length(length)
 {
-    if(m_length <= 0.0)
+    if (m_length <= 0.0)
         throw std::runtime_error("HexagonalLattice::HexagonalLattice() -> Error. "
                                  "Lattice length can't be negative or zero.");
 
@@ -172,25 +162,25 @@ HexagonalLattice* HexagonalLattice::clone() const
 
 double HexagonalLattice::latticeAngle() const
 {
-    return M_TWOPI/3.0;
+    return M_TWOPI / 3.0;
 }
 
 double HexagonalLattice::unitCellArea() const
 {
     static const double sinval = std::sin(latticeAngle());
-    return std::abs(m_length*m_length*sinval);
+    return std::abs(m_length * m_length * sinval);
 }
 
 HexagonalLattice::HexagonalLattice(const HexagonalLattice& other)
-    : Lattice2D(other)
-    , m_length(other.m_length)
+    : Lattice2D(other), m_length(other.m_length)
 {
     init_parameters();
 }
 
 void HexagonalLattice::init_parameters()
 {
-    registerParameter(BornAgain::LatticeLength, &m_length).setUnit(BornAgain::UnitsNm)
+    registerParameter(BornAgain::LatticeLength, &m_length)
+        .setUnit(BornAgain::UnitsNm)
         .setPositive();
     registerParameter(BornAgain::Xi, &m_xi).setUnit(BornAgain::UnitsRad);
 }
diff --git a/Core/Lattice/Lattice2D.h b/Core/Lattice/Lattice2D.h
index fbbf26ae0a0..11d918f3636 100644
--- a/Core/Lattice/Lattice2D.h
+++ b/Core/Lattice/Lattice2D.h
@@ -29,10 +29,10 @@ public:
         double m_bsx, m_bsy; //!< x,y coordinates of b*
     };
 
-    virtual double length1() const=0;
-    virtual double length2() const=0;
-    virtual double latticeAngle() const=0;
-    virtual double unitCellArea() const=0;
+    virtual double length1() const = 0;
+    virtual double length2() const = 0;
+    virtual double latticeAngle() const = 0;
+    virtual double unitCellArea() const = 0;
 
     double rotationAngle() const { return m_xi; }
 
diff --git a/Core/Lattice/LatticeUtils.cpp b/Core/Lattice/LatticeUtils.cpp
index 440c7ea905e..5b5d8c30922 100644
--- a/Core/Lattice/LatticeUtils.cpp
+++ b/Core/Lattice/LatticeUtils.cpp
@@ -26,9 +26,9 @@ Lattice LatticeUtils::CreateFCCLattice(double lattice_constant,
     return fcc.createTransformedLattice(rotation);
 }
 
-Lattice LatticeUtils::CreateHCPLattice(double a, double c, const ILatticeOrientation &orientation)
+Lattice LatticeUtils::CreateHCPLattice(double a, double c, const ILatticeOrientation& orientation)
 {
-    Lattice prim_hexagonal = Lattice::createHexagonalLattice(1.0, c/a);
+    Lattice prim_hexagonal = Lattice::createHexagonalLattice(1.0, c / a);
     std::unique_ptr<ILatticeOrientation> P_orientation(orientation.clone());
     P_orientation->usePrimitiveLattice(prim_hexagonal);
     auto rotation = P_orientation->transformationMatrix();
@@ -36,9 +36,9 @@ Lattice LatticeUtils::CreateHCPLattice(double a, double c, const ILatticeOrienta
     return hcp.createTransformedLattice(rotation);
 }
 
-Lattice LatticeUtils::CreateBCTLattice(double a, double c, const ILatticeOrientation &orientation)
+Lattice LatticeUtils::CreateBCTLattice(double a, double c, const ILatticeOrientation& orientation)
 {
-    Lattice prim_tetragonal = Lattice::createTetragonalLattice(1.0, c/a);
+    Lattice prim_tetragonal = Lattice::createTetragonalLattice(1.0, c / a);
     std::unique_ptr<ILatticeOrientation> P_orientation(orientation.clone());
     P_orientation->usePrimitiveLattice(prim_tetragonal);
     auto rotation = P_orientation->transformationMatrix();
diff --git a/Core/Lattice/LatticeUtils.h b/Core/Lattice/LatticeUtils.h
index a92e9b65b95..58aad22ee9b 100644
--- a/Core/Lattice/LatticeUtils.h
+++ b/Core/Lattice/LatticeUtils.h
@@ -24,10 +24,8 @@ namespace LatticeUtils
 {
 BA_CORE_API_ Lattice CreateFCCLattice(double lattice_constant,
                                       const ILatticeOrientation& orientation);
-BA_CORE_API_ Lattice CreateHCPLattice(double a, double c,
-                                      const ILatticeOrientation& orientation);
-BA_CORE_API_ Lattice CreateBCTLattice(double a, double c,
-                                      const ILatticeOrientation& orientation);
-}  // namespace LatticeUtils
+BA_CORE_API_ Lattice CreateHCPLattice(double a, double c, const ILatticeOrientation& orientation);
+BA_CORE_API_ Lattice CreateBCTLattice(double a, double c, const ILatticeOrientation& orientation);
+} // namespace LatticeUtils
 
 #endif // LATTICEUTILS_H
diff --git a/Core/Mask/Ellipse.cpp b/Core/Mask/Ellipse.cpp
index 29edb718e26..e95968e0376 100644
--- a/Core/Mask/Ellipse.cpp
+++ b/Core/Mask/Ellipse.cpp
@@ -22,14 +22,10 @@
 //! @param yradius Radius along y-axis
 //! @param theta Angle of Ellipse rotation in radians
 Ellipse::Ellipse(double xcenter, double ycenter, double xradius, double yradius, double theta)
-    : IShape2D("Ellipse")
-    , m_xc(xcenter)
-    , m_yc(ycenter)
-    , m_xr(xradius)
-    , m_yr(yradius)
-    , m_theta(theta)
+    : IShape2D("Ellipse"), m_xc(xcenter), m_yc(ycenter), m_xr(xradius), m_yr(yradius),
+      m_theta(theta)
 {
-    if(xradius <= 0.0 || yradius <= 0.0)
+    if (xradius <= 0.0 || yradius <= 0.0)
         throw Exceptions::LogicErrorException(
             "Ellipse::Ellipse(double xcenter, double ycenter, double xradius, double yradius) "
             "-> Error. Radius can't be negative\n");
@@ -37,10 +33,10 @@ Ellipse::Ellipse(double xcenter, double ycenter, double xradius, double yradius,
 
 bool Ellipse::contains(double x, double y) const
 {
-    double u = std::cos(m_theta)*(x-m_xc) + std::sin(m_theta)*(y-m_yc);
-    double v = -std::sin(m_theta)*(x-m_xc) + std::cos(m_theta)*(y-m_yc);
-    double d = (u/m_xr)*(u/m_xr) + (v/m_yr)*(v/m_yr);
-    return d<=1;
+    double u = std::cos(m_theta) * (x - m_xc) + std::sin(m_theta) * (y - m_yc);
+    double v = -std::sin(m_theta) * (x - m_xc) + std::cos(m_theta) * (y - m_yc);
+    double d = (u / m_xr) * (u / m_xr) + (v / m_yr) * (v / m_yr);
+    return d <= 1;
 }
 
 //! Returns true if area defined by two bins is inside or on border of ellipse;
diff --git a/Core/Mask/Ellipse.h b/Core/Mask/Ellipse.h
index cb17ee732f8..48b32c223df 100644
--- a/Core/Mask/Ellipse.h
+++ b/Core/Mask/Ellipse.h
@@ -20,7 +20,8 @@
 //! Ellipse shape.
 //! @ingroup tools
 
-class  BA_CORE_API_ Ellipse : public IShape2D {
+class BA_CORE_API_ Ellipse : public IShape2D
+{
 public:
     Ellipse(double xcenter, double ycenter, double xradius, double yradius, double theta = 0.0);
     Ellipse* clone() const { return new Ellipse(m_xc, m_yc, m_xr, m_yr, m_theta); }
@@ -32,7 +33,7 @@ public:
     double getCenterY() const { return m_yc; }
     double getRadiusX() const { return m_xr; }
     double getRadiusY() const { return m_yr; }
-    double getTheta()   const { return m_theta; }
+    double getTheta() const { return m_theta; }
 
 private:
     double m_xc, m_yc, m_xr, m_yr, m_theta;
diff --git a/Core/Mask/IShape2D.h b/Core/Mask/IShape2D.h
index e115cb0d832..9aa8f3af152 100644
--- a/Core/Mask/IShape2D.h
+++ b/Core/Mask/IShape2D.h
@@ -24,7 +24,8 @@ struct Bin1D;
 //! Basic class for all shapes in 2D.
 //! @ingroup tools
 
-class BA_CORE_API_ IShape2D : public ICloneable, public INamed {
+class BA_CORE_API_ IShape2D : public ICloneable, public INamed
+{
 public:
     IShape2D(const std::string& name) : INamed(name) {}
     virtual IShape2D* clone() const = 0;
@@ -36,8 +37,11 @@ public:
     //! (more precisely, if mid point of two bins satisfy this condition).
     virtual bool contains(const Bin1D& binx, const Bin1D& biny) const = 0;
 
-    friend std::ostream& operator<<(std::ostream &ostr, const IShape2D& shape) {
-        shape.print(ostr); return ostr; }
+    friend std::ostream& operator<<(std::ostream& ostr, const IShape2D& shape)
+    {
+        shape.print(ostr);
+        return ostr;
+    }
 
 protected:
     virtual void print(std::ostream& ostr) const { ostr << getName(); }
diff --git a/Core/Mask/InfinitePlane.h b/Core/Mask/InfinitePlane.h
index 48d7c56255a..e7c052e5eec 100644
--- a/Core/Mask/InfinitePlane.h
+++ b/Core/Mask/InfinitePlane.h
@@ -20,7 +20,8 @@
 //! The infinite plane is used for masking everything once and forever.
 //! @ingroup tools
 
-class BA_CORE_API_ InfinitePlane : public IShape2D {
+class BA_CORE_API_ InfinitePlane : public IShape2D
+{
 public:
     InfinitePlane() : IShape2D("InfinitePlane") {}
     InfinitePlane* clone() const { return new InfinitePlane(); }
diff --git a/Core/Mask/Line.cpp b/Core/Mask/Line.cpp
index 81edeb9dea1..1a586db3bd4 100644
--- a/Core/Mask/Line.cpp
+++ b/Core/Mask/Line.cpp
@@ -17,11 +17,11 @@
 #include "Macros.h"
 #include "Numeric.h"
 #include <limits>
-GCC_DIAG_OFF(unused-parameter)
+GCC_DIAG_OFF(unused - parameter)
 #include <boost/geometry.hpp>
-#include <boost/geometry/geometries/point_xy.hpp>
 #include <boost/geometry/geometries/linestring.hpp>
-GCC_DIAG_ON(unused-parameter)
+#include <boost/geometry/geometries/point_xy.hpp>
+GCC_DIAG_ON(unused - parameter)
 
 using namespace boost::geometry;
 typedef model::d2::point_xy<double> point_t;
@@ -30,7 +30,8 @@ typedef model::linestring<point_t> line_t;
 
 Line::Line(double x1, double y1, double x2, double y2)
     : IShape2D("Line"), m_x1(x1), m_y1(y1), m_x2(x2), m_y2(y2)
-{}
+{
+}
 
 bool Line::contains(double x, double y) const
 {
@@ -41,7 +42,7 @@ bool Line::contains(double x, double y) const
 
     double d = distance(p, line);
 
-    return d<std::numeric_limits<double>::epsilon();
+    return d < std::numeric_limits<double>::epsilon();
 }
 
 // Calculates if line crosses the box made out of our bins.
@@ -59,17 +60,14 @@ bool Line::contains(const Bin1D& binx, const Bin1D& biny) const
     line_points.push_back(point_t(m_x1, m_y1));
     line_points.push_back(point_t(m_x2, m_y2));
 
-    return intersects(line_t(box_points.begin(),box_points.end()),
-                      line_t(line_points.begin(),line_points.end()));
+    return intersects(line_t(box_points.begin(), box_points.end()),
+                      line_t(line_points.begin(), line_points.end()));
 }
 
-
 // ------------------------------------------------------------------------- //
 
 //! @param x The value at which it crosses x-axes
-VerticalLine::VerticalLine(double x)
-    : IShape2D("VerticalLine"), m_x(x)
-{}
+VerticalLine::VerticalLine(double x) : IShape2D("VerticalLine"), m_x(x) {}
 
 bool VerticalLine::contains(double x, double /*y*/) const
 {
@@ -78,16 +76,13 @@ bool VerticalLine::contains(double x, double /*y*/) const
 
 bool VerticalLine::contains(const Bin1D& binx, const Bin1D& /*biny*/) const
 {
-    return m_x>=binx.m_lower && m_x <= binx.m_upper;
+    return m_x >= binx.m_lower && m_x <= binx.m_upper;
 }
 
-
 // ------------------------------------------------------------------------- //
 
 //! @param y The value at which it crosses y-axes
-HorizontalLine::HorizontalLine(double y)
-    : IShape2D("HorizontalLine"), m_y(y)
-{}
+HorizontalLine::HorizontalLine(double y) : IShape2D("HorizontalLine"), m_y(y) {}
 
 bool HorizontalLine::contains(double /*x*/, double y) const
 {
@@ -96,5 +91,5 @@ bool HorizontalLine::contains(double /*x*/, double y) const
 
 bool HorizontalLine::contains(const Bin1D& /*binx*/, const Bin1D& biny) const
 {
-    return m_y>=biny.m_lower && m_y <= biny.m_upper;
+    return m_y >= biny.m_lower && m_y <= biny.m_upper;
 }
diff --git a/Core/Mask/Line.h b/Core/Mask/Line.h
index 1af9c814f47..32dbc7e4c40 100644
--- a/Core/Mask/Line.h
+++ b/Core/Mask/Line.h
@@ -20,23 +20,24 @@
 //! A line segment.
 //! @ingroup mask
 
-class  BA_CORE_API_ Line : public IShape2D {
+class BA_CORE_API_ Line : public IShape2D
+{
 public:
     Line(double x1, double y1, double x2, double y2);
     Line* clone() const { return new Line(m_x1, m_y1, m_x2, m_y2); }
 
     bool contains(double x, double y) const;
-    bool contains(const Bin1D &binx, const Bin1D &biny) const;
+    bool contains(const Bin1D& binx, const Bin1D& biny) const;
 
 private:
     double m_x1, m_y1, m_x2, m_y2;
 };
 
-
 //! An infinite vertical line.
 //! @ingroup mask
 
-class BA_CORE_API_ VerticalLine : public IShape2D {
+class BA_CORE_API_ VerticalLine : public IShape2D
+{
 public:
     VerticalLine(double x);
     VerticalLine* clone() const { return new VerticalLine(m_x); }
@@ -50,14 +51,14 @@ private:
     double m_x;
 };
 
-
 //! An infinite horizontal line.
 //! @ingroup mask
 
-class BA_CORE_API_ HorizontalLine : public IShape2D {
+class BA_CORE_API_ HorizontalLine : public IShape2D
+{
 public:
     HorizontalLine(double y);
-    HorizontalLine *clone() const { return new HorizontalLine(m_y); }
+    HorizontalLine* clone() const { return new HorizontalLine(m_y); }
 
     bool contains(double x, double y) const;
     bool contains(const Bin1D& binx, const Bin1D& biny) const;
diff --git a/Core/Mask/Polygon.cpp b/Core/Mask/Polygon.cpp
index c4065adb146..0b00bc9764d 100644
--- a/Core/Mask/Polygon.cpp
+++ b/Core/Mask/Polygon.cpp
@@ -16,16 +16,17 @@
 #include "Bin.h"
 #include "Exceptions.h"
 #include "Macros.h"
-GCC_DIAG_OFF(unused-parameter)
+GCC_DIAG_OFF(unused - parameter)
 #include <boost/geometry.hpp>
 #include <boost/geometry/geometries/point_xy.hpp>
 #include <boost/geometry/geometries/polygon.hpp>
-GCC_DIAG_ON(unused-parameter)
+GCC_DIAG_ON(unused - parameter)
 
 using namespace boost::geometry;
 
 //! The private data for polygons to hide boost dependency from the header
-class PolygonPrivate {
+class PolygonPrivate
+{
 public:
     typedef model::d2::point_xy<double> point_t;
     typedef model::polygon<point_t> polygon_t;
@@ -34,15 +35,14 @@ public:
     void get_points(std::vector<double>& xpos, std::vector<double>& ypos);
 };
 
-
 void PolygonPrivate::init_from(const std::vector<double>& x, const std::vector<double>& y)
 {
-    if(x.size() != y.size())
+    if (x.size() != y.size())
         throw Exceptions::LogicErrorException(
             "Polygon::Polygon(const std::vector<double>& x, const std::vector<double>& y) "
             "Error. Sizes of arrays must conincide.");
     std::vector<point_t> points;
-    for(size_t i=0; i<x.size(); ++i)
+    for (size_t i = 0; i < x.size(); ++i)
         points.push_back(point_t(x[i], y[i]));
     assign_points(polygon, points);
     correct(polygon);
@@ -52,14 +52,13 @@ void PolygonPrivate::get_points(std::vector<double>& xpos, std::vector<double>&
 {
     xpos.clear();
     ypos.clear();
-    for(auto it = polygon.outer().begin(); it != polygon.outer().end(); ++it ) {
-         // for vectors of x and y, extract the x/y from the point
-         xpos.push_back( boost::geometry::get<0>( *it ) );
-         ypos.push_back( boost::geometry::get<1>( *it ) );
+    for (auto it = polygon.outer().begin(); it != polygon.outer().end(); ++it) {
+        // for vectors of x and y, extract the x/y from the point
+        xpos.push_back(boost::geometry::get<0>(*it));
+        ypos.push_back(boost::geometry::get<1>(*it));
     }
 }
 
-
 //! @param x Vector of x-coordinates of polygon points.
 //! @param y Vector of y-coordinates of polygon points.
 
@@ -73,17 +72,17 @@ Polygon::Polygon(const std::vector<double> x, const std::vector<double> y)
 
 // IMPORTANT Input parameter is not "const reference" to be able to work from python
 // (auto conversion of python list to vector<vector<double>>).
-    //! Polygon defined by two  dimensional array with (x,y) coordinates of polygon points.
-    //! The size of second dimension should be 2. If polygon is unclosed (the last point
-    //! doesn't repeat the first one), it will be closed automatically.
-    //! @param points Two dimensional vector of (x,y) coordinates of polygon points.
-Polygon::Polygon(const std::vector<std::vector<double> > points)
+//! Polygon defined by two  dimensional array with (x,y) coordinates of polygon points.
+//! The size of second dimension should be 2. If polygon is unclosed (the last point
+//! doesn't repeat the first one), it will be closed automatically.
+//! @param points Two dimensional vector of (x,y) coordinates of polygon points.
+Polygon::Polygon(const std::vector<std::vector<double>> points)
     : IShape2D("Polygon"), m_d(new PolygonPrivate)
 {
     std::vector<double> x;
     std::vector<double> y;
-    for(size_t i=0; i<points.size(); ++i) {
-        if(points[i].size() != 2)
+    for (size_t i = 0; i < points.size(); ++i) {
+        if (points[i].size() != 2)
             throw Exceptions::LogicErrorException(
                 "Polygon(const std::vector<std::vector<double> >& points) -> Error. "
                 " Should be two-dimensional array with second dimension of 2 size.");
@@ -93,9 +92,7 @@ Polygon::Polygon(const std::vector<std::vector<double> > points)
     m_d->init_from(x, y);
 }
 
-Polygon::Polygon(const PolygonPrivate* d)
-    : IShape2D("Polygon"), m_d(new PolygonPrivate(*d))
-{}
+Polygon::Polygon(const PolygonPrivate* d) : IShape2D("Polygon"), m_d(new PolygonPrivate(*d)) {}
 
 Polygon::~Polygon()
 {
@@ -104,7 +101,7 @@ Polygon::~Polygon()
 
 bool Polygon::contains(double x, double y) const
 {
-//    return within(PolygonPrivate::point_t(x, y), m_d->polygon); // not including borders
+    //    return within(PolygonPrivate::point_t(x, y), m_d->polygon); // not including borders
     return covered_by(PolygonPrivate::point_t(x, y), m_d->polygon); // including borders
 }
 
@@ -123,7 +120,7 @@ void Polygon::getPoints(std::vector<double>& xpos, std::vector<double>& ypos) co
     m_d->get_points(xpos, ypos);
 }
 
-void Polygon::print(std::ostream &ostr) const
+void Polygon::print(std::ostream& ostr) const
 {
     ostr << wkt<PolygonPrivate::polygon_t>(m_d->polygon);
 }
diff --git a/Core/Mask/Polygon.h b/Core/Mask/Polygon.h
index 58034e8f987..c5376c6922b 100644
--- a/Core/Mask/Polygon.h
+++ b/Core/Mask/Polygon.h
@@ -27,7 +27,8 @@ class PolygonPrivate;
 //! Sizes of arrays should coincide.  If polygon is unclosed (the last point
 //! doesn't repeat the first one), it will be closed automatically.
 
-class BA_CORE_API_ Polygon : public IShape2D {
+class BA_CORE_API_ Polygon : public IShape2D
+{
 public:
     Polygon(const std::vector<double> x, const std::vector<double> y);
     Polygon(const std::vector<std::vector<double>> points);
diff --git a/Core/Mask/Rectangle.cpp b/Core/Mask/Rectangle.cpp
index c867d91fce0..42be8c8dc53 100644
--- a/Core/Mask/Rectangle.cpp
+++ b/Core/Mask/Rectangle.cpp
@@ -20,16 +20,15 @@
 //! @param ylow y-coordinate of lower left corner
 //! @param xup x-coordinate of upper right corner
 //! @param yup y-coordinate of upper right corner
-Rectangle::Rectangle(double xlow, double ylow, double xup, double yup)
-    : IShape2D("Rectangle")
+Rectangle::Rectangle(double xlow, double ylow, double xup, double yup) : IShape2D("Rectangle")
 {
-    if(xup <= xlow) {
+    if (xup <= xlow) {
         std::ostringstream message;
         message << "Rectangle(double xlow, double ylow, double xup, double yup) -> Error. ";
         message << " xup <= xlow" << std::endl;
         throw Exceptions::LogicErrorException(message.str());
     }
-    if(yup <= ylow) {
+    if (yup <= ylow) {
         std::ostringstream message;
         message << "Rectangle(double xlow, double ylow, double xup, double yup) -> Error. ";
         message << " yup <= ylow" << std::endl;
@@ -53,5 +52,5 @@ bool Rectangle::contains(const Bin1D& binx, const Bin1D& biny) const
 
 double Rectangle::getArea() const
 {
-    return (m_xup-m_xlow)*(m_yup-m_ylow);
+    return (m_xup - m_xlow) * (m_yup - m_ylow);
 }
diff --git a/Core/Mask/Rectangle.h b/Core/Mask/Rectangle.h
index d807d9128e2..13b323aec08 100644
--- a/Core/Mask/Rectangle.h
+++ b/Core/Mask/Rectangle.h
@@ -20,7 +20,8 @@
 //! The rectangle shape having its axis aligned to the (non-rotated) coordinate system.
 //! @ingroup mask
 
-class BA_CORE_API_ Rectangle : public IShape2D {
+class BA_CORE_API_ Rectangle : public IShape2D
+{
 public:
     Rectangle(double xlow, double ylow, double xup, double yup);
     Rectangle* clone() const { return new Rectangle(m_xlow, m_ylow, m_xup, m_yup); }
@@ -32,8 +33,8 @@ public:
 
     double getXlow() const { return m_xlow; }
     double getYlow() const { return m_ylow; }
-    double getXup()  const { return m_xup; }
-    double getYup()  const { return m_yup; }
+    double getXup() const { return m_xup; }
+    double getYup() const { return m_yup; }
 
 private:
     double m_xlow, m_ylow, m_xup, m_yup;
diff --git a/Core/Material/BaseMaterialImpl.h b/Core/Material/BaseMaterialImpl.h
index 48b7ae5a5f7..2e7f7b02981 100644
--- a/Core/Material/BaseMaterialImpl.h
+++ b/Core/Material/BaseMaterialImpl.h
@@ -15,19 +15,15 @@
 #ifndef BASEMATERIALIMPL_H_
 #define BASEMATERIALIMPL_H_
 
-#include "INamed.h"
-#include "Vectors3D.h"
 #include "Complex.h"
 #include "EigenCore.h"
+#include "INamed.h"
+#include "Vectors3D.h"
 
 class Transform3D;
 class WavevectorInfo;
 
-enum class MATERIAL_TYPES {
-    InvalidMaterialType = -1,
-    RefractiveMaterial = 0,
-    MaterialBySLD
-};
+enum class MATERIAL_TYPES { InvalidMaterialType = -1, RefractiveMaterial = 0, MaterialBySLD };
 
 //! @ingroup materials
 
@@ -75,7 +71,7 @@ public:
     virtual BaseMaterialImpl* transformedMaterial(const Transform3D& transform) const = 0;
 
     //! Prints object data
-    virtual void print(std::ostream &ostr) const = 0;
+    virtual void print(std::ostream& ostr) const = 0;
 };
 
 #endif /* BASEMATERIALIMPL_H_ */
diff --git a/Core/Material/MagneticMaterialImpl.cpp b/Core/Material/MagneticMaterialImpl.cpp
index 806c234a0d2..2372292edb3 100644
--- a/Core/Material/MagneticMaterialImpl.cpp
+++ b/Core/Material/MagneticMaterialImpl.cpp
@@ -13,37 +13,37 @@
 // ************************************************************************** //
 
 #include "MagneticMaterialImpl.h"
-#include "WavevectorInfo.h"
-#include "Transform3D.h"
 #include "MaterialUtils.h"
 #include "PhysicalConstants.h"
+#include "Transform3D.h"
+#include "WavevectorInfo.h"
 #include <memory>
 
-using PhysConsts::mu_B;
 using PhysConsts::gamma_n;
+using PhysConsts::mu_B;
 using PhysConsts::r_e;
- // The factor 1e-18 is here to have unit: m/A*nm^-2
-constexpr double magnetization_prefactor
-    = (gamma_n * r_e / 2.0 / mu_B) * 1e-18;
+// The factor 1e-18 is here to have unit: m/A*nm^-2
+constexpr double magnetization_prefactor = (gamma_n * r_e / 2.0 / mu_B) * 1e-18;
 
-namespace {
+namespace
+{
 cvector_t OrthogonalToBaseVector(cvector_t base, const kvector_t vector)
 {
-    if (base.mag2()==0.0) return cvector_t {};
-    cvector_t projection = (base.dot(vector)/base.mag2())*base;
+    if (base.mag2() == 0.0)
+        return cvector_t{};
+    cvector_t projection = (base.dot(vector) / base.mag2()) * base;
     return vector.complex() - projection;
 }
-}
+} // namespace
 
 MagneticMaterialImpl::MagneticMaterialImpl(const std::string& name, kvector_t magnetization)
-    : BaseMaterialImpl(name)
-    , m_magnetization(magnetization)
-{}
+    : BaseMaterialImpl(name), m_magnetization(magnetization)
+{
+}
 
 MagneticMaterialImpl* MagneticMaterialImpl::inverted() const
 {
-    std::string name = isScalarMaterial() ? getName()
-                                          : getName()+"_inv";
+    std::string name = isScalarMaterial() ? getName() : getName() + "_inv";
     std::unique_ptr<MagneticMaterialImpl> result(this->clone());
     result->setName(name);
     result->setMagnetization(-magnetization());
diff --git a/Core/Material/MagneticMaterialImpl.h b/Core/Material/MagneticMaterialImpl.h
index e44e45a03c1..818c71950c4 100644
--- a/Core/Material/MagneticMaterialImpl.h
+++ b/Core/Material/MagneticMaterialImpl.h
@@ -16,9 +16,9 @@
 #define MAGNETICMATERIALIMPL_H_
 
 #include "BaseMaterialImpl.h"
-#include "Vectors3D.h"
 #include "Complex.h"
 #include "EigenCore.h"
+#include "Vectors3D.h"
 
 class Transform3D;
 class WavevectorInfo;
@@ -36,7 +36,7 @@ public:
     virtual ~MagneticMaterialImpl() = default;
 
     //! Returns pointer to a copy of material
-    MagneticMaterialImpl* clone() const override =0;
+    MagneticMaterialImpl* clone() const override = 0;
 
     //! Constructs a material with inverted magnetization
     MagneticMaterialImpl* inverted() const override final;
@@ -56,10 +56,7 @@ public:
     MagneticMaterialImpl* transformedMaterial(const Transform3D& transform) const override final;
 
 private:
-    void setMagnetization(kvector_t magnetization)
-    {
-        m_magnetization = magnetization;
-    }
+    void setMagnetization(kvector_t magnetization) { m_magnetization = magnetization; }
 
     kvector_t m_magnetization; //!< magnetization
 };
diff --git a/Core/Material/Material.cpp b/Core/Material/Material.cpp
index 9335c77c41b..4d851391c21 100644
--- a/Core/Material/Material.cpp
+++ b/Core/Material/Material.cpp
@@ -14,26 +14,29 @@
 
 #include "Material.h"
 #include "BaseMaterialImpl.h"
-#include "WavevectorInfo.h"
-#include "Transform3D.h"
 #include "Exceptions.h"
+#include "Transform3D.h"
+#include "WavevectorInfo.h"
 #include <typeinfo>
 
 Material::Material(const Material& material)
 {
     if (material.isEmpty())
-        throw Exceptions::NullPointerException("Material: Error! Attempt to initialize material with nullptr.");
+        throw Exceptions::NullPointerException(
+            "Material: Error! Attempt to initialize material with nullptr.");
     m_material_impl.reset(material.m_material_impl->clone());
 }
 
 Material::Material(std::unique_ptr<BaseMaterialImpl> material_impl)
     : m_material_impl(std::move(material_impl))
-{}
+{
+}
 
 Material& Material::operator=(const Material& other)
 {
     if (other.isEmpty())
-        throw Exceptions::NullPointerException("Material: Error! Attempt to assign nullptr to material.");
+        throw Exceptions::NullPointerException(
+            "Material: Error! Attempt to assign nullptr to material.");
     m_material_impl.reset(other.m_material_impl->clone());
     return *this;
 }
@@ -59,7 +62,8 @@ bool Material::isScalarMaterial() const
     return m_material_impl->isScalarMaterial();
 }
 
-bool Material::isMagneticMaterial() const {
+bool Material::isMagneticMaterial() const
+{
     return m_material_impl->isMagneticMaterial();
 }
 
@@ -100,7 +104,8 @@ Eigen::Matrix2cd Material::polarizedSubtrSLD(const WavevectorInfo& wavevectors)
 
 Material Material::transformedMaterial(const Transform3D& transform) const
 {
-    std::unique_ptr<BaseMaterialImpl> material_impl(m_material_impl->transformedMaterial(transform));
+    std::unique_ptr<BaseMaterialImpl> material_impl(
+        m_material_impl->transformedMaterial(transform));
     return Material(std::move(material_impl));
 }
 
@@ -112,10 +117,14 @@ std::ostream& operator<<(std::ostream& ostr, const Material& m)
 
 bool operator==(const Material& left, const Material& right)
 {
-    if (left.getName() != right.getName()) return false;
-    if (left.magnetization() != right.magnetization()) return false;
-    if (left.materialData() != right.materialData()) return false;
-    if (left.typeID() != right.typeID()) return false;
+    if (left.getName() != right.getName())
+        return false;
+    if (left.magnetization() != right.magnetization())
+        return false;
+    if (left.materialData() != right.materialData())
+        return false;
+    if (left.typeID() != right.typeID())
+        return false;
     return true;
 }
 
@@ -123,4 +132,3 @@ bool operator!=(const Material& left, const Material& right)
 {
     return !(left == right);
 }
-
diff --git a/Core/Material/Material.h b/Core/Material/Material.h
index b405f7d9200..77595f19c7e 100644
--- a/Core/Material/Material.h
+++ b/Core/Material/Material.h
@@ -15,12 +15,12 @@
 #ifndef MATERIAL_H_
 #define MATERIAL_H_
 
+#include "BaseMaterialImpl.h"
 #include "Complex.h"
-#include "Vectors3D.h"
 #include "EigenCore.h"
-#include "BaseMaterialImpl.h"
-#include <vector>
+#include "Vectors3D.h"
 #include <memory>
+#include <vector>
 
 class Transform3D;
 class WavevectorInfo;
@@ -40,7 +40,7 @@ public:
 #ifndef SWIG
     //! Creates material with particular material implementation
     Material(std::unique_ptr<BaseMaterialImpl> material_impl);
-#endif //SWIG
+#endif // SWIG
 
     //! Material copy assignment
     Material& operator=(const Material& other);
@@ -69,7 +69,7 @@ public:
 #ifndef SWIG
     //! Returns the type of underlying material implementation
     MATERIAL_TYPES typeID() const;
-#endif //SWIG
+#endif // SWIG
 
     //! Get the magnetization (in A/m)
     kvector_t magnetization() const;
@@ -79,13 +79,14 @@ public:
     complex_t materialData() const;
 
     //! Returns true if material underlying data is nullptr
-    bool isEmpty() const {return !m_material_impl;}
+    bool isEmpty() const { return !m_material_impl; }
 
     //! Returns true if material has refractive index of (1.0, 0.0)
     //! and zero magnetization.
     bool isDefaultMaterial() const;
 
-    //! Returns (\f$ \pi/\lambda^2 \f$ - sld), sld (in \f$nm^{-2}\f$) being the scattering length density
+    //! Returns (\f$ \pi/\lambda^2 \f$ - sld), sld (in \f$nm^{-2}\f$) being the scattering length
+    //! density
     complex_t scalarSubtrSLD(const WavevectorInfo& wavevectors) const;
 
 #ifndef SWIG
@@ -95,8 +96,7 @@ public:
 
     Material transformedMaterial(const Transform3D& transform) const;
 
-    friend BA_CORE_API_ std::ostream& operator<<(
-            std::ostream& ostr, const Material& mat);
+    friend BA_CORE_API_ std::ostream& operator<<(std::ostream& ostr, const Material& mat);
 
 private:
     std::unique_ptr<BaseMaterialImpl> m_material_impl;
diff --git a/Core/Material/MaterialBySLDImpl.cpp b/Core/Material/MaterialBySLDImpl.cpp
index 76fef2b64e2..01ffeacc5bd 100644
--- a/Core/Material/MaterialBySLDImpl.cpp
+++ b/Core/Material/MaterialBySLDImpl.cpp
@@ -13,8 +13,8 @@
 // ************************************************************************** //
 
 #include "MaterialBySLDImpl.h"
-#include "WavevectorInfo.h"
 #include "Units.h"
+#include "WavevectorInfo.h"
 
 namespace
 {
@@ -24,16 +24,16 @@ inline double getWlPrefactor(double wavelength)
 {
     return wavelength * wavelength / M_PI;
 }
-}
+} // namespace
 
 MaterialBySLDImpl::MaterialBySLDImpl(const std::string& name, double sld_real, double sld_imag,
                                      kvector_t magnetization)
-    : MagneticMaterialImpl(name, magnetization)
-    , m_sld_real(sld_real)
-    , m_sld_imag(sld_imag < 0. ?
-                 throw std::runtime_error("The imaginary part of the SLD must be greater or equal zero") :
-                 sld_imag)
-{}
+    : MagneticMaterialImpl(name, magnetization), m_sld_real(sld_real),
+      m_sld_imag(sld_imag < 0. ? throw std::runtime_error(
+                     "The imaginary part of the SLD must be greater or equal zero")
+                               : sld_imag)
+{
+}
 
 MaterialBySLDImpl* MaterialBySLDImpl::clone() const
 {
@@ -64,8 +64,8 @@ complex_t MaterialBySLDImpl::scalarSubtrSLD(const WavevectorInfo& wavevectors) c
 void MaterialBySLDImpl::print(std::ostream& ostr) const
 {
     ostr << "MaterialBySLD:" << getName() << "<" << this << ">{ "
-         << "sld_real=" << m_sld_real << ", sld_imag = " << m_sld_imag
-         << ", B=" << magnetization() << "}";
+         << "sld_real=" << m_sld_real << ", sld_imag = " << m_sld_imag << ", B=" << magnetization()
+         << "}";
 }
 
 complex_t MaterialBySLDImpl::sld() const
diff --git a/Core/Material/MaterialBySLDImpl.h b/Core/Material/MaterialBySLDImpl.h
index 192c5645389..b92c56a362c 100644
--- a/Core/Material/MaterialBySLDImpl.h
+++ b/Core/Material/MaterialBySLDImpl.h
@@ -43,16 +43,14 @@ public:
     complex_t materialData() const override;
 
     //! Returns type of material implementation
-    MATERIAL_TYPES typeID() const override
-    {
-        return MATERIAL_TYPES::MaterialBySLD;
-    }
+    MATERIAL_TYPES typeID() const override { return MATERIAL_TYPES::MaterialBySLD; }
 
-    //! Returns (\f$ \pi/\lambda^2 \f$ - sld), sld (in \f$nm^{-2}\f$) being the scattering length density
+    //! Returns (\f$ \pi/\lambda^2 \f$ - sld), sld (in \f$nm^{-2}\f$) being the scattering length
+    //! density
     complex_t scalarSubtrSLD(const WavevectorInfo& wavevectors) const override;
 
     //! Prints object data
-    void print(std::ostream &ostr) const override;
+    void print(std::ostream& ostr) const override;
 
 private:
     //! Constructs a wavelength-independent material with a given complex-valued
@@ -62,7 +60,6 @@ private:
     //! Returns the scattering length density
     complex_t sld() const;
 
-
     double m_sld_real; //!< complex-valued scattering length density
     double m_sld_imag; //!< imaginary part of scattering length density (negative by default)
 };
diff --git a/Core/Material/MaterialFactoryFuncs.cpp b/Core/Material/MaterialFactoryFuncs.cpp
index e56cdd2d631..23691c114ff 100644
--- a/Core/Material/MaterialFactoryFuncs.cpp
+++ b/Core/Material/MaterialFactoryFuncs.cpp
@@ -13,10 +13,10 @@
 // ************************************************************************** //
 
 #include "MaterialFactoryFuncs.h"
-#include "MaterialBySLDImpl.h"
-#include "RefractiveMaterialImpl.h"
 #include "HomogeneousRegion.h"
+#include "MaterialBySLDImpl.h"
 #include "MaterialUtils.h"
+#include "RefractiveMaterialImpl.h"
 #include "Units.h"
 #include <functional>
 
@@ -26,10 +26,10 @@ const double inv_sq_angstroms = 1.0 / (Units::angstrom * Units::angstrom);
 template <class T>
 T averageData(const Material& layer_mat, const std::vector<HomogeneousRegion>& regions,
               std::function<T(const Material&)> average);
-}
+} // namespace
 
 Material HomogeneousMaterial(const std::string& name, complex_t refractive_index,
-                                 kvector_t magnetization)
+                             kvector_t magnetization)
 {
     const double delta = 1.0 - refractive_index.real();
     const double beta = refractive_index.imag();
@@ -37,7 +37,7 @@ Material HomogeneousMaterial(const std::string& name, complex_t refractive_index
 }
 
 Material HomogeneousMaterial(const std::string& name, double delta, double beta,
-                                 kvector_t magnetization)
+                             kvector_t magnetization)
 {
     std::unique_ptr<RefractiveMaterialImpl> mat_impl(
         new RefractiveMaterialImpl(name, delta, beta, magnetization));
@@ -79,9 +79,8 @@ Material CreateAveragedMaterial(const Material& layer_mat,
     const std::string avr_mat_name = layer_mat.getName() + "_avg";
 
     // calculate averaged magnetization
-    const kvector_t mag_avr =
-            averageData<kvector_t>(layer_mat, regions,
-                                   [](const Material& mat) { return mat.magnetization(); });
+    const kvector_t mag_avr = averageData<kvector_t>(
+        layer_mat, regions, [](const Material& mat) { return mat.magnetization(); });
 
     if (avr_material_type == MATERIAL_TYPES::RefractiveMaterial) {
         // avrData returns (1 - mdc)^2 - 1, where mdc is material data conjugate
@@ -89,15 +88,15 @@ Material CreateAveragedMaterial(const Material& layer_mat,
             const complex_t mdc = std::conj(mat.materialData());
             return mdc * mdc - 2.0 * mdc;
         };
-        const complex_t avr_mat_data
-            = std::conj(1.0 - std::sqrt(1.0 + averageData<complex_t>(layer_mat, regions, avrData)));
+        const complex_t avr_mat_data =
+            std::conj(1.0 - std::sqrt(1.0 + averageData<complex_t>(layer_mat, regions, avrData)));
         return HomogeneousMaterial(avr_mat_name, avr_mat_data.real(), avr_mat_data.imag(), mag_avr);
     } else if (avr_material_type == MATERIAL_TYPES::MaterialBySLD) {
-        complex_t (*avrData)(const Material&)
-            = [](const Material& mat) { return mat.materialData(); };
+        complex_t (*avrData)(const Material&) = [](const Material& mat) {
+            return mat.materialData();
+        };
         const complex_t avr_mat_data = averageData<complex_t>(layer_mat, regions, avrData);
-        return MaterialBySLD(avr_mat_name, avr_mat_data.real(), avr_mat_data.imag(),
-                                          mag_avr);
+        return MaterialBySLD(avr_mat_name, avr_mat_data.real(), avr_mat_data.imag(), mag_avr);
     } else
         throw std::runtime_error("Error in CalculateAverageMaterial: unknown material type.");
 }
@@ -114,4 +113,4 @@ T averageData(const Material& layer_mat, const std::vector<HomogeneousRegion>& r
         averaged_data += region.m_volume * (average(region.m_material) - layer_data);
     return averaged_data;
 }
-}
+} // namespace
diff --git a/Core/Material/MaterialUtils.cpp b/Core/Material/MaterialUtils.cpp
index 5046f5a8c56..be44b432242 100644
--- a/Core/Material/MaterialUtils.cpp
+++ b/Core/Material/MaterialUtils.cpp
@@ -13,45 +13,39 @@
 // ************************************************************************** //
 
 #include "MaterialUtils.h"
-#include "PhysicalConstants.h"
 #include "Material.h"
+#include "PhysicalConstants.h"
 
-using PhysConsts::m_n;
 using PhysConsts::g_factor_n;
-using PhysConsts::mu_N;
 using PhysConsts::h_bar;
+using PhysConsts::m_n;
+using PhysConsts::mu_N;
 // The factor 1e-18 is here to have unit: 1/T*nm^-2
-constexpr double magnetic_prefactor
-    = (m_n * g_factor_n * mu_N / h_bar / h_bar)
-      * 1e-18;
+constexpr double magnetic_prefactor = (m_n * g_factor_n * mu_N / h_bar / h_bar) * 1e-18;
 
 // Unit 2x2 matrix
 const Eigen::Matrix2cd Unit_Matrix(Eigen::Matrix2cd::Identity());
 
 // Imaginary unit
-namespace {
-const complex_t I(0,1);
+namespace
+{
+const complex_t I(0, 1);
 
 // Pauli matrices
-const Eigen::Matrix2cd Pauli_X((Eigen::Matrix2cd() << 0,  1,
-                                                      1,  0).finished());
-const Eigen::Matrix2cd Pauli_Y((Eigen::Matrix2cd() << 0, -I,
-                                                      I,  0).finished());
-const Eigen::Matrix2cd Pauli_Z((Eigen::Matrix2cd() << 1,  0,
-                                                      0, -1).finished());
-}
+const Eigen::Matrix2cd Pauli_X((Eigen::Matrix2cd() << 0, 1, 1, 0).finished());
+const Eigen::Matrix2cd Pauli_Y((Eigen::Matrix2cd() << 0, -I, I, 0).finished());
+const Eigen::Matrix2cd Pauli_Z((Eigen::Matrix2cd() << 1, 0, 0, -1).finished());
+} // namespace
 
 template <typename T>
 Eigen::Matrix2cd MaterialUtils::MagnetizationCorrection(complex_t unit_factor,
                                                         double magnetic_factor,
                                                         BasicVector3D<T> polarization)
 {
-    Eigen::Matrix2cd result = unit_factor * Unit_Matrix +
-        magnetic_factor * (
-            Pauli_X * polarization[0] +
-            Pauli_Y * polarization[1] +
-            Pauli_Z * polarization[2]
-        );
+    Eigen::Matrix2cd result =
+        unit_factor * Unit_Matrix
+        + magnetic_factor
+              * (Pauli_X * polarization[0] + Pauli_Y * polarization[1] + Pauli_Z * polarization[2]);
     return result;
 }
 template Eigen::Matrix2cd MaterialUtils::MagnetizationCorrection(complex_t unit_factor,
@@ -63,11 +57,11 @@ template Eigen::Matrix2cd MaterialUtils::MagnetizationCorrection(complex_t unit_
 
 complex_t MaterialUtils::ScalarReducedPotential(complex_t n, kvector_t k, double n_ref)
 {
-    return n*n - n_ref*n_ref*k.sin2Theta();
+    return n * n - n_ref * n_ref * k.sin2Theta();
 }
 
 Eigen::Matrix2cd MaterialUtils::PolarizedReducedPotential(complex_t n, kvector_t b_field,
-                                           kvector_t k, double n_ref)
+                                                          kvector_t k, double n_ref)
 {
     Eigen::Matrix2cd result;
     double factor = magnetic_prefactor / k.mag2();
@@ -75,7 +69,8 @@ Eigen::Matrix2cd MaterialUtils::PolarizedReducedPotential(complex_t n, kvector_t
     return MagnetizationCorrection(unit_factor, factor, b_field);
 }
 
-MATERIAL_TYPES MaterialUtils::checkMaterialTypes(const std::vector<const Material*>& materials) {
+MATERIAL_TYPES MaterialUtils::checkMaterialTypes(const std::vector<const Material*>& materials)
+{
     MATERIAL_TYPES result = MATERIAL_TYPES::RefractiveMaterial;
     bool isDefault = true;
     for (const Material* mat : materials) {
diff --git a/Core/Material/MaterialUtils.h b/Core/Material/MaterialUtils.h
index d21ec178c71..4acd52221d4 100644
--- a/Core/Material/MaterialUtils.h
+++ b/Core/Material/MaterialUtils.h
@@ -16,14 +16,15 @@
 #define MATERIALUTILS_H_
 
 #include "Complex.h"
-#include "Vectors3D.h"
 #include "EigenCore.h"
 #include "Material.h"
+#include "Vectors3D.h"
 
 //! A number of materials-related helper functions for internal use
 //! @ingroup materials
 
-namespace MaterialUtils {
+namespace MaterialUtils
+{
 
 //! Function for calculating the reduced potential, used for obtaining the Fresnel coefficients
 //! (non-polarized material case)
diff --git a/Core/Material/RefractiveMaterialImpl.cpp b/Core/Material/RefractiveMaterialImpl.cpp
index d8ebbd75ed7..b4b08496ef5 100644
--- a/Core/Material/RefractiveMaterialImpl.cpp
+++ b/Core/Material/RefractiveMaterialImpl.cpp
@@ -16,13 +16,13 @@
 #include "WavevectorInfo.h"
 
 RefractiveMaterialImpl::RefractiveMaterialImpl(const std::string& name, double delta, double beta,
-                                                 kvector_t magnetization)
-    : MagneticMaterialImpl(name, magnetization)
-    , m_delta(delta)
-    , m_beta(beta < 0. ?
-             throw std::runtime_error("The imaginary part of the refractive index must be greater or equal zero") :
-             beta)
-{}
+                                               kvector_t magnetization)
+    : MagneticMaterialImpl(name, magnetization), m_delta(delta),
+      m_beta(beta < 0. ? throw std::runtime_error(
+                 "The imaginary part of the refractive index must be greater or equal zero")
+                       : beta)
+{
+}
 
 RefractiveMaterialImpl* RefractiveMaterialImpl::clone() const
 {
@@ -48,13 +48,12 @@ complex_t RefractiveMaterialImpl::materialData() const
 complex_t RefractiveMaterialImpl::scalarSubtrSLD(const WavevectorInfo& wavevectors) const
 {
     double wavelength = wavevectors.getWavelength();
-    double prefactor = M_PI/wavelength/wavelength;
+    double prefactor = M_PI / wavelength / wavelength;
     return prefactor * refractiveIndex2(wavelength);
 }
 
 void RefractiveMaterialImpl::print(std::ostream& ostr) const
 {
     ostr << "RefractiveMaterial:" << getName() << "<" << this << ">{ "
-         << "delta=" << m_delta << ", beta=" << m_beta
-         << ", B=" << magnetization() << "}";
+         << "delta=" << m_delta << ", beta=" << m_beta << ", B=" << magnetization() << "}";
 }
diff --git a/Core/Material/RefractiveMaterialImpl.h b/Core/Material/RefractiveMaterialImpl.h
index 10480f5e66f..0f57e202459 100644
--- a/Core/Material/RefractiveMaterialImpl.h
+++ b/Core/Material/RefractiveMaterialImpl.h
@@ -24,8 +24,7 @@
 class BA_CORE_API_ RefractiveMaterialImpl : public MagneticMaterialImpl
 {
 public:
-    friend BA_CORE_API_ Material HomogeneousMaterial(const std::string&, double, double,
-                                                         kvector_t);
+    friend BA_CORE_API_ Material HomogeneousMaterial(const std::string&, double, double, kvector_t);
 
     virtual ~RefractiveMaterialImpl() = default;
 
@@ -46,25 +45,23 @@ public:
     complex_t materialData() const override;
 
     //! Returns type of material implementation
-    MATERIAL_TYPES typeID() const override
-    {
-        return MATERIAL_TYPES::RefractiveMaterial;
-    }
+    MATERIAL_TYPES typeID() const override { return MATERIAL_TYPES::RefractiveMaterial; }
 
-    //! Returns (\f$ \pi/\lambda^2 \f$ - sld), sld (in \f$nm^{-2}\f$) being the scattering length density.
-    //! If the wavelength associated with passed wavevector is different from the one
+    //! Returns (\f$ \pi/\lambda^2 \f$ - sld), sld (in \f$nm^{-2}\f$) being the scattering length
+    //! density. If the wavelength associated with passed wavevector is different from the one
     //! associated with refractive coefficients used during the object construction,
     //! provided result is inconsistent.
     complex_t scalarSubtrSLD(const WavevectorInfo& wavevectors) const override;
 
     //! Prints object data
-    void print(std::ostream &ostr) const override;
+    void print(std::ostream& ostr) const override;
 
 private:
     RefractiveMaterialImpl(const std::string& name, double delta, double beta,
                            kvector_t magnetization);
 
-    double m_delta; //!< \f$\delta\f$ coefficient for refractive index \f$n = 1 - \delta + i \beta\f$
+    double
+        m_delta;   //!< \f$\delta\f$ coefficient for refractive index \f$n = 1 - \delta + i \beta\f$
     double m_beta; //!< \f$\beta\f$ coefficient for refractive index \f$n = 1 - \delta + i \beta\f$
 };
 
diff --git a/Core/Multilayer/DecouplingApproximationStrategy.cpp b/Core/Multilayer/DecouplingApproximationStrategy.cpp
index 1d2f4a7aaae..76bb2899b9c 100644
--- a/Core/Multilayer/DecouplingApproximationStrategy.cpp
+++ b/Core/Multilayer/DecouplingApproximationStrategy.cpp
@@ -21,19 +21,20 @@
 #include "RealParameter.h"
 #include "SimulationElement.h"
 
-using InterferenceFunctionUtils::PrecomputeScalarFormFactors;
 using InterferenceFunctionUtils::PrecomputePolarizedFormFactors;
+using InterferenceFunctionUtils::PrecomputeScalarFormFactors;
 
-DecouplingApproximationStrategy::DecouplingApproximationStrategy(
-        SimulationOptions sim_params, bool polarized)
+DecouplingApproximationStrategy::DecouplingApproximationStrategy(SimulationOptions sim_params,
+                                                                 bool polarized)
     : IInterferenceFunctionStrategy(sim_params, polarized)
-{}
+{
+}
 
 //! Returns the total incoherent and coherent scattering intensity for given kf and
 //! for one particle layout (implied by the given particle form factors).
 //! This is the scalar version
-double DecouplingApproximationStrategy::scalarCalculation(
-        const SimulationElement& sim_element) const
+double
+DecouplingApproximationStrategy::scalarCalculation(const SimulationElement& sim_element) const
 {
     double intensity = 0.0;
     complex_t amplitude = complex_t(0.0, 0.0);
@@ -53,8 +54,8 @@ double DecouplingApproximationStrategy::scalarCalculation(
 }
 
 //! This is the polarized version
-double DecouplingApproximationStrategy::polarizedCalculation(
-        const SimulationElement& sim_element) const
+double
+DecouplingApproximationStrategy::polarizedCalculation(const SimulationElement& sim_element) const
 {
     Eigen::Matrix2cd mean_intensity = Eigen::Matrix2cd::Zero();
     Eigen::Matrix2cd mean_amplitude = Eigen::Matrix2cd::Zero();
@@ -72,7 +73,8 @@ double DecouplingApproximationStrategy::polarizedCalculation(
         mean_intensity += fraction * (ff * polarization_handler.getPolarization() * ff.adjoint());
     }
     Eigen::Matrix2cd amplitude_matrix = polarization_handler.getAnalyzerOperator() * mean_amplitude
-            * polarization_handler.getPolarization() * mean_amplitude.adjoint();
+                                        * polarization_handler.getPolarization()
+                                        * mean_amplitude.adjoint();
     Eigen::Matrix2cd intensity_matrix = polarization_handler.getAnalyzerOperator() * mean_intensity;
     double amplitude_trace = std::abs(amplitude_matrix.trace());
     double intensity_trace = std::abs(intensity_matrix.trace());
diff --git a/Core/Multilayer/FormFactorBAPol.cpp b/Core/Multilayer/FormFactorBAPol.cpp
index dd5bbf1d2ba..226e83f614d 100644
--- a/Core/Multilayer/FormFactorBAPol.cpp
+++ b/Core/Multilayer/FormFactorBAPol.cpp
@@ -17,14 +17,13 @@
 #include "WavevectorInfo.h"
 #include <stdexcept>
 
-
 FormFactorBAPol::FormFactorBAPol(const IFormFactor& form_factor)
     : mP_form_factor(form_factor.clone())
 {
     setName(BornAgain::FormFactorPolarizedBAType);
 }
 
-FormFactorBAPol::~FormFactorBAPol() =default;
+FormFactorBAPol::~FormFactorBAPol() = default;
 
 FormFactorBAPol* FormFactorBAPol::clone() const
 {
@@ -41,10 +40,10 @@ Eigen::Matrix2cd FormFactorBAPol::evaluatePol(const WavevectorInfo& wavevectors)
 {
     Eigen::Matrix2cd ff_BA = mP_form_factor->evaluatePol(wavevectors);
     Eigen::Matrix2cd result;
-    result(0,0) = -ff_BA(1,0);
-    result(0,1) = ff_BA(0,0);
-    result(1,0) = -ff_BA(1,1);
-    result(1,1) = ff_BA(0,1);
+    result(0, 0) = -ff_BA(1, 0);
+    result(0, 1) = ff_BA(0, 0);
+    result(1, 0) = -ff_BA(1, 1);
+    result(1, 1) = ff_BA(0, 1);
     return result;
 }
 
diff --git a/Core/Multilayer/FormFactorBAPol.h b/Core/Multilayer/FormFactorBAPol.h
index 15f2b59e5e9..f033e81196a 100644
--- a/Core/Multilayer/FormFactorBAPol.h
+++ b/Core/Multilayer/FormFactorBAPol.h
@@ -32,7 +32,8 @@ public:
 
     void accept(INodeVisitor* visitor) const override { visitor->visit(this); }
 
-    void setAmbientMaterial(Material material) override {
+    void setAmbientMaterial(Material material) override
+    {
         mP_form_factor->setAmbientMaterial(std::move(material));
     }
 
diff --git a/Core/Multilayer/FormFactorDWBA.cpp b/Core/Multilayer/FormFactorDWBA.cpp
index 15741abf46f..f12b79ba0bb 100644
--- a/Core/Multilayer/FormFactorDWBA.cpp
+++ b/Core/Multilayer/FormFactorDWBA.cpp
@@ -17,24 +17,21 @@
 #include "ILayerRTCoefficients.h"
 #include "WavevectorInfo.h"
 
-FormFactorDWBA::FormFactorDWBA(const IFormFactor& form_factor)
-    : mP_form_factor(form_factor.clone())
+FormFactorDWBA::FormFactorDWBA(const IFormFactor& form_factor) : mP_form_factor(form_factor.clone())
 {
     setName(BornAgain::FormFactorDWBAType);
 }
 
-FormFactorDWBA::~FormFactorDWBA()
-{}
+FormFactorDWBA::~FormFactorDWBA() {}
 
 FormFactorDWBA* FormFactorDWBA::clone() const
 {
     FormFactorDWBA* result = new FormFactorDWBA(*mP_form_factor);
-    std::unique_ptr<const ILayerRTCoefficients> p_in_coefs
-        = mp_in_coeffs ? std::unique_ptr<const ILayerRTCoefficients>(mp_in_coeffs->clone())
-                       : nullptr;
-    std::unique_ptr<const ILayerRTCoefficients> p_out_coefs
-        = mp_out_coeffs ? std::unique_ptr<const ILayerRTCoefficients>(mp_out_coeffs->clone())
-                        : nullptr;
+    std::unique_ptr<const ILayerRTCoefficients> p_in_coefs =
+        mp_in_coeffs ? std::unique_ptr<const ILayerRTCoefficients>(mp_in_coeffs->clone()) : nullptr;
+    std::unique_ptr<const ILayerRTCoefficients> p_out_coefs =
+        mp_out_coeffs ? std::unique_ptr<const ILayerRTCoefficients>(mp_out_coeffs->clone())
+                      : nullptr;
     result->setSpecularInfo(std::move(p_in_coefs), std::move(p_out_coefs));
     return result;
 }
@@ -68,9 +65,9 @@ complex_t FormFactorDWBA::evaluate(const WavevectorInfo& wavevectors) const
 
     // The four different scattering contributions; S stands for scattering
     // off the particle, R for reflection off the layer interface
-    complex_t term_S   = T_in * mP_form_factor->evaluate(k_TT) * T_out;
-    complex_t term_RS  = R_in * mP_form_factor->evaluate(k_RT) * T_out;
-    complex_t term_SR  = T_in * mP_form_factor->evaluate(k_TR) * R_out;
+    complex_t term_S = T_in * mP_form_factor->evaluate(k_TT) * T_out;
+    complex_t term_RS = R_in * mP_form_factor->evaluate(k_RT) * T_out;
+    complex_t term_SR = T_in * mP_form_factor->evaluate(k_TR) * R_out;
     complex_t term_RSR = R_in * mP_form_factor->evaluate(k_RR) * R_out;
 
     return term_S + term_RS + term_SR + term_RSR;
diff --git a/Core/Multilayer/FormFactorDWBA.h b/Core/Multilayer/FormFactorDWBA.h
index 33e1b4d4663..4c8c8d011e3 100644
--- a/Core/Multilayer/FormFactorDWBA.h
+++ b/Core/Multilayer/FormFactorDWBA.h
@@ -33,7 +33,8 @@ public:
 
     void accept(INodeVisitor* visitor) const override { visitor->visit(this); }
 
-    void setAmbientMaterial(Material material) override {
+    void setAmbientMaterial(Material material) override
+    {
         mP_form_factor->setAmbientMaterial(std::move(material));
     }
 
diff --git a/Core/Multilayer/FormFactorDWBAPol.cpp b/Core/Multilayer/FormFactorDWBAPol.cpp
index 3e2db7e516c..5decad0bc10 100644
--- a/Core/Multilayer/FormFactorDWBAPol.cpp
+++ b/Core/Multilayer/FormFactorDWBAPol.cpp
@@ -17,13 +17,14 @@
 #include "ILayerRTCoefficients.h"
 #include "WavevectorInfo.h"
 
-
-namespace {
-    std::complex<double> VecMatVecProduct(const Eigen::Vector2cd& vec1, const Eigen::Matrix2cd& ff,
-                                const Eigen::Vector2cd& vec2){
-        return vec1.transpose() * ff * vec2;
-    }
+namespace
+{
+std::complex<double> VecMatVecProduct(const Eigen::Vector2cd& vec1, const Eigen::Matrix2cd& ff,
+                                      const Eigen::Vector2cd& vec2)
+{
+    return vec1.transpose() * ff * vec2;
 }
+} // namespace
 
 FormFactorDWBAPol::FormFactorDWBAPol(const IFormFactor& form_factor)
     : mP_form_factor(form_factor.clone())
@@ -31,18 +32,16 @@ FormFactorDWBAPol::FormFactorDWBAPol(const IFormFactor& form_factor)
     setName(BornAgain::FormFactorPolarizedDWBAType);
 }
 
-FormFactorDWBAPol::~FormFactorDWBAPol()
-{}
+FormFactorDWBAPol::~FormFactorDWBAPol() {}
 
 FormFactorDWBAPol* FormFactorDWBAPol::clone() const
 {
     FormFactorDWBAPol* p_result = new FormFactorDWBAPol(*mP_form_factor);
-    std::unique_ptr<const ILayerRTCoefficients> p_in_coefs
-        = mp_in_coeffs ? std::unique_ptr<const ILayerRTCoefficients>(mp_in_coeffs->clone())
-                       : nullptr;
-    std::unique_ptr<const ILayerRTCoefficients> p_out_coefs
-        = mp_out_coeffs ? std::unique_ptr<const ILayerRTCoefficients>(mp_out_coeffs->clone())
-                        : nullptr;
+    std::unique_ptr<const ILayerRTCoefficients> p_in_coefs =
+        mp_in_coeffs ? std::unique_ptr<const ILayerRTCoefficients>(mp_in_coeffs->clone()) : nullptr;
+    std::unique_ptr<const ILayerRTCoefficients> p_out_coefs =
+        mp_out_coeffs ? std::unique_ptr<const ILayerRTCoefficients>(mp_out_coeffs->clone())
+                      : nullptr;
     p_result->setSpecularInfo(std::move(p_in_coefs), std::move(p_out_coefs));
     return p_result;
 }
@@ -91,117 +90,111 @@ Eigen::Matrix2cd FormFactorDWBAPol::evaluatePol(const WavevectorInfo& wavevector
     // the 1/2 eigenstate, while the capital indices indicate a reflection
     // before and/or after the scattering event (first index is in-state,
     // second is out-state; this also applies to the internal matrix indices)
-    Eigen::Matrix2cd
-        M11_S, M11_RS, M11_SR, M11_RSR,
-        M12_S, M12_RS, M12_SR, M12_RSR,
-        M21_S, M21_RS, M21_SR, M21_RSR,
-        M22_S, M22_RS, M22_SR, M22_RSR;
+    Eigen::Matrix2cd M11_S, M11_RS, M11_SR, M11_RSR, M12_S, M12_RS, M12_SR, M12_RSR, M21_S, M21_RS,
+        M21_SR, M21_RSR, M22_S, M22_RS, M22_SR, M22_RSR;
 
     // eigenmode 1 -> eigenmode 1: direct scattering
     ff_BA = mP_form_factor->evaluatePol(WavevectorInfo(ki_1T, kf_1T, wavelength));
-    M11_S(0,0) = - VecMatVecProduct(mp_out_coeffs->T1min(), ff_BA, mp_in_coeffs->T1plus());
-    M11_S(0,1) =  VecMatVecProduct(mp_out_coeffs->T1plus(), ff_BA, mp_in_coeffs->T1plus());
-    M11_S(1,0) = - VecMatVecProduct(mp_out_coeffs->T1min(), ff_BA,  mp_in_coeffs->T1min());
-    M11_S(1,1) =  VecMatVecProduct(mp_out_coeffs->T1plus(), ff_BA, mp_in_coeffs->T1min());
+    M11_S(0, 0) = -VecMatVecProduct(mp_out_coeffs->T1min(), ff_BA, mp_in_coeffs->T1plus());
+    M11_S(0, 1) = VecMatVecProduct(mp_out_coeffs->T1plus(), ff_BA, mp_in_coeffs->T1plus());
+    M11_S(1, 0) = -VecMatVecProduct(mp_out_coeffs->T1min(), ff_BA, mp_in_coeffs->T1min());
+    M11_S(1, 1) = VecMatVecProduct(mp_out_coeffs->T1plus(), ff_BA, mp_in_coeffs->T1min());
     // eigenmode 1 -> eigenmode 1: reflection and then scattering
     ff_BA = mP_form_factor->evaluatePol(WavevectorInfo(ki_1R, kf_1T, wavelength));
-    M11_RS(0,0) = - VecMatVecProduct(mp_out_coeffs->T1min(), ff_BA, mp_in_coeffs->R1plus());
-    M11_RS(0,1) =  VecMatVecProduct(mp_out_coeffs->T1plus(), ff_BA, mp_in_coeffs->R1plus());
-    M11_RS(1,0) = - VecMatVecProduct(mp_out_coeffs->T1min(), ff_BA, mp_in_coeffs->R1min());
-    M11_RS(1,1) =  VecMatVecProduct(mp_out_coeffs->T1plus(), ff_BA, mp_in_coeffs->R1min());
+    M11_RS(0, 0) = -VecMatVecProduct(mp_out_coeffs->T1min(), ff_BA, mp_in_coeffs->R1plus());
+    M11_RS(0, 1) = VecMatVecProduct(mp_out_coeffs->T1plus(), ff_BA, mp_in_coeffs->R1plus());
+    M11_RS(1, 0) = -VecMatVecProduct(mp_out_coeffs->T1min(), ff_BA, mp_in_coeffs->R1min());
+    M11_RS(1, 1) = VecMatVecProduct(mp_out_coeffs->T1plus(), ff_BA, mp_in_coeffs->R1min());
     // eigenmode 1 -> eigenmode 1: scattering and then reflection
     ff_BA = mP_form_factor->evaluatePol(WavevectorInfo(ki_1T, kf_1R, wavelength));
-    M11_SR(0,0) = - VecMatVecProduct(mp_out_coeffs->R1min(), ff_BA, mp_in_coeffs->T1plus());
-    M11_SR(0,1) =  VecMatVecProduct(mp_out_coeffs->R1plus(), ff_BA, mp_in_coeffs->T1plus());
-    M11_SR(1,0) = - VecMatVecProduct(mp_out_coeffs->R1min(), ff_BA, mp_in_coeffs->T1min());
-    M11_SR(1,1) =  VecMatVecProduct(mp_out_coeffs->R1plus(), ff_BA, mp_in_coeffs->T1min());
+    M11_SR(0, 0) = -VecMatVecProduct(mp_out_coeffs->R1min(), ff_BA, mp_in_coeffs->T1plus());
+    M11_SR(0, 1) = VecMatVecProduct(mp_out_coeffs->R1plus(), ff_BA, mp_in_coeffs->T1plus());
+    M11_SR(1, 0) = -VecMatVecProduct(mp_out_coeffs->R1min(), ff_BA, mp_in_coeffs->T1min());
+    M11_SR(1, 1) = VecMatVecProduct(mp_out_coeffs->R1plus(), ff_BA, mp_in_coeffs->T1min());
     // eigenmode 1 -> eigenmode 1: reflection, scattering and again reflection
     ff_BA = mP_form_factor->evaluatePol(WavevectorInfo(ki_1R, kf_1R, wavelength));
-    M11_RSR(0,0) = - VecMatVecProduct(mp_out_coeffs->R1min(), ff_BA, mp_in_coeffs->R1plus());
-    M11_RSR(0,1) =  VecMatVecProduct(mp_out_coeffs->R1plus(), ff_BA, mp_in_coeffs->R1plus());
-    M11_RSR(1,0) = - VecMatVecProduct(mp_out_coeffs->R1min(), ff_BA, mp_in_coeffs->R1min());
-    M11_RSR(1,1) =  VecMatVecProduct(mp_out_coeffs->R1plus(), ff_BA, mp_in_coeffs->R1min());
+    M11_RSR(0, 0) = -VecMatVecProduct(mp_out_coeffs->R1min(), ff_BA, mp_in_coeffs->R1plus());
+    M11_RSR(0, 1) = VecMatVecProduct(mp_out_coeffs->R1plus(), ff_BA, mp_in_coeffs->R1plus());
+    M11_RSR(1, 0) = -VecMatVecProduct(mp_out_coeffs->R1min(), ff_BA, mp_in_coeffs->R1min());
+    M11_RSR(1, 1) = VecMatVecProduct(mp_out_coeffs->R1plus(), ff_BA, mp_in_coeffs->R1min());
 
     // eigenmode 1 -> eigenmode 2: direct scattering
     ff_BA = mP_form_factor->evaluatePol(WavevectorInfo(ki_1T, kf_2T, wavelength));
-    M12_S(0,0) = - VecMatVecProduct(mp_out_coeffs->T2min(), ff_BA, mp_in_coeffs->T1plus());
-    M12_S(0,1) =  VecMatVecProduct(mp_out_coeffs->T2plus(), ff_BA, mp_in_coeffs->T1plus());
-    M12_S(1,0) = - VecMatVecProduct(mp_out_coeffs->T2min(), ff_BA, mp_in_coeffs->T1min());
-    M12_S(1,1) =  VecMatVecProduct(mp_out_coeffs->T2plus(), ff_BA, mp_in_coeffs->T1min());
+    M12_S(0, 0) = -VecMatVecProduct(mp_out_coeffs->T2min(), ff_BA, mp_in_coeffs->T1plus());
+    M12_S(0, 1) = VecMatVecProduct(mp_out_coeffs->T2plus(), ff_BA, mp_in_coeffs->T1plus());
+    M12_S(1, 0) = -VecMatVecProduct(mp_out_coeffs->T2min(), ff_BA, mp_in_coeffs->T1min());
+    M12_S(1, 1) = VecMatVecProduct(mp_out_coeffs->T2plus(), ff_BA, mp_in_coeffs->T1min());
     // eigenmode 1 -> eigenmode 2: reflection and then scattering
     ff_BA = mP_form_factor->evaluatePol(WavevectorInfo(ki_1R, kf_2T, wavelength));
-    M12_RS(0,0) = - VecMatVecProduct(mp_out_coeffs->T2min(), ff_BA, mp_in_coeffs->R1plus());
-    M12_RS(0,1) =  VecMatVecProduct(mp_out_coeffs->T2plus(), ff_BA, mp_in_coeffs->R1plus());
-    M12_RS(1,0) = - VecMatVecProduct(mp_out_coeffs->T2min(), ff_BA, mp_in_coeffs->R1min());
-    M12_RS(1,1) =  VecMatVecProduct(mp_out_coeffs->T2plus(), ff_BA, mp_in_coeffs->R1min());
+    M12_RS(0, 0) = -VecMatVecProduct(mp_out_coeffs->T2min(), ff_BA, mp_in_coeffs->R1plus());
+    M12_RS(0, 1) = VecMatVecProduct(mp_out_coeffs->T2plus(), ff_BA, mp_in_coeffs->R1plus());
+    M12_RS(1, 0) = -VecMatVecProduct(mp_out_coeffs->T2min(), ff_BA, mp_in_coeffs->R1min());
+    M12_RS(1, 1) = VecMatVecProduct(mp_out_coeffs->T2plus(), ff_BA, mp_in_coeffs->R1min());
     // eigenmode 1 -> eigenmode 2: scattering and then reflection
     ff_BA = mP_form_factor->evaluatePol(WavevectorInfo(ki_1T, kf_2R, wavelength));
-    M12_SR(0,0) = - VecMatVecProduct(mp_out_coeffs->R2min(), ff_BA, mp_in_coeffs->T1plus());
-    M12_SR(0,1) =  VecMatVecProduct(mp_out_coeffs->R2plus(), ff_BA, mp_in_coeffs->T1plus());
-    M12_SR(1,0) = - VecMatVecProduct(mp_out_coeffs->R2min(), ff_BA, mp_in_coeffs->T1min());
-    M12_SR(1,1) =  VecMatVecProduct(mp_out_coeffs->R2plus(), ff_BA, mp_in_coeffs->T1min());
+    M12_SR(0, 0) = -VecMatVecProduct(mp_out_coeffs->R2min(), ff_BA, mp_in_coeffs->T1plus());
+    M12_SR(0, 1) = VecMatVecProduct(mp_out_coeffs->R2plus(), ff_BA, mp_in_coeffs->T1plus());
+    M12_SR(1, 0) = -VecMatVecProduct(mp_out_coeffs->R2min(), ff_BA, mp_in_coeffs->T1min());
+    M12_SR(1, 1) = VecMatVecProduct(mp_out_coeffs->R2plus(), ff_BA, mp_in_coeffs->T1min());
     // eigenmode 1 -> eigenmode 2: reflection, scattering and again reflection
     ff_BA = mP_form_factor->evaluatePol(WavevectorInfo(ki_1R, kf_2R, wavelength));
-    M12_RSR(0,0) = - VecMatVecProduct(mp_out_coeffs->R2min(), ff_BA, mp_in_coeffs->R1plus());
-    M12_RSR(0,1) =  VecMatVecProduct(mp_out_coeffs->R2plus(), ff_BA, mp_in_coeffs->R1plus());
-    M12_RSR(1,0) = - VecMatVecProduct(mp_out_coeffs->R2min(), ff_BA, mp_in_coeffs->R1min());
-    M12_RSR(1,1) =  VecMatVecProduct(mp_out_coeffs->R2plus(), ff_BA, mp_in_coeffs->R1min());
+    M12_RSR(0, 0) = -VecMatVecProduct(mp_out_coeffs->R2min(), ff_BA, mp_in_coeffs->R1plus());
+    M12_RSR(0, 1) = VecMatVecProduct(mp_out_coeffs->R2plus(), ff_BA, mp_in_coeffs->R1plus());
+    M12_RSR(1, 0) = -VecMatVecProduct(mp_out_coeffs->R2min(), ff_BA, mp_in_coeffs->R1min());
+    M12_RSR(1, 1) = VecMatVecProduct(mp_out_coeffs->R2plus(), ff_BA, mp_in_coeffs->R1min());
 
     // eigenmode 2 -> eigenmode 1: direct scattering
     ff_BA = mP_form_factor->evaluatePol(WavevectorInfo(ki_2T, kf_1T, wavelength));
-    M21_S(0,0) = - VecMatVecProduct(mp_out_coeffs->T1min(), ff_BA, mp_in_coeffs->T2plus());
-    M21_S(0,1) =  VecMatVecProduct(mp_out_coeffs->T1plus(), ff_BA, mp_in_coeffs->T2plus());
-    M21_S(1,0) = - VecMatVecProduct(mp_out_coeffs->T1min(), ff_BA, mp_in_coeffs->T2min());
-    M21_S(1,1) =  VecMatVecProduct(mp_out_coeffs->T1plus(), ff_BA, mp_in_coeffs->T2min());
+    M21_S(0, 0) = -VecMatVecProduct(mp_out_coeffs->T1min(), ff_BA, mp_in_coeffs->T2plus());
+    M21_S(0, 1) = VecMatVecProduct(mp_out_coeffs->T1plus(), ff_BA, mp_in_coeffs->T2plus());
+    M21_S(1, 0) = -VecMatVecProduct(mp_out_coeffs->T1min(), ff_BA, mp_in_coeffs->T2min());
+    M21_S(1, 1) = VecMatVecProduct(mp_out_coeffs->T1plus(), ff_BA, mp_in_coeffs->T2min());
     // eigenmode 2 -> eigenmode 1: reflection and then scattering
     ff_BA = mP_form_factor->evaluatePol(WavevectorInfo(ki_2R, kf_1T, wavelength));
-    M21_RS(0,0) = - VecMatVecProduct(mp_out_coeffs->T1min(), ff_BA, mp_in_coeffs->R2plus());
-    M21_RS(0,1) =  VecMatVecProduct(mp_out_coeffs->T1plus(), ff_BA, mp_in_coeffs->R2plus());
-    M21_RS(1,0) = - VecMatVecProduct(mp_out_coeffs->T1min(), ff_BA, mp_in_coeffs->R2min());
-    M21_RS(1,1) =  VecMatVecProduct(mp_out_coeffs->T1plus(), ff_BA, mp_in_coeffs->R2min());
+    M21_RS(0, 0) = -VecMatVecProduct(mp_out_coeffs->T1min(), ff_BA, mp_in_coeffs->R2plus());
+    M21_RS(0, 1) = VecMatVecProduct(mp_out_coeffs->T1plus(), ff_BA, mp_in_coeffs->R2plus());
+    M21_RS(1, 0) = -VecMatVecProduct(mp_out_coeffs->T1min(), ff_BA, mp_in_coeffs->R2min());
+    M21_RS(1, 1) = VecMatVecProduct(mp_out_coeffs->T1plus(), ff_BA, mp_in_coeffs->R2min());
     // eigenmode 2 -> eigenmode 1: scattering and then reflection
     ff_BA = mP_form_factor->evaluatePol(WavevectorInfo(ki_2T, kf_1R, wavelength));
-    M21_SR(0,0) = - VecMatVecProduct(mp_out_coeffs->R1min(), ff_BA, mp_in_coeffs->T2plus());
-    M21_SR(0,1) =  VecMatVecProduct(mp_out_coeffs->R1plus(), ff_BA, mp_in_coeffs->T2plus());
-    M21_SR(1,0) = - VecMatVecProduct(mp_out_coeffs->R1min(), ff_BA, mp_in_coeffs->T2min());
-    M21_SR(1,1) =  VecMatVecProduct(mp_out_coeffs->R1plus(), ff_BA, mp_in_coeffs->T2min());
+    M21_SR(0, 0) = -VecMatVecProduct(mp_out_coeffs->R1min(), ff_BA, mp_in_coeffs->T2plus());
+    M21_SR(0, 1) = VecMatVecProduct(mp_out_coeffs->R1plus(), ff_BA, mp_in_coeffs->T2plus());
+    M21_SR(1, 0) = -VecMatVecProduct(mp_out_coeffs->R1min(), ff_BA, mp_in_coeffs->T2min());
+    M21_SR(1, 1) = VecMatVecProduct(mp_out_coeffs->R1plus(), ff_BA, mp_in_coeffs->T2min());
     // eigenmode 2 -> eigenmode 1: reflection, scattering and again reflection
     ff_BA = mP_form_factor->evaluatePol(WavevectorInfo(ki_2R, kf_1R, wavelength));
-    M21_RSR(0,0) = - VecMatVecProduct(mp_out_coeffs->R1min(), ff_BA, mp_in_coeffs->R2plus());
-    M21_RSR(0,1) =  VecMatVecProduct(mp_out_coeffs->R1plus(), ff_BA, mp_in_coeffs->R2plus());
-    M21_RSR(1,0) = - VecMatVecProduct(mp_out_coeffs->R1min(), ff_BA, mp_in_coeffs->R2min());
-    M21_RSR(1,1) =  VecMatVecProduct(mp_out_coeffs->R1plus(), ff_BA, mp_in_coeffs->R2min());
+    M21_RSR(0, 0) = -VecMatVecProduct(mp_out_coeffs->R1min(), ff_BA, mp_in_coeffs->R2plus());
+    M21_RSR(0, 1) = VecMatVecProduct(mp_out_coeffs->R1plus(), ff_BA, mp_in_coeffs->R2plus());
+    M21_RSR(1, 0) = -VecMatVecProduct(mp_out_coeffs->R1min(), ff_BA, mp_in_coeffs->R2min());
+    M21_RSR(1, 1) = VecMatVecProduct(mp_out_coeffs->R1plus(), ff_BA, mp_in_coeffs->R2min());
 
     // eigenmode 2 -> eigenmode 2: direct scattering
     ff_BA = mP_form_factor->evaluatePol(WavevectorInfo(ki_2T, kf_2T, wavelength));
-    M22_S(0,0) = - VecMatVecProduct(mp_out_coeffs->T2min(), ff_BA, mp_in_coeffs->T2plus());
-    M22_S(0,1) =  VecMatVecProduct(mp_out_coeffs->T2plus(), ff_BA, mp_in_coeffs->T2plus());
-    M22_S(1,0) = - VecMatVecProduct(mp_out_coeffs->T2min(), ff_BA, mp_in_coeffs->T2min());
-    M22_S(1,1) =  VecMatVecProduct(mp_out_coeffs->T2plus(), ff_BA, mp_in_coeffs->T2min());
+    M22_S(0, 0) = -VecMatVecProduct(mp_out_coeffs->T2min(), ff_BA, mp_in_coeffs->T2plus());
+    M22_S(0, 1) = VecMatVecProduct(mp_out_coeffs->T2plus(), ff_BA, mp_in_coeffs->T2plus());
+    M22_S(1, 0) = -VecMatVecProduct(mp_out_coeffs->T2min(), ff_BA, mp_in_coeffs->T2min());
+    M22_S(1, 1) = VecMatVecProduct(mp_out_coeffs->T2plus(), ff_BA, mp_in_coeffs->T2min());
     // eigenmode 2 -> eigenmode 2: reflection and then scattering
     ff_BA = mP_form_factor->evaluatePol(WavevectorInfo(ki_2R, kf_2T, wavelength));
-    M22_RS(0,0) = - VecMatVecProduct(mp_out_coeffs->T2min(), ff_BA, mp_in_coeffs->R2plus());
-    M22_RS(0,1) =  VecMatVecProduct(mp_out_coeffs->T2plus(), ff_BA, mp_in_coeffs->R2plus());
-    M22_RS(1,0) = - VecMatVecProduct(mp_out_coeffs->T2min(), ff_BA, mp_in_coeffs->R2min());
-    M22_RS(1,1) =  VecMatVecProduct(mp_out_coeffs->T2plus(), ff_BA, mp_in_coeffs->R2min());
+    M22_RS(0, 0) = -VecMatVecProduct(mp_out_coeffs->T2min(), ff_BA, mp_in_coeffs->R2plus());
+    M22_RS(0, 1) = VecMatVecProduct(mp_out_coeffs->T2plus(), ff_BA, mp_in_coeffs->R2plus());
+    M22_RS(1, 0) = -VecMatVecProduct(mp_out_coeffs->T2min(), ff_BA, mp_in_coeffs->R2min());
+    M22_RS(1, 1) = VecMatVecProduct(mp_out_coeffs->T2plus(), ff_BA, mp_in_coeffs->R2min());
     // eigenmode 2 -> eigenmode 2: scattering and then reflection
     ff_BA = mP_form_factor->evaluatePol(WavevectorInfo(ki_2T, kf_2R, wavelength));
-    M22_SR(0,0) = - VecMatVecProduct(mp_out_coeffs->R2min(), ff_BA, mp_in_coeffs->T2plus());
-    M22_SR(0,1) =  VecMatVecProduct(mp_out_coeffs->R2plus(), ff_BA, mp_in_coeffs->T2plus());
-    M22_SR(1,0) = - VecMatVecProduct(mp_out_coeffs->R2min(), ff_BA, mp_in_coeffs->T2min());
-    M22_SR(1,1) =  VecMatVecProduct(mp_out_coeffs->R2plus(), ff_BA, mp_in_coeffs->T2min());
+    M22_SR(0, 0) = -VecMatVecProduct(mp_out_coeffs->R2min(), ff_BA, mp_in_coeffs->T2plus());
+    M22_SR(0, 1) = VecMatVecProduct(mp_out_coeffs->R2plus(), ff_BA, mp_in_coeffs->T2plus());
+    M22_SR(1, 0) = -VecMatVecProduct(mp_out_coeffs->R2min(), ff_BA, mp_in_coeffs->T2min());
+    M22_SR(1, 1) = VecMatVecProduct(mp_out_coeffs->R2plus(), ff_BA, mp_in_coeffs->T2min());
     // eigenmode 2 -> eigenmode 2: reflection, scattering and again reflection
     ff_BA = mP_form_factor->evaluatePol(WavevectorInfo(ki_2R, kf_2R, wavelength));
-    M22_RSR(0,0) = - VecMatVecProduct(mp_out_coeffs->R2min(), ff_BA, mp_in_coeffs->R2plus());
-    M22_RSR(0,1) =  VecMatVecProduct(mp_out_coeffs->R2plus(), ff_BA, mp_in_coeffs->R2plus());
-    M22_RSR(1,0) = - VecMatVecProduct(mp_out_coeffs->R2min(), ff_BA, mp_in_coeffs->R2min());
-    M22_RSR(1,1) =  VecMatVecProduct(mp_out_coeffs->R2plus(), ff_BA, mp_in_coeffs->R2min());
-
-    return
-        M11_S + M11_RS + M11_SR + M11_RSR +
-        M12_S + M12_RS + M12_SR + M12_RSR +
-        M21_S + M21_RS + M21_SR + M21_RSR +
-            M22_S + M22_RS + M22_SR + M22_RSR;
+    M22_RSR(0, 0) = -VecMatVecProduct(mp_out_coeffs->R2min(), ff_BA, mp_in_coeffs->R2plus());
+    M22_RSR(0, 1) = VecMatVecProduct(mp_out_coeffs->R2plus(), ff_BA, mp_in_coeffs->R2plus());
+    M22_RSR(1, 0) = -VecMatVecProduct(mp_out_coeffs->R2min(), ff_BA, mp_in_coeffs->R2min());
+    M22_RSR(1, 1) = VecMatVecProduct(mp_out_coeffs->R2plus(), ff_BA, mp_in_coeffs->R2min());
+
+    return M11_S + M11_RS + M11_SR + M11_RSR + M12_S + M12_RS + M12_SR + M12_RSR + M21_S + M21_RS
+           + M21_SR + M21_RSR + M22_S + M22_RS + M22_SR + M22_RSR;
 }
 
 double FormFactorDWBAPol::bottomZ(const IRotation& rotation) const
diff --git a/Core/Multilayer/FormFactorDWBAPol.h b/Core/Multilayer/FormFactorDWBAPol.h
index d0678c3e766..ea6a89446d3 100644
--- a/Core/Multilayer/FormFactorDWBAPol.h
+++ b/Core/Multilayer/FormFactorDWBAPol.h
@@ -34,7 +34,8 @@ public:
 
     void accept(INodeVisitor* visitor) const override { visitor->visit(this); }
 
-    void setAmbientMaterial(Material material) override {
+    void setAmbientMaterial(Material material) override
+    {
         mP_form_factor->setAmbientMaterial(std::move(material));
     }
 
diff --git a/Core/Multilayer/IFresnelMap.cpp b/Core/Multilayer/IFresnelMap.cpp
index 318bfd65ea0..8e93d659876 100644
--- a/Core/Multilayer/IFresnelMap.cpp
+++ b/Core/Multilayer/IFresnelMap.cpp
@@ -15,8 +15,10 @@
 #include "IFresnelMap.h"
 #include "Slice.h"
 
-IFresnelMap::IFresnelMap(std::unique_ptr<ISpecularStrategy> strategy) : m_use_cache(true),
-                                                                        m_Strategy(std::move(strategy)) {}
+IFresnelMap::IFresnelMap(std::unique_ptr<ISpecularStrategy> strategy)
+    : m_use_cache(true), m_Strategy(std::move(strategy))
+{
+}
 
 void IFresnelMap::setSlices(const std::vector<Slice>& slices)
 {
diff --git a/Core/Multilayer/IInterferenceFunctionStrategy.cpp b/Core/Multilayer/IInterferenceFunctionStrategy.cpp
index 88ddfcb93bc..c1a4c44143e 100644
--- a/Core/Multilayer/IInterferenceFunctionStrategy.cpp
+++ b/Core/Multilayer/IInterferenceFunctionStrategy.cpp
@@ -15,28 +15,27 @@
 #include "IInterferenceFunctionStrategy.h"
 #include "Exceptions.h"
 #include "FormFactorCoherentSum.h"
-#include "InterferenceFunctionNone.h"
 #include "IntegratorMCMiser.h"
+#include "InterferenceFunctionNone.h"
 #include "SimulationElement.h"
 
 IInterferenceFunctionStrategy::IInterferenceFunctionStrategy(const SimulationOptions& sim_params,
                                                              bool polarized)
-    : mP_iff(nullptr)
-    , m_options(sim_params)
-    , m_polarized(polarized)
-    , mP_integrator(make_integrator_miser(
-        this, &IInterferenceFunctionStrategy::evaluate_for_fixed_angles, 2) )
-{}
+    : mP_iff(nullptr), m_options(sim_params), m_polarized(polarized),
+      mP_integrator(
+          make_integrator_miser(this, &IInterferenceFunctionStrategy::evaluate_for_fixed_angles, 2))
+{
+}
 
-IInterferenceFunctionStrategy::~IInterferenceFunctionStrategy() =default;
+IInterferenceFunctionStrategy::~IInterferenceFunctionStrategy() = default;
 
 void IInterferenceFunctionStrategy::init(
     const std::vector<FormFactorCoherentSum>& weighted_formfactors,
     const IInterferenceFunction* p_iff)
 {
-    if (weighted_formfactors.size()==0)
+    if (weighted_formfactors.size() == 0)
         throw Exceptions::ClassInitializationException(
-                "IInterferenceFunctionStrategy::init: strategy gets no formfactors.");
+            "IInterferenceFunctionStrategy::init: strategy gets no formfactors.");
     m_formfactor_wrappers = weighted_formfactors;
     if (p_iff)
         mP_iff.reset(p_iff->clone());
@@ -53,8 +52,8 @@ double IInterferenceFunctionStrategy::evaluate(const SimulationElement& sim_elem
     return evaluateSinglePoint(sim_element);
 }
 
-double IInterferenceFunctionStrategy::evaluateSinglePoint(
-        const SimulationElement& sim_element) const
+double
+IInterferenceFunctionStrategy::evaluateSinglePoint(const SimulationElement& sim_element) const
 {
     if (!m_polarized)
         return scalarCalculation(sim_element);
@@ -63,17 +62,17 @@ double IInterferenceFunctionStrategy::evaluateSinglePoint(
 }
 
 //! Performs a Monte Carlo integration over the bin for the evaluation of the intensity.
-double IInterferenceFunctionStrategy::MCIntegratedEvaluate(
-    const SimulationElement& sim_element) const
+double
+IInterferenceFunctionStrategy::MCIntegratedEvaluate(const SimulationElement& sim_element) const
 {
     double min_array[] = {0.0, 0.0};
     double max_array[] = {1.0, 1.0};
-    return mP_integrator->integrate(
-        min_array, max_array, (void*)&sim_element, m_options.getMcPoints());
+    return mP_integrator->integrate(min_array, max_array, (void*)&sim_element,
+                                    m_options.getMcPoints());
 }
 
-double IInterferenceFunctionStrategy::evaluate_for_fixed_angles(
-    double* fractions, size_t, void* params) const
+double IInterferenceFunctionStrategy::evaluate_for_fixed_angles(double* fractions, size_t,
+                                                                void* params) const
 {
     double par0 = fractions[0];
     double par1 = fractions[1];
@@ -84,5 +83,4 @@ double IInterferenceFunctionStrategy::evaluate_for_fixed_angles(
     return pars->getIntegrationFactor(par0, par1) * evaluateSinglePoint(sim_element);
 }
 
-void IInterferenceFunctionStrategy::strategy_specific_post_init()
-{}
+void IInterferenceFunctionStrategy::strategy_specific_post_init() {}
diff --git a/Core/Multilayer/IInterferenceFunctionStrategy.h b/Core/Multilayer/IInterferenceFunctionStrategy.h
index ab50814e233..a83e0bf3a77 100644
--- a/Core/Multilayer/IInterferenceFunctionStrategy.h
+++ b/Core/Multilayer/IInterferenceFunctionStrategy.h
@@ -62,9 +62,9 @@ private:
     double evaluate_for_fixed_angles(double* fractions, size_t dim, void* params) const;
     virtual void strategy_specific_post_init();
     //! Evaluates the intensity in the scalar case
-    virtual double scalarCalculation(const SimulationElement& sim_element) const =0;
+    virtual double scalarCalculation(const SimulationElement& sim_element) const = 0;
     //! Evaluates the intensity in the polarized case
-    virtual double polarizedCalculation(const SimulationElement& sim_element) const =0;
+    virtual double polarizedCalculation(const SimulationElement& sim_element) const = 0;
 
     bool m_polarized;
 
diff --git a/Core/Multilayer/ILayerRTCoefficients.h b/Core/Multilayer/ILayerRTCoefficients.h
index 280730a5cd5..f60a64e9711 100644
--- a/Core/Multilayer/ILayerRTCoefficients.h
+++ b/Core/Multilayer/ILayerRTCoefficients.h
@@ -27,37 +27,39 @@ class BA_CORE_API_ ILayerRTCoefficients
 public:
     virtual ~ILayerRTCoefficients() {}
 
-    virtual ILayerRTCoefficients* clone() const=0;
+    virtual ILayerRTCoefficients* clone() const = 0;
 
 #ifndef SWIG
     //! The following functions return the transmitted and reflected amplitudes
     //! for different incoming beam polarizations and eigenmodes
-    virtual Eigen::Vector2cd T1plus() const=0;
-    virtual Eigen::Vector2cd R1plus() const=0;
-    virtual Eigen::Vector2cd T2plus() const=0;
-    virtual Eigen::Vector2cd R2plus() const=0;
-    virtual Eigen::Vector2cd T1min() const=0;
-    virtual Eigen::Vector2cd R1min() const=0;
-    virtual Eigen::Vector2cd T2min() const=0;
-    virtual Eigen::Vector2cd R2min() const=0;
+    virtual Eigen::Vector2cd T1plus() const = 0;
+    virtual Eigen::Vector2cd R1plus() const = 0;
+    virtual Eigen::Vector2cd T2plus() const = 0;
+    virtual Eigen::Vector2cd R2plus() const = 0;
+    virtual Eigen::Vector2cd T1min() const = 0;
+    virtual Eigen::Vector2cd R1min() const = 0;
+    virtual Eigen::Vector2cd T2min() const = 0;
+    virtual Eigen::Vector2cd R2min() const = 0;
     //! Returns z-part of the two wavevector eigenmodes
-    virtual Eigen::Vector2cd getKz() const=0;
+    virtual Eigen::Vector2cd getKz() const = 0;
     //! Scalar value getters; these throw errors by default as they should only
     //! be used when the derived object is really scalar
 #endif
-    virtual complex_t getScalarT() const {
+    virtual complex_t getScalarT() const
+    {
         throw Exceptions::NotImplementedException("ILayerRTCoefficients::"
-                "getScalarT(): coefficients are not scalar.");
+                                                  "getScalarT(): coefficients are not scalar.");
     }
-    virtual complex_t getScalarR() const {
+    virtual complex_t getScalarR() const
+    {
         throw Exceptions::NotImplementedException("ILayerRTCoefficients::"
-                "getScalarR(): coefficients are not scalar.");
+                                                  "getScalarR(): coefficients are not scalar.");
     }
-    virtual complex_t getScalarKz() const {
+    virtual complex_t getScalarKz() const
+    {
         throw Exceptions::NotImplementedException("ILayerRTCoefficients::"
-                "getScalarKz(): coefficients are not scalar.");
+                                                  "getScalarKz(): coefficients are not scalar.");
     }
 };
 
-
 #endif // ILAYERRTCOEFFICIENTS_H
diff --git a/Core/Multilayer/IMultiLayerBuilder.cpp b/Core/Multilayer/IMultiLayerBuilder.cpp
index 50673965c70..923a31ccd4a 100644
--- a/Core/Multilayer/IMultiLayerBuilder.cpp
+++ b/Core/Multilayer/IMultiLayerBuilder.cpp
@@ -19,4 +19,3 @@ IMultiLayerBuilder::IMultiLayerBuilder()
 {
     setName(BornAgain::SampleBuilderType);
 }
-
diff --git a/Core/Multilayer/IMultiLayerBuilder.h b/Core/Multilayer/IMultiLayerBuilder.h
index c34ca7150c3..9182d48ec48 100644
--- a/Core/Multilayer/IMultiLayerBuilder.h
+++ b/Core/Multilayer/IMultiLayerBuilder.h
@@ -27,14 +27,18 @@ class BA_CORE_API_ IMultiLayerBuilder : public IParameterized
 public:
     IMultiLayerBuilder();
 
-    virtual MultiLayer* buildSample() const =0;
+    virtual MultiLayer* buildSample() const = 0;
 
     // this method is extended in the Python wrappers (needed to solve ownership issues with
     // the created sample in buildSample()
     static bool isPythonBuilder() { return false; }
 
-    virtual MultiLayer* createSample(size_t index=0) { (void)index; return buildSample(); }
-    virtual size_t size() { return 1;}
+    virtual MultiLayer* createSample(size_t index = 0)
+    {
+        (void)index;
+        return buildSample();
+    }
+    virtual size_t size() { return 1; }
 };
 
 #endif // IMULTILAYERBUILDER_H
diff --git a/Core/Multilayer/ISpecularStrategy.h b/Core/Multilayer/ISpecularStrategy.h
index 2fd03aac6d8..901df5c1d4a 100644
--- a/Core/Multilayer/ISpecularStrategy.h
+++ b/Core/Multilayer/ISpecularStrategy.h
@@ -15,8 +15,8 @@
 #ifndef ISPECULARSTRATEGY_H
 #define ISPECULARSTRATEGY_H
 
-#include "Slice.h"
 #include "ILayerRTCoefficients.h"
+#include "Slice.h"
 
 class BA_CORE_API_ ISpecularStrategy
 {
@@ -24,12 +24,10 @@ public:
     using single_coeff_t = std::unique_ptr<const ILayerRTCoefficients>;
     using coeffs_t = std::vector<single_coeff_t>;
 
-    virtual coeffs_t
-    Execute(const std::vector<Slice>& slices, const kvector_t& k) const = 0;
-
-    virtual coeffs_t
-    Execute(const std::vector<Slice>& slices, const std::vector<complex_t>& kz) const = 0;
+    virtual coeffs_t Execute(const std::vector<Slice>& slices, const kvector_t& k) const = 0;
 
+    virtual coeffs_t Execute(const std::vector<Slice>& slices,
+                             const std::vector<complex_t>& kz) const = 0;
 };
 
 #endif // ISPECULARSTRATEGY_H
diff --git a/Core/Multilayer/InterferenceFunctionUtils.cpp b/Core/Multilayer/InterferenceFunctionUtils.cpp
index baa9bf38a1c..2656c05792d 100644
--- a/Core/Multilayer/InterferenceFunctionUtils.cpp
+++ b/Core/Multilayer/InterferenceFunctionUtils.cpp
@@ -17,25 +17,25 @@
 
 namespace InterferenceFunctionUtils
 {
-std::vector<complex_t> PrecomputeScalarFormFactors(
-        const SimulationElement& sim_element,
-        const std::vector<FormFactorCoherentSum>& ff_wrappers)
+std::vector<complex_t>
+PrecomputeScalarFormFactors(const SimulationElement& sim_element,
+                            const std::vector<FormFactorCoherentSum>& ff_wrappers)
 {
     std::vector<complex_t> result;
-    for (auto& ffw: ff_wrappers) {
+    for (auto& ffw : ff_wrappers) {
         result.push_back(ffw.evaluate(sim_element));
     }
     return result;
 }
 
-matrixFFVector_t PrecomputePolarizedFormFactors(
-        const SimulationElement& sim_element,
-        const std::vector<FormFactorCoherentSum>& ff_wrappers)
+matrixFFVector_t
+PrecomputePolarizedFormFactors(const SimulationElement& sim_element,
+                               const std::vector<FormFactorCoherentSum>& ff_wrappers)
 {
     matrixFFVector_t result;
-    for (auto& ffw: ff_wrappers) {
+    for (auto& ffw : ff_wrappers) {
         result.push_back(ffw.evaluatePol(sim_element));
     }
     return result;
 }
-}  // namespace InterferenceFunctionUtils
+} // namespace InterferenceFunctionUtils
diff --git a/Core/Multilayer/InterferenceFunctionUtils.h b/Core/Multilayer/InterferenceFunctionUtils.h
index d9a5dcfe4d2..2fad9d52d0b 100644
--- a/Core/Multilayer/InterferenceFunctionUtils.h
+++ b/Core/Multilayer/InterferenceFunctionUtils.h
@@ -26,14 +26,13 @@ namespace InterferenceFunctionUtils
 {
 using matrixFFVector_t = std::vector<Eigen::Matrix2cd, Eigen::aligned_allocator<Eigen::Matrix2cd>>;
 
-std::vector<complex_t> PrecomputeScalarFormFactors(
-        const SimulationElement& sim_element,
-        const std::vector<FormFactorCoherentSum>& ff_wrappers);
-matrixFFVector_t PrecomputePolarizedFormFactors(
-        const SimulationElement& sim_element,
-        const std::vector<FormFactorCoherentSum>& ff_wrappers);
-
-
-}  // namespace InterferenceFunctionUtils
+std::vector<complex_t>
+PrecomputeScalarFormFactors(const SimulationElement& sim_element,
+                            const std::vector<FormFactorCoherentSum>& ff_wrappers);
+matrixFFVector_t
+PrecomputePolarizedFormFactors(const SimulationElement& sim_element,
+                               const std::vector<FormFactorCoherentSum>& ff_wrappers);
+
+} // namespace InterferenceFunctionUtils
 
 #endif // INTERFERENCEFUNCTIONUTILS_H
diff --git a/Core/Multilayer/Layer.cpp b/Core/Multilayer/Layer.cpp
index 2e48b138c8e..dfbd4adcd02 100644
--- a/Core/Multilayer/Layer.cpp
+++ b/Core/Multilayer/Layer.cpp
@@ -23,15 +23,13 @@
 //! @param material: material the layer is made of
 //! @param thickness: thickness of a layer in nanometers
 Layer::Layer(Material material, double thickness)
-    : m_material(std::move(material))
-    , m_thickness(thickness)
+    : m_material(std::move(material)), m_thickness(thickness)
 {
     setName(BornAgain::LayerType);
     registerThickness();
 }
 
-Layer::~Layer()
-{}
+Layer::~Layer() {}
 
 Layer* Layer::clone() const
 {
@@ -75,16 +73,17 @@ std::vector<const ILayout*> Layer::layouts() const
 std::vector<const INode*> Layer::getChildren() const
 {
     std::vector<const INode*> result;
-    for(auto layout : m_layouts)
+    for (auto layout : m_layouts)
         result.push_back(layout);
     return result;
 }
 
 void Layer::registerThickness(bool make_registered)
 {
-    if(make_registered) {
-        if(!parameter(BornAgain::Thickness))
-            registerParameter(BornAgain::Thickness, &m_thickness).setUnit(BornAgain::UnitsNm)
+    if (make_registered) {
+        if (!parameter(BornAgain::Thickness))
+            registerParameter(BornAgain::Thickness, &m_thickness)
+                .setUnit(BornAgain::UnitsNm)
                 .setNonnegative();
     } else {
         removeParameter(BornAgain::Thickness);
diff --git a/Core/Multilayer/Layer.h b/Core/Multilayer/Layer.h
index 263f1a06400..02c4421fc9e 100644
--- a/Core/Multilayer/Layer.h
+++ b/Core/Multilayer/Layer.h
@@ -57,7 +57,7 @@ private:
     kvector_t m_B_field;                  //!< cached value of magnetic induction
     double m_thickness;                   //!< layer thickness in nanometers
     SafePointerVector<ILayout> m_layouts; //!< independent layouts in this layer
-    unsigned int m_n_slices=1;            //!< number of slices to create for graded layer approach
+    unsigned int m_n_slices = 1;          //!< number of slices to create for graded layer approach
 };
 
 #endif // LAYER_H
diff --git a/Core/Multilayer/LayerFillLimits.cpp b/Core/Multilayer/LayerFillLimits.cpp
index 2ab43c357c0..b6c0deda3a5 100644
--- a/Core/Multilayer/LayerFillLimits.cpp
+++ b/Core/Multilayer/LayerFillLimits.cpp
@@ -22,24 +22,24 @@ ZLimits CalculateNewLayerLimits(ZLimits old_limits, ZLimits bounded_limits);
 }
 
 LayerFillLimits::LayerFillLimits(std::vector<double> layers_bottomz)
-    : m_layers_bottomz(std::move(layers_bottomz))
-    , m_layer_fill_limits(m_layers_bottomz.size() + 1)
-    // default ZLimits designate an absence of limits
-{}
+    : m_layers_bottomz(std::move(layers_bottomz)), m_layer_fill_limits(m_layers_bottomz.size() + 1)
+// default ZLimits designate an absence of limits
+{
+}
 
 void LayerFillLimits::update(ParticleLimits particle_limits, double offset)
 {
-    if (m_layers_bottomz.empty()) return;  // do nothing for the single layer case
+    if (m_layers_bottomz.empty())
+        return; // do nothing for the single layer case
     double top = particle_limits.m_top + offset;
     double bottom = particle_limits.m_bottom + offset;
     if (bottom > top)
         throw std::runtime_error("LayerFillLimits::update: lower_limit > upper_limit.");
-    if (bottom == top)  // zero-size particle
+    if (bottom == top) // zero-size particle
         return;
     size_t top_index = layerIndexTop(top);
     size_t bottom_index = layerIndexBottom(bottom);
-    for (size_t i_layer=top_index; i_layer<bottom_index+1; ++i_layer)
-    {
+    for (size_t i_layer = top_index; i_layer < bottom_index + 1; ++i_layer) {
         ZLimits limits(bottom, top);
         updateLayerLimits(i_layer, limits);
     }
@@ -56,8 +56,7 @@ size_t LayerFillLimits::layerIndexTop(double top_z) const
         return 0;
     if (top_z <= m_layers_bottomz.back())
         return m_layers_bottomz.size();
-    auto index_above = std::lower_bound(m_layers_bottomz.rbegin(),
-                                        m_layers_bottomz.rend(), top_z);
+    auto index_above = std::lower_bound(m_layers_bottomz.rbegin(), m_layers_bottomz.rend(), top_z);
     return static_cast<size_t>(m_layers_bottomz.rend() - index_above);
 }
 
@@ -67,10 +66,9 @@ size_t LayerFillLimits::layerIndexBottom(double bottom_z) const
         return 0;
     if (bottom_z < m_layers_bottomz.back())
         return m_layers_bottomz.size();
-    auto index_below = std::upper_bound(m_layers_bottomz.rbegin(),
-                                        m_layers_bottomz.rend(), bottom_z);
+    auto index_below =
+        std::upper_bound(m_layers_bottomz.rbegin(), m_layers_bottomz.rend(), bottom_z);
     return static_cast<size_t>(m_layers_bottomz.rend() - index_below);
-
 }
 
 void LayerFillLimits::updateLayerLimits(size_t i_layer, ZLimits limits)
@@ -79,13 +77,12 @@ void LayerFillLimits::updateLayerLimits(size_t i_layer, ZLimits limits)
         throw std::runtime_error("LayerFillLimits::updateLayerLimits: given limits are not "
                                  "finite.");
     auto old_limits = m_layer_fill_limits[i_layer];
-    double layer_ref = i_layer ? m_layers_bottomz[i_layer-1]
-                               : m_layers_bottomz[i_layer];
-    double upper = i_layer ? std::min(limits.upperLimit().m_value, layer_ref)
-                           : limits.upperLimit().m_value;
-    double lower = (i_layer==m_layer_fill_limits.size()-1)
-                    ? limits.lowerLimit().m_value
-                    : std::max(limits.lowerLimit().m_value, m_layers_bottomz[i_layer]);
+    double layer_ref = i_layer ? m_layers_bottomz[i_layer - 1] : m_layers_bottomz[i_layer];
+    double upper =
+        i_layer ? std::min(limits.upperLimit().m_value, layer_ref) : limits.upperLimit().m_value;
+    double lower = (i_layer == m_layer_fill_limits.size() - 1)
+                       ? limits.lowerLimit().m_value
+                       : std::max(limits.lowerLimit().m_value, m_layers_bottomz[i_layer]);
     ZLimits bounded_limits(lower - layer_ref, upper - layer_ref);
     m_layer_fill_limits[i_layer] = CalculateNewLayerLimits(old_limits, bounded_limits);
 }
@@ -99,4 +96,4 @@ ZLimits CalculateNewLayerLimits(ZLimits old_limits, ZLimits bounded_limits)
     else
         return ConvexHull(old_limits, bounded_limits);
 }
-}
+} // namespace
diff --git a/Core/Multilayer/LayerFillLimits.h b/Core/Multilayer/LayerFillLimits.h
index 900a8201dbf..3b13f19ab11 100644
--- a/Core/Multilayer/LayerFillLimits.h
+++ b/Core/Multilayer/LayerFillLimits.h
@@ -18,8 +18,8 @@
 #include "IParticle.h"
 #include "ZLimits.h"
 #include <cstddef>
-#include <vector>
 #include <utility>
+#include <vector>
 
 //! Helper class for the graded layer approximation. Generates limits for each layer, indicating
 //! the region of the layer (along z) that contains particle(s)
@@ -34,10 +34,11 @@ public:
     LayerFillLimits(std::vector<double> layers_bottomz);
 
     //! Particle limits are given in global coordinates
-    void update(ParticleLimits particle_limits, double offset=0.0);
+    void update(ParticleLimits particle_limits, double offset = 0.0);
 
     //! Returns the filled region limits for each layer (in local layer coordinates)
     std::vector<ZLimits> layerZLimits() const;
+
 private:
     size_t layerIndexTop(double top_z) const;
     size_t layerIndexBottom(double bottom_z) const;
diff --git a/Core/Multilayer/LayerInterface.cpp b/Core/Multilayer/LayerInterface.cpp
index 96910d2850d..84d18b6a45a 100644
--- a/Core/Multilayer/LayerInterface.cpp
+++ b/Core/Multilayer/LayerInterface.cpp
@@ -22,9 +22,7 @@ LayerInterface::LayerInterface() : m_topLayer(nullptr), m_bottomLayer(nullptr)
     setName(BornAgain::LayerInterfaceType);
 }
 
-LayerInterface::~LayerInterface()
-{
-}
+LayerInterface::~LayerInterface() {}
 
 LayerInterface* LayerInterface::clone() const
 {
diff --git a/Core/Multilayer/LayerRoughness.cpp b/Core/Multilayer/LayerRoughness.cpp
index ac85008e3c3..368f318ae97 100644
--- a/Core/Multilayer/LayerRoughness.cpp
+++ b/Core/Multilayer/LayerRoughness.cpp
@@ -17,10 +17,7 @@
 #include "MathConstants.h"
 #include "RealParameter.h"
 
-LayerRoughness::LayerRoughness()
-    : m_sigma(0)
-    , m_hurstParameter(0)
-    , m_lateralCorrLength(0)
+LayerRoughness::LayerRoughness() : m_sigma(0), m_hurstParameter(0), m_lateralCorrLength(0)
 {
     initialize();
 }
@@ -31,9 +28,7 @@ LayerRoughness::LayerRoughness()
 //! dimensionless [0.0, 1.0], where 0.0 gives more spikes, 1.0 more smoothness
 //! @param lateralCorrLength: lateral correlation length of the roughness in nanometers
 LayerRoughness::LayerRoughness(double sigma, double hurstParameter, double lateralCorrLength)
-    : m_sigma(sigma)
-    , m_hurstParameter(hurstParameter)
-    , m_lateralCorrLength(lateralCorrLength)
+    : m_sigma(sigma), m_hurstParameter(hurstParameter), m_lateralCorrLength(lateralCorrLength)
 {
     initialize();
 }
@@ -43,11 +38,11 @@ void LayerRoughness::initialize()
     setName(BornAgain::LayerBasicRoughnessType);
     registerParameter(BornAgain::Sigma, &m_sigma);
     registerParameter(BornAgain::Hurst, &m_hurstParameter);
-    registerParameter(BornAgain::CorrelationLength, &m_lateralCorrLength).
-        setUnit(BornAgain::UnitsNm).setNonnegative();
+    registerParameter(BornAgain::CorrelationLength, &m_lateralCorrLength)
+        .setUnit(BornAgain::UnitsNm)
+        .setNonnegative();
 }
 
-
 /* ************************************************************************* */
 //! Power spectral density of the surface roughness is a result of two-dimensional
 //! Fourier transform of the correlation function of the roughness profile.
@@ -59,10 +54,10 @@ void LayerRoughness::initialize()
 double LayerRoughness::getSpectralFun(const kvector_t kvec) const
 {
     double H = m_hurstParameter;
-    double clength2 = m_lateralCorrLength*m_lateralCorrLength;
-    double Qpar2 = kvec.x()*kvec.x() + kvec.y()*kvec.y();
-    return 4.0*M_PI*H * m_sigma*m_sigma * clength2 *
-        std::pow( (1.0 + Qpar2*clength2), (-1-H) );
+    double clength2 = m_lateralCorrLength * m_lateralCorrLength;
+    double Qpar2 = kvec.x() * kvec.x() + kvec.y() * kvec.y();
+    return 4.0 * M_PI * H * m_sigma * m_sigma * clength2
+           * std::pow((1.0 + Qpar2 * clength2), (-1 - H));
 }
 
 //! Correlation function of the roughness profile
@@ -71,6 +66,6 @@ double LayerRoughness::getCorrFun(const kvector_t k) const
 {
     double H = m_hurstParameter;
     double clength = m_lateralCorrLength;
-    double R = sqrt(k.x()*k.x() + k.y()*k.y());
-    return m_sigma*m_sigma*std::exp( -1.0*std::pow(R/clength, 2.*H) );
+    double R = sqrt(k.x() * k.x() + k.y() * k.y());
+    return m_sigma * m_sigma * std::exp(-1.0 * std::pow(R / clength, 2. * H));
 }
diff --git a/Core/Multilayer/LayerRoughness.h b/Core/Multilayer/LayerRoughness.h
index c990e70a8c4..db24be98f14 100644
--- a/Core/Multilayer/LayerRoughness.h
+++ b/Core/Multilayer/LayerRoughness.h
@@ -32,8 +32,10 @@ public:
     LayerRoughness();
     LayerRoughness(double sigma, double hurstParameter, double lateralCorrLength);
 
-    LayerRoughness* clone() const {
-        return new LayerRoughness(m_sigma, m_hurstParameter, m_lateralCorrLength); }
+    LayerRoughness* clone() const
+    {
+        return new LayerRoughness(m_sigma, m_hurstParameter, m_lateralCorrLength);
+    }
     virtual void accept(INodeVisitor* visitor) const { visitor->visit(this); }
 
     //! Returns power spectral density of the surface roughness
@@ -52,15 +54,17 @@ public:
     double getHurstParameter() const { return m_hurstParameter; }
 
     //! Sets lateral correlation length
-    void setLatteralCorrLength(double lateralCorrLength) {
-        m_lateralCorrLength = lateralCorrLength; }
+    void setLatteralCorrLength(double lateralCorrLength)
+    {
+        m_lateralCorrLength = lateralCorrLength;
+    }
     //! Returns lateral correlation length
     double getLatteralCorrLength() const { return m_lateralCorrLength; }
 
 protected:
-    double m_sigma;                //!< rms of roughness
-    double m_hurstParameter;   //!< Hurst parameter which describes how jagged the interface, 0<H<=1
-    double m_lateralCorrLength;   //!< lateral correlation length of the roughness
+    double m_sigma;          //!< rms of roughness
+    double m_hurstParameter; //!< Hurst parameter which describes how jagged the interface, 0<H<=1
+    double m_lateralCorrLength; //!< lateral correlation length of the roughness
 
 private:
     void initialize();
diff --git a/Core/Multilayer/LayoutStrategyBuilder.cpp b/Core/Multilayer/LayoutStrategyBuilder.cpp
index 24a4c3aa2ba..c6a15aae5dd 100644
--- a/Core/Multilayer/LayoutStrategyBuilder.cpp
+++ b/Core/Multilayer/LayoutStrategyBuilder.cpp
@@ -14,24 +14,20 @@
 
 #include "LayoutStrategyBuilder.h"
 #include "DecouplingApproximationStrategy.h"
-#include "SSCApproximationStrategy.h"
 #include "Exceptions.h"
 #include "InterferenceFunctionRadialParaCrystal.h"
 #include "ProcessedLayout.h"
+#include "SSCApproximationStrategy.h"
 
-
-LayoutStrategyBuilder::LayoutStrategyBuilder(
-    const ProcessedLayout* p_layout, const SimulationOptions& sim_params, bool polarized)
-    : mp_layout(p_layout)
-    , m_sim_params(sim_params)
-    , m_polarized(polarized)
+LayoutStrategyBuilder::LayoutStrategyBuilder(const ProcessedLayout* p_layout,
+                                             const SimulationOptions& sim_params, bool polarized)
+    : mp_layout(p_layout), m_sim_params(sim_params), m_polarized(polarized)
 {
     createStrategy();
 }
 
 // needs class definitions => don't move to .h
-LayoutStrategyBuilder::~LayoutStrategyBuilder()
-{}
+LayoutStrategyBuilder::~LayoutStrategyBuilder() {}
 
 IInterferenceFunctionStrategy* LayoutStrategyBuilder::releaseStrategy()
 {
@@ -45,7 +41,7 @@ void LayoutStrategyBuilder::createStrategy()
     checkInterferenceFunction(p_iff);
 
     auto p_radial_para = dynamic_cast<const InterferenceFunctionRadialParaCrystal*>(p_iff);
-    if (p_radial_para && p_radial_para->kappa()>0.0) {
+    if (p_radial_para && p_radial_para->kappa() > 0.0) {
         double kappa = p_radial_para->kappa();
         mP_strategy.reset(new SSCApproximationStrategy(m_sim_params, kappa, m_polarized));
     } else {
@@ -60,7 +56,7 @@ void LayoutStrategyBuilder::createStrategy()
 void LayoutStrategyBuilder::checkInterferenceFunction(const IInterferenceFunction* p_iff)
 {
     auto n_slices = mp_layout->numberOfSlices();
-    if (p_iff && n_slices>1 && !p_iff->supportsMultilayer())
+    if (p_iff && n_slices > 1 && !p_iff->supportsMultilayer())
         throw std::runtime_error("LayoutStrategyBuilder::checkInterferenceFunction: "
                                  "interference function does not support multiple layers");
 }
diff --git a/Core/Multilayer/LayoutStrategyBuilder.h b/Core/Multilayer/LayoutStrategyBuilder.h
index 17941fa8b85..639c457facc 100644
--- a/Core/Multilayer/LayoutStrategyBuilder.h
+++ b/Core/Multilayer/LayoutStrategyBuilder.h
@@ -28,8 +28,8 @@ class ProcessedLayout;
 class BA_CORE_API_ LayoutStrategyBuilder
 {
 public:
-    LayoutStrategyBuilder(
-        const ProcessedLayout* p_layout, const SimulationOptions& sim_params, bool polarized);
+    LayoutStrategyBuilder(const ProcessedLayout* p_layout, const SimulationOptions& sim_params,
+                          bool polarized);
 
     ~LayoutStrategyBuilder();
 
@@ -41,7 +41,7 @@ private:
 
     const ProcessedLayout* mp_layout;
     SimulationOptions m_sim_params;
-    bool m_polarized;  //!< polarized computation required?
+    bool m_polarized; //!< polarized computation required?
     std::unique_ptr<IInterferenceFunctionStrategy> mP_strategy;
 };
 
diff --git a/Core/Multilayer/MatrixFresnelMap.h b/Core/Multilayer/MatrixFresnelMap.h
index 06b3a23afb6..0be1c194a0a 100644
--- a/Core/Multilayer/MatrixFresnelMap.h
+++ b/Core/Multilayer/MatrixFresnelMap.h
@@ -67,9 +67,9 @@ private:
     mutable CoefficientHash m_hash_table_out;
     mutable CoefficientHash m_hash_table_in;
 
-    const ISpecularStrategy::coeffs_t&
-    getCoefficientsFromCache(kvector_t kvec, const std::vector<Slice>& slices,
-                             CoefficientHash& hash_table) const;
+    const ISpecularStrategy::coeffs_t& getCoefficientsFromCache(kvector_t kvec,
+                                                                const std::vector<Slice>& slices,
+                                                                CoefficientHash& hash_table) const;
 };
 
 #endif // MATRIXFRESNELMAP_H
diff --git a/Core/Multilayer/MatrixRTCoefficients.cpp b/Core/Multilayer/MatrixRTCoefficients.cpp
index 214b6fceb1b..d625ea4673c 100644
--- a/Core/Multilayer/MatrixRTCoefficients.cpp
+++ b/Core/Multilayer/MatrixRTCoefficients.cpp
@@ -14,7 +14,7 @@
 
 #include "MatrixRTCoefficients.h"
 
-MatrixRTCoefficients *MatrixRTCoefficients::clone() const
+MatrixRTCoefficients* MatrixRTCoefficients::clone() const
 {
     return new MatrixRTCoefficients(*this);
 }
@@ -22,10 +22,10 @@ MatrixRTCoefficients *MatrixRTCoefficients::clone() const
 Eigen::Vector2cd MatrixRTCoefficients::T1plus() const
 {
     Eigen::Vector2cd result;
-    Eigen::Matrix<complex_t, 4, 1> m = T1m*phi_psi_plus;
+    Eigen::Matrix<complex_t, 4, 1> m = T1m * phi_psi_plus;
     result(0) = m(2);
     result(1) = m(3);
-    if (lambda(0)==0.0 && result==Eigen::Vector2cd::Zero())
+    if (lambda(0) == 0.0 && result == Eigen::Vector2cd::Zero())
         result(0) = 0.5;
     return result;
 }
@@ -33,11 +33,11 @@ Eigen::Vector2cd MatrixRTCoefficients::T1plus() const
 Eigen::Vector2cd MatrixRTCoefficients::R1plus() const
 {
     Eigen::Vector2cd result;
-    Eigen::Matrix<complex_t, 4, 1> m = R1m*phi_psi_plus;
+    Eigen::Matrix<complex_t, 4, 1> m = R1m * phi_psi_plus;
     result(0) = m(2);
     result(1) = m(3);
-    Eigen::Matrix<complex_t, 4, 1> mT = T1m*phi_psi_plus;
-    if (lambda(0)==0.0 && mT(2)==0.0 && mT(3)==0.0)
+    Eigen::Matrix<complex_t, 4, 1> mT = T1m * phi_psi_plus;
+    if (lambda(0) == 0.0 && mT(2) == 0.0 && mT(3) == 0.0)
         result(0) = -0.5;
     return result;
 }
@@ -45,10 +45,10 @@ Eigen::Vector2cd MatrixRTCoefficients::R1plus() const
 Eigen::Vector2cd MatrixRTCoefficients::T2plus() const
 {
     Eigen::Vector2cd result;
-    Eigen::Matrix<complex_t, 4, 1> m = T2m*phi_psi_plus;
+    Eigen::Matrix<complex_t, 4, 1> m = T2m * phi_psi_plus;
     result(0) = m(2);
     result(1) = m(3);
-    if (lambda(1)==0.0 && result==Eigen::Vector2cd::Zero())
+    if (lambda(1) == 0.0 && result == Eigen::Vector2cd::Zero())
         result(0) = 0.5;
     return result;
 }
@@ -56,11 +56,11 @@ Eigen::Vector2cd MatrixRTCoefficients::T2plus() const
 Eigen::Vector2cd MatrixRTCoefficients::R2plus() const
 {
     Eigen::Vector2cd result;
-    Eigen::Matrix<complex_t, 4, 1> m = R2m*phi_psi_plus;
+    Eigen::Matrix<complex_t, 4, 1> m = R2m * phi_psi_plus;
     result(0) = m(2);
     result(1) = m(3);
-    Eigen::Matrix<complex_t, 4, 1> mT = T2m*phi_psi_plus;
-    if (lambda(1)==0.0 && mT(2)==0.0 && mT(3)==0.0)
+    Eigen::Matrix<complex_t, 4, 1> mT = T2m * phi_psi_plus;
+    if (lambda(1) == 0.0 && mT(2) == 0.0 && mT(3) == 0.0)
         result(0) = -0.5;
     return result;
 }
@@ -68,10 +68,10 @@ Eigen::Vector2cd MatrixRTCoefficients::R2plus() const
 Eigen::Vector2cd MatrixRTCoefficients::T1min() const
 {
     Eigen::Vector2cd result;
-    Eigen::Matrix<complex_t, 4, 1> m = T1m*phi_psi_min;
+    Eigen::Matrix<complex_t, 4, 1> m = T1m * phi_psi_min;
     result(0) = m(2);
     result(1) = m(3);
-    if (lambda(0)==0.0 && result==Eigen::Vector2cd::Zero())
+    if (lambda(0) == 0.0 && result == Eigen::Vector2cd::Zero())
         result(1) = 0.5;
     return result;
 }
@@ -79,11 +79,11 @@ Eigen::Vector2cd MatrixRTCoefficients::T1min() const
 Eigen::Vector2cd MatrixRTCoefficients::R1min() const
 {
     Eigen::Vector2cd result;
-    Eigen::Matrix<complex_t, 4, 1> m = R1m*phi_psi_min;
+    Eigen::Matrix<complex_t, 4, 1> m = R1m * phi_psi_min;
     result(0) = m(2);
     result(1) = m(3);
-    Eigen::Matrix<complex_t, 4, 1> mT = T1m*phi_psi_min;
-    if (lambda(0)==0.0 && mT(2)==0.0 && mT(3)==0.0)
+    Eigen::Matrix<complex_t, 4, 1> mT = T1m * phi_psi_min;
+    if (lambda(0) == 0.0 && mT(2) == 0.0 && mT(3) == 0.0)
         result(1) = -0.5;
     return result;
 }
@@ -91,10 +91,10 @@ Eigen::Vector2cd MatrixRTCoefficients::R1min() const
 Eigen::Vector2cd MatrixRTCoefficients::T2min() const
 {
     Eigen::Vector2cd result;
-    Eigen::Matrix<complex_t, 4, 1> m = T2m*phi_psi_min;
+    Eigen::Matrix<complex_t, 4, 1> m = T2m * phi_psi_min;
     result(0) = m(2);
     result(1) = m(3);
-    if (lambda(1)==0.0 && result==Eigen::Vector2cd::Zero())
+    if (lambda(1) == 0.0 && result == Eigen::Vector2cd::Zero())
         result(1) = 0.5;
     return result;
 }
@@ -102,11 +102,11 @@ Eigen::Vector2cd MatrixRTCoefficients::T2min() const
 Eigen::Vector2cd MatrixRTCoefficients::R2min() const
 {
     Eigen::Vector2cd result;
-    Eigen::Matrix<complex_t, 4, 1> m = R2m*phi_psi_min;
+    Eigen::Matrix<complex_t, 4, 1> m = R2m * phi_psi_min;
     result(0) = m(2);
     result(1) = m(3);
-    Eigen::Matrix<complex_t, 4, 1> mT = T2m*phi_psi_min;
-    if (lambda(1)==0.0 && mT(2)==0.0 && mT(3)==0.0)
+    Eigen::Matrix<complex_t, 4, 1> mT = T2m * phi_psi_min;
+    if (lambda(1) == 0.0 && mT(2) == 0.0 && mT(3) == 0.0)
         result(1) = -0.5;
     return result;
 }
@@ -118,136 +118,134 @@ void MatrixRTCoefficients::calculateTRMatrices()
         return;
     }
 
-    if (lambda(0)==0.0) {
-        complex_t ikt = mul_I( m_kt );
+    if (lambda(0) == 0.0) {
+        complex_t ikt = mul_I(m_kt);
         // Lambda1 component contained only in T1m (R1m=0)
         // row 0:
-        T1m(0,0) = (1.0 - m_bz/m_b_mag)/2.0;
-        T1m(0,1) = - m_scatt_matrix(0,1)/2.0/m_b_mag;
+        T1m(0, 0) = (1.0 - m_bz / m_b_mag) / 2.0;
+        T1m(0, 1) = -m_scatt_matrix(0, 1) / 2.0 / m_b_mag;
         // row 1:
-        T1m(1,0) = - m_scatt_matrix(1,0)/2.0/m_b_mag;
-        T1m(1,1) = (1.0 + m_bz/m_b_mag)/2.0;
+        T1m(1, 0) = -m_scatt_matrix(1, 0) / 2.0 / m_b_mag;
+        T1m(1, 1) = (1.0 + m_bz / m_b_mag) / 2.0;
         // row 2:
-        T1m(2,0) = ikt*(1.0 - m_bz/m_b_mag)/2.0;
-        T1m(2,1) = -ikt*m_scatt_matrix(0,1)/2.0/m_b_mag;
-        T1m(2,2) = T1m(0,0);
-        T1m(2,3) = T1m(0,1);
+        T1m(2, 0) = ikt * (1.0 - m_bz / m_b_mag) / 2.0;
+        T1m(2, 1) = -ikt * m_scatt_matrix(0, 1) / 2.0 / m_b_mag;
+        T1m(2, 2) = T1m(0, 0);
+        T1m(2, 3) = T1m(0, 1);
         // row 3:
-        T1m(3,0) = -ikt*m_scatt_matrix(1,0)/2.0/m_b_mag;
-        T1m(3,1) = ikt*(1.0 + m_bz/m_b_mag)/2.0;
-        T1m(3,2) = T1m(1,0);
-        T1m(3,3) = T1m(1,1);
-    }
-    else {
+        T1m(3, 0) = -ikt * m_scatt_matrix(1, 0) / 2.0 / m_b_mag;
+        T1m(3, 1) = ikt * (1.0 + m_bz / m_b_mag) / 2.0;
+        T1m(3, 2) = T1m(1, 0);
+        T1m(3, 3) = T1m(1, 1);
+    } else {
         // T1m:
         // row 0:
-        T1m(0,0) = (1.0 - m_bz/m_b_mag)/4.0;
-        T1m(0,1) = - m_scatt_matrix(0,1)/4.0/m_b_mag;
-        T1m(0,2) = lambda(0)*(m_bz/m_b_mag - 1.0)/4.0;
-        T1m(0,3) = m_scatt_matrix(0,1)*lambda(0)/4.0/m_b_mag;
+        T1m(0, 0) = (1.0 - m_bz / m_b_mag) / 4.0;
+        T1m(0, 1) = -m_scatt_matrix(0, 1) / 4.0 / m_b_mag;
+        T1m(0, 2) = lambda(0) * (m_bz / m_b_mag - 1.0) / 4.0;
+        T1m(0, 3) = m_scatt_matrix(0, 1) * lambda(0) / 4.0 / m_b_mag;
         // row 1:
-        T1m(1,0) = - m_scatt_matrix(1,0)/4.0/m_b_mag;
-        T1m(1,1) = (1.0 + m_bz/m_b_mag)/4.0;
-        T1m(1,2) = m_scatt_matrix(1,0)*lambda(0)/4.0/m_b_mag;
-        T1m(1,3) = - lambda(0)*(m_bz/m_b_mag + 1.0)/4.0;
+        T1m(1, 0) = -m_scatt_matrix(1, 0) / 4.0 / m_b_mag;
+        T1m(1, 1) = (1.0 + m_bz / m_b_mag) / 4.0;
+        T1m(1, 2) = m_scatt_matrix(1, 0) * lambda(0) / 4.0 / m_b_mag;
+        T1m(1, 3) = -lambda(0) * (m_bz / m_b_mag + 1.0) / 4.0;
         // row 2:
-        T1m(2,0) = -(1.0 - m_bz/m_b_mag)/4.0/lambda(0);
-        T1m(2,1) = m_scatt_matrix(0,1)/4.0/m_b_mag/lambda(0);
-        T1m(2,2) = -(m_bz/m_b_mag - 1.0)/4.0;
-        T1m(2,3) = - m_scatt_matrix(0,1)/4.0/m_b_mag;
+        T1m(2, 0) = -(1.0 - m_bz / m_b_mag) / 4.0 / lambda(0);
+        T1m(2, 1) = m_scatt_matrix(0, 1) / 4.0 / m_b_mag / lambda(0);
+        T1m(2, 2) = -(m_bz / m_b_mag - 1.0) / 4.0;
+        T1m(2, 3) = -m_scatt_matrix(0, 1) / 4.0 / m_b_mag;
         // row 3:
-        T1m(3,0) = m_scatt_matrix(1,0)/4.0/m_b_mag/lambda(0);
-        T1m(3,1) = -(1.0 + m_bz/m_b_mag)/4.0/lambda(0);
-        T1m(3,2) = - m_scatt_matrix(1,0)/4.0/m_b_mag;
-        T1m(3,3) = (m_bz/m_b_mag + 1.0)/4.0;
+        T1m(3, 0) = m_scatt_matrix(1, 0) / 4.0 / m_b_mag / lambda(0);
+        T1m(3, 1) = -(1.0 + m_bz / m_b_mag) / 4.0 / lambda(0);
+        T1m(3, 2) = -m_scatt_matrix(1, 0) / 4.0 / m_b_mag;
+        T1m(3, 3) = (m_bz / m_b_mag + 1.0) / 4.0;
 
         // R1m:
         // row 0:
-        R1m(0,0) = T1m(0,0);
-        R1m(0,1) = T1m(0,1);
-        R1m(0,2) = -T1m(0,2);
-        R1m(0,3) = -T1m(0,3);
+        R1m(0, 0) = T1m(0, 0);
+        R1m(0, 1) = T1m(0, 1);
+        R1m(0, 2) = -T1m(0, 2);
+        R1m(0, 3) = -T1m(0, 3);
         // row 1:
-        R1m(1,0) = T1m(1,0);
-        R1m(1,1) = T1m(1,1);
-        R1m(1,2) = -T1m(1,2);
-        R1m(1,3) = -T1m(1,3);
+        R1m(1, 0) = T1m(1, 0);
+        R1m(1, 1) = T1m(1, 1);
+        R1m(1, 2) = -T1m(1, 2);
+        R1m(1, 3) = -T1m(1, 3);
         // row 2:
-        R1m(2,0) = -T1m(2,0);
-        R1m(2,1) = -T1m(2,1);
-        R1m(2,2) = T1m(2,2);
-        R1m(2,3) = T1m(2,3);
+        R1m(2, 0) = -T1m(2, 0);
+        R1m(2, 1) = -T1m(2, 1);
+        R1m(2, 2) = T1m(2, 2);
+        R1m(2, 3) = T1m(2, 3);
         // row 3:
-        R1m(3,0) = -T1m(3,0);
-        R1m(3,1) = -T1m(3,1);
-        R1m(3,2) = T1m(3,2);
-        R1m(3,3) = T1m(3,3);
+        R1m(3, 0) = -T1m(3, 0);
+        R1m(3, 1) = -T1m(3, 1);
+        R1m(3, 2) = T1m(3, 2);
+        R1m(3, 3) = T1m(3, 3);
     }
 
-    if (lambda(1)==0.0) {
+    if (lambda(1) == 0.0) {
         complex_t ikt = mul_I(m_kt);
         // Lambda2 component contained only in T2m (R2m=0)
         // row 0:
-        T2m(0,0) = (1.0 + m_bz/m_b_mag)/2.0;
-        T2m(0,1) = m_scatt_matrix(0,1)/2.0/m_b_mag;
+        T2m(0, 0) = (1.0 + m_bz / m_b_mag) / 2.0;
+        T2m(0, 1) = m_scatt_matrix(0, 1) / 2.0 / m_b_mag;
         // row 1:
-        T2m(1,0) = m_scatt_matrix(1,0)/2.0/m_b_mag;
-        T2m(1,1) = (1.0 - m_bz/m_b_mag)/2.0;
+        T2m(1, 0) = m_scatt_matrix(1, 0) / 2.0 / m_b_mag;
+        T2m(1, 1) = (1.0 - m_bz / m_b_mag) / 2.0;
         // row 2:
-        T2m(2,0) = ikt*(1.0 + m_bz/m_b_mag)/2.0;
-        T2m(2,1) = ikt*m_scatt_matrix(0,1)/2.0/m_b_mag;
-        T2m(2,2) = T2m(0,0);
-        T2m(2,3) = T2m(0,1);
+        T2m(2, 0) = ikt * (1.0 + m_bz / m_b_mag) / 2.0;
+        T2m(2, 1) = ikt * m_scatt_matrix(0, 1) / 2.0 / m_b_mag;
+        T2m(2, 2) = T2m(0, 0);
+        T2m(2, 3) = T2m(0, 1);
         // row 3:
-        T2m(3,0) = ikt*m_scatt_matrix(1,0)/2.0/m_b_mag;
-        T2m(3,1) = ikt*(1.0 - m_bz/m_b_mag)/2.0;
-        T2m(3,2) = T2m(1,0);
-        T2m(3,3) = T2m(1,1);
-    }
-    else {
+        T2m(3, 0) = ikt * m_scatt_matrix(1, 0) / 2.0 / m_b_mag;
+        T2m(3, 1) = ikt * (1.0 - m_bz / m_b_mag) / 2.0;
+        T2m(3, 2) = T2m(1, 0);
+        T2m(3, 3) = T2m(1, 1);
+    } else {
         // T2m:
         // row 0:
-        T2m(0,0) = (1.0 + m_bz/m_b_mag)/4.0;
-        T2m(0,1) = m_scatt_matrix(0,1)/4.0/m_b_mag;
-        T2m(0,2) = - lambda(1)*(m_bz/m_b_mag + 1.0)/4.0;
-        T2m(0,3) = - m_scatt_matrix(0,1)*lambda(1)/4.0/m_b_mag;
+        T2m(0, 0) = (1.0 + m_bz / m_b_mag) / 4.0;
+        T2m(0, 1) = m_scatt_matrix(0, 1) / 4.0 / m_b_mag;
+        T2m(0, 2) = -lambda(1) * (m_bz / m_b_mag + 1.0) / 4.0;
+        T2m(0, 3) = -m_scatt_matrix(0, 1) * lambda(1) / 4.0 / m_b_mag;
         // row 1:
-        T2m(1,0) = m_scatt_matrix(1,0)/4.0/m_b_mag;
-        T2m(1,1) = (1.0 - m_bz/m_b_mag)/4.0;
-        T2m(1,2) = - m_scatt_matrix(1,0)*lambda(1)/4.0/m_b_mag;
-        T2m(1,3) = lambda(1)*(m_bz/m_b_mag - 1.0)/4.0;
+        T2m(1, 0) = m_scatt_matrix(1, 0) / 4.0 / m_b_mag;
+        T2m(1, 1) = (1.0 - m_bz / m_b_mag) / 4.0;
+        T2m(1, 2) = -m_scatt_matrix(1, 0) * lambda(1) / 4.0 / m_b_mag;
+        T2m(1, 3) = lambda(1) * (m_bz / m_b_mag - 1.0) / 4.0;
         // row 2:
-        T2m(2,0) = -(1.0 + m_bz/m_b_mag)/4.0/lambda(1);
-        T2m(2,1) = - m_scatt_matrix(0,1)/4.0/m_b_mag/lambda(1);
-        T2m(2,2) = (m_bz/m_b_mag + 1.0)/4.0;
-        T2m(2,3) = m_scatt_matrix(0,1)/4.0/m_b_mag;
+        T2m(2, 0) = -(1.0 + m_bz / m_b_mag) / 4.0 / lambda(1);
+        T2m(2, 1) = -m_scatt_matrix(0, 1) / 4.0 / m_b_mag / lambda(1);
+        T2m(2, 2) = (m_bz / m_b_mag + 1.0) / 4.0;
+        T2m(2, 3) = m_scatt_matrix(0, 1) / 4.0 / m_b_mag;
         // row 3:
-        T2m(3,0) = - m_scatt_matrix(1,0)/4.0/m_b_mag/lambda(1);
-        T2m(3,1) = -(1.0 - m_bz/m_b_mag)/4.0/lambda(1);
-        T2m(3,2) = m_scatt_matrix(1,0)/4.0/m_b_mag;
-        T2m(3,3) = (1.0 - m_bz/m_b_mag)/4.0;
+        T2m(3, 0) = -m_scatt_matrix(1, 0) / 4.0 / m_b_mag / lambda(1);
+        T2m(3, 1) = -(1.0 - m_bz / m_b_mag) / 4.0 / lambda(1);
+        T2m(3, 2) = m_scatt_matrix(1, 0) / 4.0 / m_b_mag;
+        T2m(3, 3) = (1.0 - m_bz / m_b_mag) / 4.0;
 
         // R2m:
         // row 0:
-        R2m(0,0) = T2m(0,0);
-        R2m(0,1) = T2m(0,1);
-        R2m(0,2) = -T2m(0,2);
-        R2m(0,3) = -T2m(0,3);
+        R2m(0, 0) = T2m(0, 0);
+        R2m(0, 1) = T2m(0, 1);
+        R2m(0, 2) = -T2m(0, 2);
+        R2m(0, 3) = -T2m(0, 3);
         // row 1:
-        R2m(1,0) = T2m(1,0);
-        R2m(1,1) = T2m(1,1);
-        R2m(1,2) = -T2m(1,2);
-        R2m(1,3) = -T2m(1,3);
+        R2m(1, 0) = T2m(1, 0);
+        R2m(1, 1) = T2m(1, 1);
+        R2m(1, 2) = -T2m(1, 2);
+        R2m(1, 3) = -T2m(1, 3);
         // row 2:
-        R2m(2,0) = -T2m(2,0);
-        R2m(2,1) = -T2m(2,1);
-        R2m(2,2) = T2m(2,2);
-        R2m(2,3) = T2m(2,3);
+        R2m(2, 0) = -T2m(2, 0);
+        R2m(2, 1) = -T2m(2, 1);
+        R2m(2, 2) = T2m(2, 2);
+        R2m(2, 3) = T2m(2, 3);
         // row 3:
-        R2m(3,0) = -T2m(3,0);
-        R2m(3,1) = -T2m(3,1);
-        R2m(3,2) = T2m(3,2);
-        R2m(3,3) = T2m(3,3);
+        R2m(3, 0) = -T2m(3, 0);
+        R2m(3, 1) = -T2m(3, 1);
+        R2m(3, 2) = T2m(3, 2);
+        R2m(3, 3) = T2m(3, 3);
     }
 }
 
@@ -258,42 +256,42 @@ void MatrixRTCoefficients::calculateTRWithoutMagnetization()
     T2m.setZero();
     R2m.setZero();
 
-    if (m_a==0.0) {
+    if (m_a == 0.0) {
         // Spin down component contained only in T1 (R1=0)
-        T1m(1,1) = 1.0;
-        T1m(3,1) = mul_I(m_kt);
-        T1m(3,3) = 1.0;
+        T1m(1, 1) = 1.0;
+        T1m(3, 1) = mul_I(m_kt);
+        T1m(3, 3) = 1.0;
 
         // Spin up component contained only in T2 (R2=0)
-        T2m(0,0) = 1.0;
-        T2m(2,0) = mul_I(m_kt);
-        T2m(2,2) = 1.0;
+        T2m(0, 0) = 1.0;
+        T2m(2, 0) = mul_I(m_kt);
+        T2m(2, 2) = 1.0;
         return;
     }
 
     // T1m:
-    T1m(1,1) = 0.5;
-    T1m(1,3) = -std::sqrt(m_a)/2.0;
-    T1m(3,1) = -1.0/(2.0*std::sqrt(m_a));
-    T1m(3,3) = 0.5;
+    T1m(1, 1) = 0.5;
+    T1m(1, 3) = -std::sqrt(m_a) / 2.0;
+    T1m(3, 1) = -1.0 / (2.0 * std::sqrt(m_a));
+    T1m(3, 3) = 0.5;
 
     // R1m:
-    R1m(1,1) = 0.5;
-    R1m(1,3) = std::sqrt(m_a)/2.0;
-    R1m(3,1) = 1.0/(2.0*std::sqrt(m_a));
-    R1m(3,3) = 0.5;
+    R1m(1, 1) = 0.5;
+    R1m(1, 3) = std::sqrt(m_a) / 2.0;
+    R1m(3, 1) = 1.0 / (2.0 * std::sqrt(m_a));
+    R1m(3, 3) = 0.5;
 
     // T2m:
-    T2m(0,0) = 0.5;
-    T2m(0,2) = -std::sqrt(m_a)/2.0;
-    T2m(2,0) = -1.0/(2.0*std::sqrt(m_a));
-    T2m(2,2) = 0.5;
+    T2m(0, 0) = 0.5;
+    T2m(0, 2) = -std::sqrt(m_a) / 2.0;
+    T2m(2, 0) = -1.0 / (2.0 * std::sqrt(m_a));
+    T2m(2, 2) = 0.5;
 
     // R2m:
-    R2m(0,0) = 0.5;
-    R2m(0,2) = std::sqrt(m_a)/2.0;
-    R2m(2,0) = 1.0/(2.0*std::sqrt(m_a));
-    R2m(2,2) = 0.5;
+    R2m(0, 0) = 0.5;
+    R2m(0, 2) = std::sqrt(m_a) / 2.0;
+    R2m(2, 0) = 1.0 / (2.0 * std::sqrt(m_a));
+    R2m(2, 2) = 0.5;
 }
 
 void MatrixRTCoefficients::initializeBottomLayerPhiPsi()
@@ -304,18 +302,14 @@ void MatrixRTCoefficients::initializeBottomLayerPhiPsi()
         return;
     }
     // First basis vector that has no upward going wave amplitude
-    phi_psi_min(0) = m_scatt_matrix(0,1) * ( lambda(0)-lambda(1) ) /
-            2.0/m_b_mag;
-    phi_psi_min(1) = ( m_bz  * (lambda(1) - lambda(0)) / m_b_mag -
-            lambda(1) - lambda(0) )/2.0;
+    phi_psi_min(0) = m_scatt_matrix(0, 1) * (lambda(0) - lambda(1)) / 2.0 / m_b_mag;
+    phi_psi_min(1) = (m_bz * (lambda(1) - lambda(0)) / m_b_mag - lambda(1) - lambda(0)) / 2.0;
     phi_psi_min(2) = 0.0;
     phi_psi_min(3) = 1.0;
 
     // Second basis vector that has no upward going wave amplitude
-    phi_psi_plus(0) = - (m_scatt_matrix(0,0) + lambda(0) * lambda(1) ) /
-            ( lambda(0) + lambda(1) );
-    phi_psi_plus(1) = m_scatt_matrix(1,0) * ( lambda(0) - lambda(1) ) /
-            2.0/m_b_mag;
+    phi_psi_plus(0) = -(m_scatt_matrix(0, 0) + lambda(0) * lambda(1)) / (lambda(0) + lambda(1));
+    phi_psi_plus(1) = m_scatt_matrix(1, 0) * (lambda(0) - lambda(1)) / 2.0 / m_b_mag;
     phi_psi_plus(2) = 1.0;
     phi_psi_plus(3) = 0.0;
 }
diff --git a/Core/Multilayer/MatrixRTCoefficients.h b/Core/Multilayer/MatrixRTCoefficients.h
index 14e49127978..45416d12bc9 100644
--- a/Core/Multilayer/MatrixRTCoefficients.h
+++ b/Core/Multilayer/MatrixRTCoefficients.h
@@ -47,24 +47,24 @@ public:
     void initializeBottomLayerPhiPsi();
 
     // NOTE: exceptionally, this class has member variables without prefix m_
-    Eigen::Vector2cd kz; //!< z-part of the two wavevector eigenmodes
-    Eigen::Vector2cd lambda; //!< positive eigenvalues of transfer matrix
-    Eigen::Vector4cd phi_psi_plus; //!< boundary values for up-polarization
-    Eigen::Vector4cd phi_psi_min; //!< boundary values for down-polarization
-    Eigen::Matrix4cd T1m; //!< matrix selecting the transmitted part of
-                          //!< the first eigenmode
-    Eigen::Matrix4cd R1m; //!< matrix selecting the reflected part of
-                          //!< the first eigenmode
-    Eigen::Matrix4cd T2m; //!< matrix selecting the transmitted part of
-                          //!< the second eigenmode
-    Eigen::Matrix4cd R2m; //!< matrix selecting the reflected part of
-                          //!< the second eigenmode
+    Eigen::Vector2cd kz;             //!< z-part of the two wavevector eigenmodes
+    Eigen::Vector2cd lambda;         //!< positive eigenvalues of transfer matrix
+    Eigen::Vector4cd phi_psi_plus;   //!< boundary values for up-polarization
+    Eigen::Vector4cd phi_psi_min;    //!< boundary values for down-polarization
+    Eigen::Matrix4cd T1m;            //!< matrix selecting the transmitted part of
+                                     //!< the first eigenmode
+    Eigen::Matrix4cd R1m;            //!< matrix selecting the reflected part of
+                                     //!< the first eigenmode
+    Eigen::Matrix4cd T2m;            //!< matrix selecting the transmitted part of
+                                     //!< the second eigenmode
+    Eigen::Matrix4cd R2m;            //!< matrix selecting the reflected part of
+                                     //!< the second eigenmode
     Eigen::Matrix2cd m_scatt_matrix; //!< scattering matrix
-    complex_t m_a; //!< polarization independent part of scattering matrix
-    complex_t m_b_mag; //!< magnitude of magnetic interaction term
-    complex_t m_bz; //!< z-part of magnetic interaction term
-    double m_kt; //!< wavevector length times thickness of layer for use when
-                 //!< lambda=0
+    complex_t m_a;                   //!< polarization independent part of scattering matrix
+    complex_t m_b_mag;               //!< magnitude of magnetic interaction term
+    complex_t m_bz;                  //!< z-part of magnetic interaction term
+    double m_kt;                     //!< wavevector length times thickness of layer for use when
+                                     //!< lambda=0
 };
 
 #endif // MATRIXRTCOEFFICIENTS_H
diff --git a/Core/Multilayer/MatrixRTCoefficients_v2.cpp b/Core/Multilayer/MatrixRTCoefficients_v2.cpp
index 568539393db..fbbd28c21a4 100644
--- a/Core/Multilayer/MatrixRTCoefficients_v2.cpp
+++ b/Core/Multilayer/MatrixRTCoefficients_v2.cpp
@@ -14,18 +14,17 @@
 
 #include "MatrixRTCoefficients_v2.h"
 
-namespace {
+namespace
+{
 Eigen::Vector2cd waveVector(const Eigen::Matrix4cd& frob_matrix,
                             const Eigen::Vector4cd& boundary_cond);
 
 constexpr complex_t I = complex_t(0.0, 1.0);
-}
+} // namespace
 
 MatrixRTCoefficients_v2::MatrixRTCoefficients_v2(double kz_sign, Eigen::Vector2cd eigenvalues,
-                                             kvector_t b)
-    : m_kz_sign(kz_sign)
-    , m_lambda(std::move(eigenvalues))
-    , m_b(std::move(b))
+                                                 kvector_t b)
+    : m_kz_sign(kz_sign), m_lambda(std::move(eigenvalues)), m_b(std::move(b))
 {
 }
 
@@ -103,11 +102,12 @@ Eigen::Vector2cd MatrixRTCoefficients_v2::getKz() const
     return -I * m_kz_sign * m_lambda;
 }
 
-namespace {
+namespace
+{
 Eigen::Vector2cd waveVector(const Eigen::Matrix4cd& frob_matrix,
                             const Eigen::Vector4cd& boundary_cond)
 {
     Eigen::Matrix<complex_t, 4, 1> m = frob_matrix * boundary_cond;
     return {m(2), m(3)};
 }
-}
+} // namespace
diff --git a/Core/Multilayer/MatrixRTCoefficients_v2.h b/Core/Multilayer/MatrixRTCoefficients_v2.h
index 76f723b758c..19b08e38fc3 100644
--- a/Core/Multilayer/MatrixRTCoefficients_v2.h
+++ b/Core/Multilayer/MatrixRTCoefficients_v2.h
@@ -53,7 +53,7 @@ private:
     kvector_t m_b; //!< normalized magnetic field impact (with correction for external mag. field)
 
     Eigen::Vector4cd m_w_plus; //!< boundary values for up-polarization
-    Eigen::Vector4cd m_w_min; //!< boundary values for down-polarization
+    Eigen::Vector4cd m_w_min;  //!< boundary values for down-polarization
 
     Eigen::Matrix4cd T1; //!< matrix selecting the transmitted part of
                          //!< the first eigenmode
diff --git a/Core/Multilayer/MultiLayer.cpp b/Core/Multilayer/MultiLayer.cpp
index 763de34a1ea..5f912ad4e65 100644
--- a/Core/Multilayer/MultiLayer.cpp
+++ b/Core/Multilayer/MultiLayer.cpp
@@ -81,7 +81,6 @@ void MultiLayer::addLayerWithTopRoughness(const Layer& layer, const LayerRoughne
             throw std::runtime_error(
                 "Invalid call to MultiLayer::addLayer(): the semi-infinite top layer "
                 "cannot have roughness.");
-
     }
     addAndRegisterLayer(p_new_layer);
 }
diff --git a/Core/Multilayer/MultiLayer.h b/Core/Multilayer/MultiLayer.h
index 145286aee09..a05ae12a8b5 100644
--- a/Core/Multilayer/MultiLayer.h
+++ b/Core/Multilayer/MultiLayer.h
@@ -16,10 +16,10 @@
 #define MULTILAYER_H
 
 #include "ISample.h"
+#include "RoughnessModels.h"
 #include "SafePointerVector.h"
 #include "Vectors3D.h"
 #include "ZLimits.h"
-#include "RoughnessModels.h"
 
 #include <functional>
 
diff --git a/Core/Multilayer/MultiLayerFuncs.cpp b/Core/Multilayer/MultiLayerFuncs.cpp
index a00bb37f02e..482661d7bc5 100644
--- a/Core/Multilayer/MultiLayerFuncs.cpp
+++ b/Core/Multilayer/MultiLayerFuncs.cpp
@@ -28,7 +28,7 @@ std::vector<complex_t> MaterialProfile(const MultiLayer& multilayer, int n_point
     return helper.calculateProfile(z_values);
 }
 
-std::pair<double, double> DefaultMaterialProfileLimits(const MultiLayer &multilayer)
+std::pair<double, double> DefaultMaterialProfileLimits(const MultiLayer& multilayer)
 {
     SimulationOptions options;
     options.setUseAvgMaterials(true);
diff --git a/Core/Multilayer/MultiLayerFuncs.h b/Core/Multilayer/MultiLayerFuncs.h
index eb411695bf7..1c3e24a73e8 100644
--- a/Core/Multilayer/MultiLayerFuncs.h
+++ b/Core/Multilayer/MultiLayerFuncs.h
@@ -31,7 +31,6 @@ BA_CORE_API_ std::vector<complex_t> MaterialProfile(const MultiLayer& multilayer
 //! Get default z limits for generating a material profile
 BA_CORE_API_ std::pair<double, double> DefaultMaterialProfileLimits(const MultiLayer& multilayer);
 
-
 //! Generate z values (equidistant) for use in MaterialProfile
 BA_CORE_API_ std::vector<double> GenerateZValues(int n_points, double z_min, double z_max);
 
diff --git a/Core/Multilayer/RoughnessModels.cpp b/Core/Multilayer/RoughnessModels.cpp
index 0f011d54bce..ddb46ed2511 100644
--- a/Core/Multilayer/RoughnessModels.cpp
+++ b/Core/Multilayer/RoughnessModels.cpp
@@ -16,11 +16,12 @@
 
 #include <map>
 
-namespace {
+namespace
+{
 const std::map<RoughnessModel, std::string> roughnessModelNames = {
     {RoughnessModel::DEFAULT, "RoughnessModel::DEFAULT"},
     {RoughnessModel::TANH, "RoughnessModel::TANH"},
-    {RoughnessModel::NEVOT_CROCE, "RoughnessModel::NEVOT_CROCE"} };
+    {RoughnessModel::NEVOT_CROCE, "RoughnessModel::NEVOT_CROCE"}};
 }
 
 std::string RoughnessModelWrap::roughnessModelName(RoughnessModel model)
@@ -30,5 +31,3 @@ std::string RoughnessModelWrap::roughnessModelName(RoughnessModel model)
         return iter->second;
     return "Invalid roughness model";
 }
-
-
diff --git a/Core/Multilayer/RoughnessModels.h b/Core/Multilayer/RoughnessModels.h
index ecb522d0bbf..53ac4811b00 100644
--- a/Core/Multilayer/RoughnessModels.h
+++ b/Core/Multilayer/RoughnessModels.h
@@ -12,7 +12,6 @@
 //
 // ************************************************************************** //
 
-
 #ifndef ROUGHNESSMODELS_H
 #define ROUGHNESSMODELS_H
 
@@ -31,6 +30,4 @@ struct BA_CORE_API_ RoughnessModelWrap {
 };
 typedef RoughnessModelWrap::RoughnessModel RoughnessModel;
 
-
-
 #endif // ROUGHNESSMODELS_H
diff --git a/Core/Multilayer/SSCAHelper.h b/Core/Multilayer/SSCAHelper.h
index 69729544340..e505d794c87 100644
--- a/Core/Multilayer/SSCAHelper.h
+++ b/Core/Multilayer/SSCAHelper.h
@@ -34,12 +34,13 @@ public:
 
     void init(const std::vector<FormFactorCoherentSum>& ff_wrappers);
 
-    complex_t getCharacteristicSizeCoupling(double qp,
-            const std::vector<FormFactorCoherentSum>& ff_wrappers) const;
+    complex_t
+    getCharacteristicSizeCoupling(double qp,
+                                  const std::vector<FormFactorCoherentSum>& ff_wrappers) const;
     complex_t getCharacteristicDistribution(double qp, const IInterferenceFunction* p_iff) const;
     complex_t calculatePositionOffsetPhase(double qp, double radial_extension) const;
     complex_t getMeanFormfactorNorm(double qp, const std::vector<complex_t>& precomputed_ff,
-            const std::vector<FormFactorCoherentSum>& ff_wrappers) const;
+                                    const std::vector<FormFactorCoherentSum>& ff_wrappers) const;
     void getMeanFormfactors(double qp, Eigen::Matrix2cd& ff_orig, Eigen::Matrix2cd& ff_conj,
                             const InterferenceFunctionUtils::matrixFFVector_t& precomputed_ff,
                             const std::vector<FormFactorCoherentSum>& ff_wrappers) const;
diff --git a/Core/Multilayer/SSCApproximationStrategy.cpp b/Core/Multilayer/SSCApproximationStrategy.cpp
index 2a50c08c21b..17309c0b0c8 100644
--- a/Core/Multilayer/SSCApproximationStrategy.cpp
+++ b/Core/Multilayer/SSCApproximationStrategy.cpp
@@ -18,14 +18,14 @@
 #include "InterferenceFunctionUtils.h"
 #include "SimulationElement.h"
 
-using InterferenceFunctionUtils::PrecomputeScalarFormFactors;
 using InterferenceFunctionUtils::PrecomputePolarizedFormFactors;
+using InterferenceFunctionUtils::PrecomputeScalarFormFactors;
 
 SSCApproximationStrategy::SSCApproximationStrategy(SimulationOptions sim_params, double kappa,
-                                                     bool polarized)
-    : IInterferenceFunctionStrategy(sim_params, polarized)
-    , m_helper(kappa)
-{}
+                                                   bool polarized)
+    : IInterferenceFunctionStrategy(sim_params, polarized), m_helper(kappa)
+{
+}
 
 void SSCApproximationStrategy::strategy_specific_post_init()
 {
@@ -45,8 +45,8 @@ double SSCApproximationStrategy::scalarCalculation(const SimulationElement& sim_
         double fraction = m_formfactor_wrappers[i].relativeAbundance();
         diffuse_intensity += fraction * std::norm(ff);
     }
-    complex_t mean_ff_norm  = m_helper.getMeanFormfactorNorm(qp, precomputed_ff,
-                                                             m_formfactor_wrappers);
+    complex_t mean_ff_norm =
+        m_helper.getMeanFormfactorNorm(qp, precomputed_ff, m_formfactor_wrappers);
     complex_t p2kappa = m_helper.getCharacteristicSizeCoupling(qp, m_formfactor_wrappers);
     complex_t omega = m_helper.getCharacteristicDistribution(qp, mP_iff.get());
     double iff = 2.0 * (mean_ff_norm * omega / (1.0 - p2kappa * omega)).real();
@@ -70,10 +70,9 @@ double SSCApproximationStrategy::polarizedCalculation(const SimulationElement& s
     m_helper.getMeanFormfactors(qp, mff_orig, mff_conj, precomputed_ff, m_formfactor_wrappers);
     complex_t p2kappa = m_helper.getCharacteristicSizeCoupling(qp, m_formfactor_wrappers);
     complex_t omega = m_helper.getCharacteristicDistribution(qp, mP_iff.get());
-    Eigen::Matrix2cd interference_matrix
-        = (2.0 * omega / (1.0 - p2kappa * omega))
-        * polarization_handler.getAnalyzerOperator() * mff_orig
-        * polarization_handler.getPolarization() * mff_conj;
+    Eigen::Matrix2cd interference_matrix = (2.0 * omega / (1.0 - p2kappa * omega))
+                                           * polarization_handler.getAnalyzerOperator() * mff_orig
+                                           * polarization_handler.getPolarization() * mff_conj;
     Eigen::Matrix2cd diffuse_matrix2 = polarization_handler.getAnalyzerOperator() * diffuse_matrix;
     double interference_trace = std::abs(interference_matrix.trace());
     double diffuse_trace = std::abs(diffuse_matrix2.trace());
diff --git a/Core/Multilayer/ScalarFresnelMap.cpp b/Core/Multilayer/ScalarFresnelMap.cpp
index fa7aa7df5d9..460246b7bbd 100644
--- a/Core/Multilayer/ScalarFresnelMap.cpp
+++ b/Core/Multilayer/ScalarFresnelMap.cpp
@@ -27,7 +27,8 @@ ScalarFresnelMap::ScalarFresnelMap(std::unique_ptr<ISpecularStrategy> strategy)
 ScalarFresnelMap::~ScalarFresnelMap() = default;
 
 //! Returns hash value of a pair of doubles, computed by exclusive-or of the component hash values.
-size_t ScalarFresnelMap::Hash2Doubles::operator()(const std::pair<double, double>& doubles) const noexcept
+size_t
+ScalarFresnelMap::Hash2Doubles::operator()(const std::pair<double, double>& doubles) const noexcept
 {
     return std::hash<double>{}(doubles.first) ^ std::hash<double>{}(doubles.second);
 }
diff --git a/Core/Multilayer/ScalarFresnelMap.h b/Core/Multilayer/ScalarFresnelMap.h
index f1e582396b1..6011c953269 100644
--- a/Core/Multilayer/ScalarFresnelMap.h
+++ b/Core/Multilayer/ScalarFresnelMap.h
@@ -16,8 +16,8 @@
 #define SCALARFRESNELMAP_H
 
 #include "IFresnelMap.h"
-#include "ScalarRTCoefficients.h"
 #include "ISpecularStrategy.h"
+#include "ScalarRTCoefficients.h"
 #include <cstddef>
 #include <unordered_map>
 #include <utility>
@@ -53,8 +53,8 @@ private:
     std::unique_ptr<const ILayerRTCoefficients> getCoefficients(const kvector_t& kvec,
                                                                 size_t layer_index) const override;
     const ISpecularStrategy::coeffs_t& getCoefficientsFromCache(kvector_t kvec) const;
-    mutable std::unordered_map<std::pair<double, double>, ISpecularStrategy::coeffs_t,
-                               Hash2Doubles> m_cache;
+    mutable std::unordered_map<std::pair<double, double>, ISpecularStrategy::coeffs_t, Hash2Doubles>
+        m_cache;
 };
 
 #endif // SCALARFRESNELMAP_H
diff --git a/Core/Multilayer/ScalarRTCoefficients.h b/Core/Multilayer/ScalarRTCoefficients.h
index ff5e463bfc0..64a5e9161dc 100644
--- a/Core/Multilayer/ScalarRTCoefficients.h
+++ b/Core/Multilayer/ScalarRTCoefficients.h
@@ -15,9 +15,9 @@
 #ifndef SCALARRTCOEFFICIENTS_H
 #define SCALARRTCOEFFICIENTS_H
 
-#include "ILayerRTCoefficients.h"
 #include "Complex.h"
 #include "EigenCore.h"
+#include "ILayerRTCoefficients.h"
 
 //! Specular reflection and transmission coefficients in a layer in case
 //! of scalar interactions between the layers and the scattered particle.
@@ -70,8 +70,7 @@ private:
 // implementation
 // ************************************************************************** //
 
-inline ScalarRTCoefficients::ScalarRTCoefficients()
-    : kz(0)
+inline ScalarRTCoefficients::ScalarRTCoefficients() : kz(0)
 {
     m_plus(0) = 1.0;
     m_plus(1) = 0.0;
@@ -127,7 +126,7 @@ inline Eigen::Vector2cd ScalarRTCoefficients::R2min() const
 
 inline Eigen::Vector2cd ScalarRTCoefficients::getKz() const
 {
-    return (m_plus+m_min) * kz;
+    return (m_plus + m_min) * kz;
 }
 
 inline complex_t ScalarRTCoefficients::getScalarR() const
diff --git a/Core/Multilayer/SpecularMagneticOldStrategy.cpp b/Core/Multilayer/SpecularMagneticOldStrategy.cpp
index d4c437d7892..96dd06a0864 100644
--- a/Core/Multilayer/SpecularMagneticOldStrategy.cpp
+++ b/Core/Multilayer/SpecularMagneticOldStrategy.cpp
@@ -22,39 +22,39 @@
 
 namespace
 {
-void CalculateEigenvalues(const std::vector<Slice> &slices, const kvector_t k,
+void CalculateEigenvalues(const std::vector<Slice>& slices, const kvector_t k,
                           std::vector<MatrixRTCoefficients>& coeff);
 void CalculateTransferAndBoundary(const std::vector<Slice>& slices,
                                   std::vector<MatrixRTCoefficients>& coeff);
 void SetForNoTransmission(std::vector<MatrixRTCoefficients>& coeff);
 complex_t GetImExponential(complex_t exponent);
 const complex_t I(0, 1);
-}
+} // namespace
 
-ISpecularStrategy::coeffs_t
-SpecularMagneticOldStrategy::Execute(const std::vector<Slice>& slices,
-                                     const kvector_t& k) const
+ISpecularStrategy::coeffs_t SpecularMagneticOldStrategy::Execute(const std::vector<Slice>& slices,
+                                                                 const kvector_t& k) const
 {
     std::vector<MatrixRTCoefficients> result(slices.size());
     CalculateEigenvalues(slices, k, result);
     CalculateTransferAndBoundary(slices, result);
 
     coeffs_t resultConvert;
-    for(auto& coeff : result)
-        resultConvert.push_back( std::make_unique<MatrixRTCoefficients>(coeff));
+    for (auto& coeff : result)
+        resultConvert.push_back(std::make_unique<MatrixRTCoefficients>(coeff));
 
     return resultConvert;
 }
 
 ISpecularStrategy::coeffs_t
-SpecularMagneticOldStrategy::Execute(const std::vector<Slice>& slices, const std::vector<complex_t>& k) const
+SpecularMagneticOldStrategy::Execute(const std::vector<Slice>& slices,
+                                     const std::vector<complex_t>& k) const
 {
     throw std::runtime_error("Not implemented");
 }
 
-
-namespace {
-void CalculateEigenvalues(const std::vector<Slice> &slices, const kvector_t k,
+namespace
+{
+void CalculateEigenvalues(const std::vector<Slice>& slices, const kvector_t k,
                           std::vector<MatrixRTCoefficients>& coeff)
 {
     double mag_k = k.mag();
@@ -83,7 +83,7 @@ void CalculateEigenvalues(const std::vector<Slice> &slices, const kvector_t k,
 }
 
 // todo: avoid overflows (see SpecularMatrix.cpp)
-void CalculateTransferAndBoundary(const std::vector<Slice> &slices,
+void CalculateTransferAndBoundary(const std::vector<Slice>& slices,
                                   std::vector<MatrixRTCoefficients>& coeff)
 {
     size_t N = coeff.size();
@@ -162,5 +162,4 @@ complex_t GetImExponential(complex_t exponent)
         return 0.0;
     return std::exp(I * exponent);
 }
-}  // unnamed namespace
-
+} // unnamed namespace
diff --git a/Core/Multilayer/SpecularMagneticOldStrategy.h b/Core/Multilayer/SpecularMagneticOldStrategy.h
index a252e28fb57..6285df220d9 100644
--- a/Core/Multilayer/SpecularMagneticOldStrategy.h
+++ b/Core/Multilayer/SpecularMagneticOldStrategy.h
@@ -15,11 +15,11 @@
 #ifndef SPECULARMAGNETICOLDSTRATEGY_H
 #define SPECULARMAGNETICOLDSTRATEGY_H
 
-#include "MatrixRTCoefficients.h"
 #include "ISpecularStrategy.h"
+#include "MatrixRTCoefficients.h"
 #include "Vectors3D.h"
-#include <vector>
 #include <memory>
+#include <vector>
 
 class Slice;
 
@@ -32,11 +32,9 @@ class BA_CORE_API_ SpecularMagneticOldStrategy : public ISpecularStrategy
 public:
     //! Computes refraction angle reflection/transmission coefficients
     //! for given sliced multilayer and wavevector k
-    coeffs_t
-    Execute(const std::vector<Slice>& slices, const kvector_t& k) const;
+    coeffs_t Execute(const std::vector<Slice>& slices, const kvector_t& k) const;
 
-    coeffs_t
-    Execute(const std::vector<Slice>& slices, const std::vector<complex_t>& kz) const;
+    coeffs_t Execute(const std::vector<Slice>& slices, const std::vector<complex_t>& kz) const;
 
 }; // class SpecularMagneticOldStrategy
 
diff --git a/Core/Multilayer/SpecularMagneticStrategy.cpp b/Core/Multilayer/SpecularMagneticStrategy.cpp
index 44aaf940f8b..84b3ca52336 100644
--- a/Core/Multilayer/SpecularMagneticStrategy.cpp
+++ b/Core/Multilayer/SpecularMagneticStrategy.cpp
@@ -17,7 +17,8 @@
 #include "PhysicalConstants.h"
 #include "Slice.h"
 
-namespace {
+namespace
+{
 kvector_t magneticImpact(kvector_t B_field);
 Eigen::Vector2cd eigenvalues(complex_t kz, double b_mag);
 Eigen::Vector2cd checkForUnderflow(const Eigen::Vector2cd& eigenvs);
@@ -27,30 +28,31 @@ complex_t GetImExponential(complex_t exponent);
 constexpr double magnetic_prefactor = PhysConsts::m_n * PhysConsts::g_factor_n * PhysConsts::mu_N
                                       / PhysConsts::h_bar / PhysConsts::h_bar * 1e-18;
 constexpr complex_t I(0.0, 1.0);
-}
+} // namespace
 
-ISpecularStrategy::coeffs_t
-SpecularMagneticStrategy::Execute(const std::vector<Slice>& slices, const kvector_t& k) const
+ISpecularStrategy::coeffs_t SpecularMagneticStrategy::Execute(const std::vector<Slice>& slices,
+                                                              const kvector_t& k) const
 {
     return Execute(slices, KzComputation::computeReducedKz(slices, k));
 }
 
 ISpecularStrategy::coeffs_t
-SpecularMagneticStrategy::Execute(const std::vector<Slice>& slices, const std::vector<complex_t>& kz) const
+SpecularMagneticStrategy::Execute(const std::vector<Slice>& slices,
+                                  const std::vector<complex_t>& kz) const
 {
-    if(slices.size() != kz.size())
+    if (slices.size() != kz.size())
         throw std::runtime_error("Number of slices does not match the size of the kz-vector");
 
     ISpecularStrategy::coeffs_t result;
-    for(auto& coeff : computeTR(slices, kz))
-        result.push_back( std::make_unique<MatrixRTCoefficients_v2>(coeff) );
+    for (auto& coeff : computeTR(slices, kz))
+        result.push_back(std::make_unique<MatrixRTCoefficients_v2>(coeff));
 
     return result;
 }
 
-
-std::vector<MatrixRTCoefficients_v2> SpecularMagneticStrategy::computeTR(const std::vector<Slice>& slices,
-                                                              const std::vector<complex_t>& kzs)
+std::vector<MatrixRTCoefficients_v2>
+SpecularMagneticStrategy::computeTR(const std::vector<Slice>& slices,
+                                    const std::vector<complex_t>& kzs)
 {
     if (slices.size() != kzs.size())
         throw std::runtime_error(
@@ -98,30 +100,22 @@ void SpecularMagneticStrategy::calculateTR(MatrixRTCoefficients_v2& coeff)
     const complex_t l_2 = coeff.m_lambda(1);
 
     auto& T1 = coeff.T1;
-    T1 << bmbz, -bxmby, -bmbz * l_1, bxmby * l_1,
-          -bxpby, bpbz, bxpby * l_1, -bpbz * l_1,
-          -bmbz / l_1, bxmby / l_1, bmbz, -bxmby,
-          bxpby / l_1, -bpbz / l_1, -bxpby, bpbz;
+    T1 << bmbz, -bxmby, -bmbz * l_1, bxmby * l_1, -bxpby, bpbz, bxpby * l_1, -bpbz * l_1,
+        -bmbz / l_1, bxmby / l_1, bmbz, -bxmby, bxpby / l_1, -bpbz / l_1, -bxpby, bpbz;
     T1 /= 4.0 * b;
 
     auto& R1 = coeff.R1;
-    R1 << T1(0, 0), T1(0, 1), -T1(0, 2), -T1(0, 3),
-          T1(1, 0), T1(1, 1), -T1(1, 2), -T1(1, 3),
-          -T1(2, 0), -T1(2, 1), T1(2, 2), T1(2, 3),
-          -T1(3, 0), -T1(3, 1), T1(3, 2), T1(3, 3);
+    R1 << T1(0, 0), T1(0, 1), -T1(0, 2), -T1(0, 3), T1(1, 0), T1(1, 1), -T1(1, 2), -T1(1, 3),
+        -T1(2, 0), -T1(2, 1), T1(2, 2), T1(2, 3), -T1(3, 0), -T1(3, 1), T1(3, 2), T1(3, 3);
 
     auto& T2 = coeff.T2;
-    T2 << bpbz, bxmby, -bpbz * l_2, -bxmby * l_2,
-          bxpby, bmbz, -bxpby * l_2, -bmbz * l_2,
-          -bpbz / l_2, -bxmby / l_2, bpbz, bxmby,
-          -bxpby / l_2, -bmbz / l_2, bxpby, bmbz;
+    T2 << bpbz, bxmby, -bpbz * l_2, -bxmby * l_2, bxpby, bmbz, -bxpby * l_2, -bmbz * l_2,
+        -bpbz / l_2, -bxmby / l_2, bpbz, bxmby, -bxpby / l_2, -bmbz / l_2, bxpby, bmbz;
     T2 /= 4.0 * b;
 
     auto& R2 = coeff.R2;
-    R2 << T2(0, 0), T2(0, 1), -T2(0, 2), -T2(0, 3),
-          T2(1, 0), T2(1, 1), -T2(1, 2), -T2(1, 3),
-          -T2(2, 0), -T2(2, 1), T2(2, 2), T2(2, 3),
-          -T2(3, 0), -T2(3, 1), T2(3, 2), T2(3, 3);
+    R2 << T2(0, 0), T2(0, 1), -T2(0, 2), -T2(0, 3), T2(1, 0), T2(1, 1), -T2(1, 2), -T2(1, 3),
+        -T2(2, 0), -T2(2, 1), T2(2, 2), T2(2, 3), -T2(3, 0), -T2(3, 1), T2(3, 2), T2(3, 3);
 }
 
 void SpecularMagneticStrategy::calculateZeroFieldTR(MatrixRTCoefficients_v2& coeff)
@@ -135,14 +129,10 @@ void SpecularMagneticStrategy::calculateZeroFieldTR(MatrixRTCoefficients_v2& coe
     const complex_t eigen_value = coeff.m_lambda(0);
 
     Eigen::Matrix3cd Tblock;
-    Tblock << 0.5, 0.0, -0.5 * eigen_value,
-              0.0, 0.0, 0.0,
-              -0.5 / eigen_value, 0.0, 0.5;
+    Tblock << 0.5, 0.0, -0.5 * eigen_value, 0.0, 0.0, 0.0, -0.5 / eigen_value, 0.0, 0.5;
 
     Eigen::Matrix3cd Rblock;
-    Rblock << 0.5, 0.0, 0.5 * eigen_value,
-              0.0, 0.0, 0.0,
-              0.5 / eigen_value, 0.0, 0.5;
+    Rblock << 0.5, 0.0, 0.5 * eigen_value, 0.0, 0.0, 0.0, 0.5 / eigen_value, 0.0, 0.5;
 
     coeff.T1.block<3, 3>(1, 1) = Tblock;
     coeff.R1.block<3, 3>(1, 1) = Rblock;
@@ -188,7 +178,7 @@ void SpecularMagneticStrategy::nullifyBottomReflection(MatrixRTCoefficients_v2&
 }
 
 void SpecularMagneticStrategy::propagateBackwards(std::vector<MatrixRTCoefficients_v2>& coeff,
-                                           const std::vector<Slice>& slices)
+                                                  const std::vector<Slice>& slices)
 {
     const int size = static_cast<int>(coeff.size());
     for (int index = size - 2; index >= 0; --index) {
@@ -221,14 +211,14 @@ SpecularMagneticStrategy::findNormalizationCoefficients(const MatrixRTCoefficien
 }
 
 void SpecularMagneticStrategy::propagateForwards(std::vector<MatrixRTCoefficients_v2>& coeff,
-                                          const Eigen::Matrix2cd& weights)
+                                                 const Eigen::Matrix2cd& weights)
 {
     const complex_t a_plus = weights(0, 0);
     const complex_t b_plus = weights(1, 0);
     const complex_t a_min = weights(0, 1);
     const complex_t b_min = weights(1, 1);
 
-    for (auto& term: coeff) {
+    for (auto& term : coeff) {
         Eigen::Vector4cd w_plus = a_plus * term.m_w_plus + b_plus * term.m_w_min;
         Eigen::Vector4cd w_min = a_min * term.m_w_plus + b_min * term.m_w_min;
         term.m_w_plus = std::move(w_plus);
@@ -236,7 +226,8 @@ void SpecularMagneticStrategy::propagateForwards(std::vector<MatrixRTCoefficient
     }
 }
 
-namespace {
+namespace
+{
 kvector_t magneticImpact(kvector_t B_field)
 {
     return -magnetic_prefactor * B_field;
@@ -260,4 +251,4 @@ complex_t GetImExponential(complex_t exponent)
         return 0.0;
     return std::exp(I * exponent);
 }
-}
+} // namespace
diff --git a/Core/Multilayer/SpecularMagneticStrategy.h b/Core/Multilayer/SpecularMagneticStrategy.h
index 333b0d10ab3..6bde6ceebb8 100644
--- a/Core/Multilayer/SpecularMagneticStrategy.h
+++ b/Core/Multilayer/SpecularMagneticStrategy.h
@@ -18,8 +18,8 @@
 #include "ISpecularStrategy.h"
 #include "MatrixRTCoefficients_v2.h"
 #include "Vectors3D.h"
-#include <vector>
 #include <memory>
+#include <vector>
 
 class Slice;
 
@@ -31,13 +31,12 @@ class BA_CORE_API_ SpecularMagneticStrategy : public ISpecularStrategy
 public:
     //! Computes refraction angle reflection/transmission coefficients
     //! for given sliced multilayer and wavevector k
-    ISpecularStrategy::coeffs_t
-    Execute(const std::vector<Slice>& slices, const kvector_t& k) const;
+    ISpecularStrategy::coeffs_t Execute(const std::vector<Slice>& slices, const kvector_t& k) const;
 
     //! Computes refraction angle reflection/transmission coefficients
     //! for given sliced multilayer and a set of kz projections corresponding to each slice
-    ISpecularStrategy::coeffs_t
-    Execute(const std::vector<Slice>& slices, const std::vector<complex_t>& kz) const;
+    ISpecularStrategy::coeffs_t Execute(const std::vector<Slice>& slices,
+                                        const std::vector<complex_t>& kz) const;
 
     static std::vector<MatrixRTCoefficients_v2> computeTR(const std::vector<Slice>& slices,
                                                           const std::vector<complex_t>& kzs);
diff --git a/Core/Multilayer/SpecularScalarNCStrategy.cpp b/Core/Multilayer/SpecularScalarNCStrategy.cpp
index 539ea74cdee..730deaa10a5 100644
--- a/Core/Multilayer/SpecularScalarNCStrategy.cpp
+++ b/Core/Multilayer/SpecularScalarNCStrategy.cpp
@@ -15,24 +15,24 @@
 #include "SpecularScalarNCStrategy.h"
 #include <Eigen/Dense>
 
-Eigen::Vector2cd SpecularScalarNCStrategy::transition(complex_t kzi, complex_t kzi1, double sigma, double thickness,
-                                     const Eigen::Vector2cd& t_r1) const
+Eigen::Vector2cd SpecularScalarNCStrategy::transition(complex_t kzi, complex_t kzi1, double sigma,
+                                                      double thickness,
+                                                      const Eigen::Vector2cd& t_r1) const
 {
     complex_t roughness_diff = 1;
-    complex_t roughness_sum  = 1;
+    complex_t roughness_sum = 1;
     if (sigma > 0.0) {
-        roughness_diff = exp( - (kzi1 - kzi) * (kzi1 - kzi) * sigma * sigma / 2. );
-        roughness_sum  = exp( - (kzi1 + kzi) * (kzi1 + kzi) * sigma * sigma / 2. );
+        roughness_diff = exp(-(kzi1 - kzi) * (kzi1 - kzi) * sigma * sigma / 2.);
+        roughness_sum = exp(-(kzi1 + kzi) * (kzi1 + kzi) * sigma * sigma / 2.);
     }
     const complex_t phase_shift = exp_I(kzi * thickness);
     const complex_t kz_ratio = kzi1 / kzi;
-    
-    const complex_t a00 = 0.5 * ( 1. + kz_ratio ) * roughness_diff;
-    const complex_t a01 = 0.5 * ( 1. - kz_ratio ) * roughness_sum;
-    
+
+    const complex_t a00 = 0.5 * (1. + kz_ratio) * roughness_diff;
+    const complex_t a01 = 0.5 * (1. - kz_ratio) * roughness_sum;
+
     Eigen::Vector2cd result;
     result << (a00 * t_r1(0) + a01 * t_r1(1)) / phase_shift,
-    (a01 * t_r1(0) + a00 * t_r1(1)) * phase_shift;
+        (a01 * t_r1(0) + a00 * t_r1(1)) * phase_shift;
     return result;
 }
-
diff --git a/Core/Multilayer/SpecularScalarNCStrategy.h b/Core/Multilayer/SpecularScalarNCStrategy.h
index de7d7700f5c..367ea6d32ff 100644
--- a/Core/Multilayer/SpecularScalarNCStrategy.h
+++ b/Core/Multilayer/SpecularScalarNCStrategy.h
@@ -26,15 +26,13 @@ class Slice;
 class BA_CORE_API_ SpecularScalarNCStrategy : public SpecularScalarStrategy
 {
 private:
-
     //! Roughness is modelled by a Gaussian profile, i.e. Nevot-Croce factors for the
     //! reflection coefficients.
-    //! Implementation follows A. Gibaud and G. Vignaud, in X-ray and Neutron Reflectivity, edited by J. Daillant
-    //! and A. Gibaud, volume 770 of Lecture Notes in Physics (2009)
-    virtual Eigen::Vector2cd transition(complex_t kzi, complex_t kzi1, double sigma, double thickness,
+    //! Implementation follows A. Gibaud and G. Vignaud, in X-ray and Neutron Reflectivity, edited
+    //! by J. Daillant and A. Gibaud, volume 770 of Lecture Notes in Physics (2009)
+    virtual Eigen::Vector2cd transition(complex_t kzi, complex_t kzi1, double sigma,
+                                        double thickness,
                                         const Eigen::Vector2cd& t_r1) const override;
-
-
 };
 
 #endif // SPECULARSCALARNCSTRATEGY_H
diff --git a/Core/Multilayer/SpecularScalarStrategy.cpp b/Core/Multilayer/SpecularScalarStrategy.cpp
index 7eb36cdddcd..05c74960049 100644
--- a/Core/Multilayer/SpecularScalarStrategy.cpp
+++ b/Core/Multilayer/SpecularScalarStrategy.cpp
@@ -26,28 +26,29 @@ const LayerRoughness* GetBottomRoughness(const std::vector<Slice>& slices,
                                          const size_t slice_index);
 } // namespace
 
-ISpecularStrategy::coeffs_t
-SpecularScalarStrategy::Execute(const std::vector<Slice>& slices, const kvector_t& k) const
+ISpecularStrategy::coeffs_t SpecularScalarStrategy::Execute(const std::vector<Slice>& slices,
+                                                            const kvector_t& k) const
 {
     std::vector<complex_t> kz = KzComputation::computeReducedKz(slices, k);
     return Execute(slices, kz);
 }
 
-ISpecularStrategy::coeffs_t
-SpecularScalarStrategy::Execute(const std::vector<Slice>& slices, const std::vector<complex_t>& kz) const
+ISpecularStrategy::coeffs_t SpecularScalarStrategy::Execute(const std::vector<Slice>& slices,
+                                                            const std::vector<complex_t>& kz) const
 {
-    if(slices.size() != kz.size())
+    if (slices.size() != kz.size())
         throw std::runtime_error("Number of slices does not match the size of the kz-vector");
 
     ISpecularStrategy::coeffs_t result;
-    for(auto& coeff : computeTR(slices, kz))
-        result.push_back( std::make_unique<ScalarRTCoefficients>(coeff) );
+    for (auto& coeff : computeTR(slices, kz))
+        result.push_back(std::make_unique<ScalarRTCoefficients>(coeff));
 
     return result;
 }
 
-std::vector<ScalarRTCoefficients> SpecularScalarStrategy::computeTR(const std::vector<Slice>& slices,
-                                                                    const std::vector<complex_t>& kz) const
+std::vector<ScalarRTCoefficients>
+SpecularScalarStrategy::computeTR(const std::vector<Slice>& slices,
+                                  const std::vector<complex_t>& kz) const
 {
     const size_t N = slices.size();
     std::vector<ScalarRTCoefficients> coeff(N);
@@ -71,7 +72,8 @@ std::vector<ScalarRTCoefficients> SpecularScalarStrategy::computeTR(const std::v
     return coeff;
 }
 
-void SpecularScalarStrategy::setZeroBelow(std::vector<ScalarRTCoefficients>& coeff, size_t current_layer)
+void SpecularScalarStrategy::setZeroBelow(std::vector<ScalarRTCoefficients>& coeff,
+                                          size_t current_layer)
 {
     size_t N = coeff.size();
     for (size_t i = current_layer + 1; i < N; ++i) {
@@ -80,12 +82,13 @@ void SpecularScalarStrategy::setZeroBelow(std::vector<ScalarRTCoefficients>& coe
 }
 
 bool SpecularScalarStrategy::calculateUpFromLayer(std::vector<ScalarRTCoefficients>& coeff,
-                          const std::vector<Slice>& slices, const std::vector<complex_t>& kz,
-                          size_t slice_index) const
+                                                  const std::vector<Slice>& slices,
+                                                  const std::vector<complex_t>& kz,
+                                                  size_t slice_index) const
 {
     coeff[slice_index + 1].t_r(0) = 1.0;
     coeff[slice_index + 1].t_r(1) = 0.0;
-    std::vector<complex_t> factors(slice_index+2);
+    std::vector<complex_t> factors(slice_index + 2);
     factors[slice_index + 1] = complex_t(1, 0);
     for (size_t j = 0; j <= slice_index; ++j) {
         size_t i = slice_index - j; // start from bottom
@@ -95,7 +98,7 @@ bool SpecularScalarStrategy::calculateUpFromLayer(std::vector<ScalarRTCoefficien
 
         coeff[i].t_r = transition(kz[i], kz[i + 1], sigma, slices[i].thickness(), coeff[i + 1].t_r);
 
-        if (std::isinf(std::norm(coeff[i].t_r(0))) || std::isnan(std::norm(coeff[i].t_r(0)))){
+        if (std::isinf(std::norm(coeff[i].t_r(0))) || std::isnan(std::norm(coeff[i].t_r(0)))) {
             coeff[i].t_r(0) = 1.0;
             coeff[i].t_r(1) = 0.0;
 
@@ -111,12 +114,13 @@ bool SpecularScalarStrategy::calculateUpFromLayer(std::vector<ScalarRTCoefficien
     }
 
     // now correct all amplitudes by dividing the with the remaining factors in forward direction
-    // at some point this divison underflows, which is the point when all further amplitudes are set to zero
+    // at some point this divison underflows, which is the point when all further amplitudes are set
+    // to zero
     auto dumpingFactor = complex_t(1, 0);
-    for (size_t j = 1; j <= slice_index + 1; ++j){
-        dumpingFactor = dumpingFactor * factors[j-1];
-        if (std::isinf(std::norm( dumpingFactor ))){
-            setZeroBelow(coeff, j-1);
+    for (size_t j = 1; j <= slice_index + 1; ++j) {
+        dumpingFactor = dumpingFactor * factors[j - 1];
+        if (std::isinf(std::norm(dumpingFactor))) {
+            setZeroBelow(coeff, j - 1);
             break;
         }
         coeff[j].t_r = coeff[j].t_r / dumpingFactor;
@@ -126,11 +130,12 @@ bool SpecularScalarStrategy::calculateUpFromLayer(std::vector<ScalarRTCoefficien
     return true;
 }
 
-namespace  {
+namespace
+{
 const LayerRoughness* GetBottomRoughness(const std::vector<Slice>& slices, const size_t slice_index)
 {
     if (slice_index + 1 < slices.size())
         return slices[slice_index + 1].topRoughness();
     return nullptr;
 }
-}
+} // namespace
diff --git a/Core/Multilayer/SpecularScalarStrategy.h b/Core/Multilayer/SpecularScalarStrategy.h
index 9278f04285d..1fa65f63549 100644
--- a/Core/Multilayer/SpecularScalarStrategy.h
+++ b/Core/Multilayer/SpecularScalarStrategy.h
@@ -18,8 +18,8 @@
 #include "ISpecularStrategy.h"
 #include "ScalarRTCoefficients.h"
 #include "Vectors3D.h"
-#include <vector>
 #include <memory>
+#include <vector>
 
 class Slice;
 
@@ -39,17 +39,17 @@ public:
                                                 const std::vector<complex_t>& kz) const override;
 
 private:
-    virtual Eigen::Vector2cd transition(complex_t kzi, complex_t kzi1, double sigma, double thickness,
-                                        const Eigen::Vector2cd& t_r1) const = 0;
+    virtual Eigen::Vector2cd transition(complex_t kzi, complex_t kzi1, double sigma,
+                                        double thickness, const Eigen::Vector2cd& t_r1) const = 0;
 
     std::vector<ScalarRTCoefficients> computeTR(const std::vector<Slice>& slices,
-                                                       const std::vector<complex_t>& kz) const;
+                                                const std::vector<complex_t>& kz) const;
 
     static void setZeroBelow(std::vector<ScalarRTCoefficients>& coeff, size_t current_layer);
 
     bool calculateUpFromLayer(std::vector<ScalarRTCoefficients>& coeff,
-                                     const std::vector<Slice>& slices, const std::vector<complex_t>& kz,
-                                     size_t slice_index) const;
+                              const std::vector<Slice>& slices, const std::vector<complex_t>& kz,
+                              size_t slice_index) const;
 };
 
 #endif // SPECULARSCALARSTRATEGY_H
diff --git a/Core/Multilayer/SpecularScalarTanhStrategy.cpp b/Core/Multilayer/SpecularScalarTanhStrategy.cpp
index 8915985ec47..b27e741434c 100644
--- a/Core/Multilayer/SpecularScalarTanhStrategy.cpp
+++ b/Core/Multilayer/SpecularScalarTanhStrategy.cpp
@@ -19,11 +19,12 @@
 
 namespace
 {
-    const double pi2_15 = std::pow(M_PI_2, 1.5);
+const double pi2_15 = std::pow(M_PI_2, 1.5);
 }
 
-Eigen::Vector2cd SpecularScalarTanhStrategy::transition(complex_t kzi, complex_t kzi1, double sigma, double thickness,
-                            const Eigen::Vector2cd& t_r1) const
+Eigen::Vector2cd SpecularScalarTanhStrategy::transition(complex_t kzi, complex_t kzi1, double sigma,
+                                                        double thickness,
+                                                        const Eigen::Vector2cd& t_r1) const
 {
     complex_t roughness = 1;
     if (sigma > 0.0) {
diff --git a/Core/Multilayer/SpecularScalarTanhStrategy.h b/Core/Multilayer/SpecularScalarTanhStrategy.h
index 84b05e659cd..81b415fdd91 100644
--- a/Core/Multilayer/SpecularScalarTanhStrategy.h
+++ b/Core/Multilayer/SpecularScalarTanhStrategy.h
@@ -26,12 +26,10 @@ class Slice;
 class BA_CORE_API_ SpecularScalarTanhStrategy : public SpecularScalarStrategy
 {
 private:
-
     //! Roughness is modelled by tanh profile [see e.g. Phys. Rev. B, vol. 47 (8), p. 4385 (1993)].
-    virtual Eigen::Vector2cd transition(complex_t kzi, complex_t kzi1, double sigma, double thickness,
+    virtual Eigen::Vector2cd transition(complex_t kzi, complex_t kzi1, double sigma,
+                                        double thickness,
                                         const Eigen::Vector2cd& t_r1) const override;
-
-
 };
 
 #endif // SPECULARSCALARTANHSTRATEGY_H
diff --git a/Core/Multilayer/SpecularStrategyBuilder.cpp b/Core/Multilayer/SpecularStrategyBuilder.cpp
index 568ac6096c7..ff0c3681a78 100644
--- a/Core/Multilayer/SpecularStrategyBuilder.cpp
+++ b/Core/Multilayer/SpecularStrategyBuilder.cpp
@@ -12,11 +12,11 @@
 //
 // ************************************************************************** //
 
+#include "SpecularStrategyBuilder.h"
 #include "MultiLayerUtils.h"
 #include "SpecularMagneticStrategy.h"
 #include "SpecularScalarNCStrategy.h"
 #include "SpecularScalarTanhStrategy.h"
-#include "SpecularStrategyBuilder.h"
 
 std::unique_ptr<ISpecularStrategy> SpecularStrategyBuilder::build(const MultiLayer& sample,
                                                                   const bool magnetic)
diff --git a/Core/Multilayer/SpecularStrategyBuilder.h b/Core/Multilayer/SpecularStrategyBuilder.h
index 74646f158fd..dbe421cce43 100644
--- a/Core/Multilayer/SpecularStrategyBuilder.h
+++ b/Core/Multilayer/SpecularStrategyBuilder.h
@@ -23,7 +23,7 @@ class SpecularStrategyBuilder
 {
 
 public:
-    static std::unique_ptr<ISpecularStrategy> build( const MultiLayer& sample, const bool magnetic );
+    static std::unique_ptr<ISpecularStrategy> build(const MultiLayer& sample, const bool magnetic);
 };
 
 #endif // SPECULARSTRATEGYBUILDER_H
diff --git a/Core/Parametrization/DistributionHandler.cpp b/Core/Parametrization/DistributionHandler.cpp
index ea2d9f83866..6a1b552dca1 100644
--- a/Core/Parametrization/DistributionHandler.cpp
+++ b/Core/Parametrization/DistributionHandler.cpp
@@ -18,19 +18,16 @@
 #include "ParameterPool.h"
 #include "ParameterSample.h"
 
-DistributionHandler::DistributionHandler()
-: m_nbr_combinations(1)
+DistributionHandler::DistributionHandler() : m_nbr_combinations(1)
 {
     setName("DistributionHandler");
 }
 
-DistributionHandler::~DistributionHandler()
-{
-}
+DistributionHandler::~DistributionHandler() {}
 
 void DistributionHandler::addParameterDistribution(const ParameterDistribution& par_distr)
 {
-    if(par_distr.getNbrSamples() > 0) {
+    if (par_distr.getNbrSamples() > 0) {
         m_distributions.push_back(par_distr);
         m_nbr_combinations *= par_distr.getNbrSamples();
         m_cached_samples.push_back(par_distr.generateSamples());
@@ -46,25 +43,26 @@ double DistributionHandler::setParameterValues(ParameterPool* p_parameter_pool,
 {
     if (index >= m_nbr_combinations)
         throw Exceptions::RuntimeErrorException(
-                "DistributionWeighter::setParameterValues: "
-                "index must be smaller than the total number of parameter combinations");
+            "DistributionWeighter::setParameterValues: "
+            "index must be smaller than the total number of parameter combinations");
     size_t n_distr = m_distributions.size();
     double weight = 1.0;
-    if (n_distr == 0) return weight;
-    for (size_t param_index=n_distr-1; ; --param_index) {
+    if (n_distr == 0)
+        return weight;
+    for (size_t param_index = n_distr - 1;; --param_index) {
         size_t remainder = index % m_distributions[param_index].getNbrSamples();
         index /= m_distributions[param_index].getNbrSamples();
         int changed = p_parameter_pool->setMatchedParametersValue(
-                m_distributions[param_index].getMainParameterName(),
-                m_cached_samples[param_index][remainder].value);
+            m_distributions[param_index].getMainParameterName(),
+            m_cached_samples[param_index][remainder].value);
         if (changed != 1) {
-            throw Exceptions::RuntimeErrorException(
-                    "DistributionWeighter::setParameterValues: "
-                    "parameter name matches nothing or more than "
-                    "one parameter");
+            throw Exceptions::RuntimeErrorException("DistributionWeighter::setParameterValues: "
+                                                    "parameter name matches nothing or more than "
+                                                    "one parameter");
         }
         weight *= m_cached_samples[param_index][remainder].weight;
-        if (param_index==0) break;
+        if (param_index == 0)
+            break;
     }
     return weight;
 }
diff --git a/Core/Parametrization/DistributionHandler.h b/Core/Parametrization/DistributionHandler.h
index 78d3d0261c1..8cda348e025 100644
--- a/Core/Parametrization/DistributionHandler.h
+++ b/Core/Parametrization/DistributionHandler.h
@@ -29,12 +29,12 @@ public:
     virtual ~DistributionHandler();
 
     //! add a sampled parameter distribution
-    void addParameterDistribution(const std::string &param_name,
-            const IDistribution1D &distribution, size_t nbr_samples,
-            double sigma_factor=0.0,
-            const RealLimits &limits=RealLimits());
+    void addParameterDistribution(const std::string& param_name,
+                                  const IDistribution1D& distribution, size_t nbr_samples,
+                                  double sigma_factor = 0.0,
+                                  const RealLimits& limits = RealLimits());
 
-    void addParameterDistribution(const ParameterDistribution &par_distr);
+    void addParameterDistribution(const ParameterDistribution& par_distr);
 
     //! get the total number of parameter value combinations (product
     //! of the individual sizes of each parameter distribution
@@ -44,7 +44,7 @@ public:
     //! combination of values, determined by the index (which must be smaller
     //! than the total number of combinations) and returns the weight
     //! associated with this combination of parameter values
-    double setParameterValues(ParameterPool *p_parameter_pool, size_t index);
+    double setParameterValues(ParameterPool* p_parameter_pool, size_t index);
 
     //! Sets mean distribution values to the parameter pool.
     void setParameterToMeans(ParameterPool* p_parameter_pool) const;
@@ -54,7 +54,7 @@ public:
 private:
     size_t m_nbr_combinations;
     Distributions_t m_distributions;
-    std::vector<std::vector<ParameterSample> > m_cached_samples;
+    std::vector<std::vector<ParameterSample>> m_cached_samples;
 };
 
 #endif // DISTRIBUTIONHANDLER_H
diff --git a/Core/Parametrization/Distributions.cpp b/Core/Parametrization/Distributions.cpp
index a4d289928d1..fa52c8bb6f5 100644
--- a/Core/Parametrization/Distributions.cpp
+++ b/Core/Parametrization/Distributions.cpp
@@ -24,7 +24,8 @@
 #include <limits>
 #include <sstream>
 
-namespace {
+namespace
+{
 bool DoubleEqual(double a, double b);
 }
 
@@ -283,7 +284,7 @@ DistributionLogNormal::DistributionLogNormal(double median, double scale_param)
 double DistributionLogNormal::probabilityDensity(double x) const
 {
     if (m_scale_param == 0.0)
-        return DoubleEqual(x, m_median)  ? 1.0 : 0.0;
+        return DoubleEqual(x, m_median) ? 1.0 : 0.0;
     double t = std::log(x / m_median) / m_scale_param;
     return std::exp(-t * t / 2.0) / (x * m_scale_param * std::sqrt(M_TWOPI));
 }
@@ -465,11 +466,13 @@ void DistributionTrapezoid::adjustLimitsToNonZeroSamples(double& min, double& ma
         max -= step;
 }
 
-namespace {
+namespace
+{
 bool DoubleEqual(double a, double b)
 {
-    double eps = 10.0 * std::max(std::abs(a)*std::numeric_limits<double>::epsilon(),
-                                 std::numeric_limits<double>::min());
-    return std::abs(a-b) < eps;
-}
+    double eps = 10.0
+                 * std::max(std::abs(a) * std::numeric_limits<double>::epsilon(),
+                            std::numeric_limits<double>::min());
+    return std::abs(a - b) < eps;
 }
+} // namespace
diff --git a/Core/Parametrization/Distributions.h b/Core/Parametrization/Distributions.h
index 32f63f9dd9d..2fe5275aa00 100644
--- a/Core/Parametrization/Distributions.h
+++ b/Core/Parametrization/Distributions.h
@@ -35,33 +35,34 @@ public:
     IDistribution1D() {}
     virtual ~IDistribution1D() {}
 
-    virtual IDistribution1D* clone() const =0;
+    virtual IDistribution1D* clone() const = 0;
 
     //! Returns the distribution-specific probability density for value x.
-    virtual double probabilityDensity(double x) const =0;
+    virtual double probabilityDensity(double x) const = 0;
 
     //! Returns the distribution-specific mean.
-    virtual double getMean() const =0;
+    virtual double getMean() const = 0;
 
     //! Returns equidistant samples, using intrinsic parameters, weighted with probabilityDensity().
-    std::vector<ParameterSample> equidistantSamples(
-        size_t nbr_samples, double sigma_factor=0., const RealLimits& limits=RealLimits()) const;
+    std::vector<ParameterSample> equidistantSamples(size_t nbr_samples, double sigma_factor = 0.,
+                                                    const RealLimits& limits = RealLimits()) const;
 
     //! Returns equidistant samples from xmin to xmax, weighted with probabilityDensity().
-    std::vector<ParameterSample> equidistantSamplesInRange(
-        size_t nbr_samples, double xmin, double xmax) const;
+    std::vector<ParameterSample> equidistantSamplesInRange(size_t nbr_samples, double xmin,
+                                                           double xmax) const;
 
     //! Returns equidistant interpolation points, with range computed in distribution-specific
     //! way from mean and width parameter, taking into account limits and sigma_factor.
-    virtual std::vector<double> equidistantPoints(
-        size_t nbr_samples, double sigma_factor, const RealLimits& limits=RealLimits()) const =0;
+    virtual std::vector<double>
+    equidistantPoints(size_t nbr_samples, double sigma_factor,
+                      const RealLimits& limits = RealLimits()) const = 0;
 
     //! Returns equidistant interpolation points from xmin to xmax.
-    virtual std::vector<double> equidistantPointsInRange(
-        size_t nbr_samples, double xmin, double xmax) const;
+    virtual std::vector<double> equidistantPointsInRange(size_t nbr_samples, double xmin,
+                                                         double xmax) const;
 
     //! Returns true if the distribution is in the limit case of a Dirac delta distribution.
-    virtual bool isDelta() const =0;
+    virtual bool isDelta() const = 0;
 
     //! Sets distribution units.
     virtual void setUnits(const std::string& units);
@@ -76,11 +77,10 @@ protected:
     void adjustMinMaxForLimits(double& xmin, double& xmax, const RealLimits& limits) const;
 
     //! Returns weighted samples from given interpolation points and probabilityDensity().
-    std::vector<ParameterSample> generateSamplesFromValues(
-        const std::vector<double>& sample_values) const;
+    std::vector<ParameterSample>
+    generateSamplesFromValues(const std::vector<double>& sample_values) const;
 };
 
-
 // ************************************************************************** //
 // specific distribution classes
 // ************************************************************************** //
@@ -91,20 +91,20 @@ protected:
 class BA_CORE_API_ DistributionGate : public IDistribution1D
 {
 public:
-    DistributionGate() : DistributionGate( 0., 1. ) {}
+    DistributionGate() : DistributionGate(0., 1.) {}
     DistributionGate(double min, double max);
     virtual ~DistributionGate() {}
 
     DistributionGate* clone() const final { return new DistributionGate(m_min, m_max); }
 
     double probabilityDensity(double x) const final;
-    double getMean() const final { return (m_min+m_max)/2.0; }
+    double getMean() const final { return (m_min + m_max) / 2.0; }
     double getMin() const { return m_min; }
     double getMax() const { return m_max; }
 
     //! Returns list of sample values
-    virtual std::vector<double> equidistantPoints(
-        size_t nbr_samples, double sigma_factor, const RealLimits& limits = RealLimits()) const;
+    virtual std::vector<double> equidistantPoints(size_t nbr_samples, double sigma_factor,
+                                                  const RealLimits& limits = RealLimits()) const;
 
     bool isDelta() const final;
 
@@ -121,7 +121,6 @@ private:
     double m_max;
 };
 
-
 //! Lorentz distribution with half width hwhm.
 //! @ingroup paramDistribution
 
@@ -139,8 +138,8 @@ public:
     double getHWHM() const { return m_hwhm; }
 
     //! generate list of sample values
-    virtual std::vector<double> equidistantPoints(
-        size_t nbr_samples, double sigma_factor, const RealLimits& limits = RealLimits()) const;
+    virtual std::vector<double> equidistantPoints(size_t nbr_samples, double sigma_factor,
+                                                  const RealLimits& limits = RealLimits()) const;
 
     bool isDelta() const final;
 
@@ -157,27 +156,28 @@ private:
     double m_hwhm;
 };
 
-
 //! Gaussian distribution with standard deviation std_dev.
 //! @ingroup paramDistribution
 
-class BA_CORE_API_ DistributionGaussian: public IDistribution1D
+class BA_CORE_API_ DistributionGaussian : public IDistribution1D
 {
 public:
     DistributionGaussian() : DistributionGaussian(0., 1.) {}
     DistributionGaussian(double mean, double std_dev);
     virtual ~DistributionGaussian() {}
 
-    DistributionGaussian* clone() const final {
-        return new DistributionGaussian(m_mean, m_std_dev); }
+    DistributionGaussian* clone() const final
+    {
+        return new DistributionGaussian(m_mean, m_std_dev);
+    }
 
     double probabilityDensity(double x) const final;
     double getMean() const final { return m_mean; }
     double getStdDev() const { return m_std_dev; }
 
     //! generate list of sample values
-    virtual std::vector<double> equidistantPoints(
-        size_t nbr_samples, double sigma_factor, const RealLimits& limits = RealLimits()) const;
+    virtual std::vector<double> equidistantPoints(size_t nbr_samples, double sigma_factor,
+                                                  const RealLimits& limits = RealLimits()) const;
 
     bool isDelta() const final;
 
@@ -194,19 +194,20 @@ private:
     double m_std_dev;
 };
 
-
 //! Log-normal distribution.
 //! @ingroup paramDistribution
 
-class BA_CORE_API_ DistributionLogNormal: public IDistribution1D
+class BA_CORE_API_ DistributionLogNormal : public IDistribution1D
 {
 public:
     DistributionLogNormal(double scale_param) : DistributionLogNormal(1., scale_param) {}
     DistributionLogNormal(double median, double scale_param);
     virtual ~DistributionLogNormal() {}
 
-    DistributionLogNormal* clone() const final {
-        return new DistributionLogNormal(m_median, m_scale_param); }
+    DistributionLogNormal* clone() const final
+    {
+        return new DistributionLogNormal(m_median, m_scale_param);
+    }
 
     double probabilityDensity(double x) const final;
     double getMean() const final;
@@ -214,8 +215,8 @@ public:
     double getScalePar() const { return m_scale_param; }
 
     //! generate list of sample values
-    virtual std::vector<double> equidistantPoints(
-        size_t nbr_samples, double sigma_factor, const RealLimits& limits = RealLimits()) const;
+    virtual std::vector<double> equidistantPoints(size_t nbr_samples, double sigma_factor,
+                                                  const RealLimits& limits = RealLimits()) const;
 
     bool isDelta() const final;
 
@@ -234,11 +235,10 @@ private:
     double m_scale_param;
 };
 
-
 //! Cosine distribution.
 //! @ingroup paramDistribution
 
-class BA_CORE_API_ DistributionCosine: public IDistribution1D
+class BA_CORE_API_ DistributionCosine : public IDistribution1D
 {
 public:
     DistributionCosine() : DistributionCosine(0., 1.) {}
@@ -252,8 +252,8 @@ public:
     double getSigma() const { return m_sigma; }
 
     //! generate list of sample values
-    virtual std::vector<double> equidistantPoints(
-        size_t nbr_samples, double sigma_factor, const RealLimits& limits = RealLimits()) const;
+    virtual std::vector<double> equidistantPoints(size_t nbr_samples, double sigma_factor,
+                                                  const RealLimits& limits = RealLimits()) const;
 
     bool isDelta() const final;
 
@@ -273,16 +273,18 @@ private:
 //! Trapezoidal distribution.
 //! @ingroup paramDistribution
 
-class BA_CORE_API_ DistributionTrapezoid: public IDistribution1D
+class BA_CORE_API_ DistributionTrapezoid : public IDistribution1D
 {
 public:
     DistributionTrapezoid() : DistributionTrapezoid(0., 0., 1., 0.) {}
-    DistributionTrapezoid(double center, double left_width,
-                            double middle_width, double right_width);
+    DistributionTrapezoid(double center, double left_width, double middle_width,
+                          double right_width);
     virtual ~DistributionTrapezoid() {}
 
-    DistributionTrapezoid* clone() const final {
-        return new DistributionTrapezoid(m_center, m_left, m_middle, m_right); }
+    DistributionTrapezoid* clone() const final
+    {
+        return new DistributionTrapezoid(m_center, m_left, m_middle, m_right);
+    }
 
     double probabilityDensity(double x) const final;
     double getMean() const final { return m_center; }
@@ -291,8 +293,8 @@ public:
     double getRightWidth() const { return m_right; }
 
     //! generate list of sample values
-    virtual std::vector<double> equidistantPoints(
-        size_t nbr_samples, double sigma_factor, const RealLimits& limits = RealLimits()) const;
+    virtual std::vector<double> equidistantPoints(size_t nbr_samples, double sigma_factor,
+                                                  const RealLimits& limits = RealLimits()) const;
 
     bool isDelta() const final;
 
diff --git a/Core/Parametrization/INode.cpp b/Core/Parametrization/INode.cpp
index 128afa7b373..e8ab3e1e371 100644
--- a/Core/Parametrization/INode.cpp
+++ b/Core/Parametrization/INode.cpp
@@ -14,29 +14,27 @@
 
 #include "INode.h"
 #include "Exceptions.h"
-#include "NodeUtils.h"
-#include "NodeIterator.h"
 #include "IterationStrategy.h"
+#include "NodeIterator.h"
+#include "NodeUtils.h"
 #include "ParameterPool.h"
 #include <algorithm>
 
-INode::INode()
-    : m_parent(nullptr)
-{}
+INode::INode() : m_parent(nullptr) {}
 
 std::string INode::treeToString() const
 {
     return NodeUtils::nodeToString(*this);
 }
 
-void INode::registerChild(INode *node)
+void INode::registerChild(INode* node)
 {
-    if(!node)
+    if (!node)
         throw Exceptions::NullPointerException("INode::registerChild -> Error. Null pointer.");
     node->setParent(this);
 }
 
-std::vector<const INode *> INode::getChildren() const
+std::vector<const INode*> INode::getChildren() const
 {
     return {};
 }
@@ -58,13 +56,13 @@ INode* INode::parent()
 
 int INode::copyNumber(const INode* node) const
 {
-    if(node->parent() != this)
+    if (node->parent() != this)
         return -1;
 
     int result(-1), count(0);
     for (auto child : getChildren()) {
 
-        if(child == nullptr)
+        if (child == nullptr)
             throw std::runtime_error("INode::copyNumber() -> Error. Nullptr as child.");
 
         if (child == node)
@@ -95,7 +93,7 @@ ParameterPool* INode::createParameterTree() const
     NodeIterator<PreorderStrategy> it(this);
     it.first();
     while (!it.isDone()) {
-        const INode *child = it.getCurrent();
+        const INode* child = it.getCurrent();
         const std::string path = NodeUtils::nodePath(*child, this->parent()) + "/";
         child->parameterPool()->copyToExternalPool(path, result.get());
         it.next();
diff --git a/Core/Parametrization/INode.h b/Core/Parametrization/INode.h
index 2db6def172a..c064e2f3794 100644
--- a/Core/Parametrization/INode.h
+++ b/Core/Parametrization/INode.h
@@ -15,10 +15,10 @@
 #ifndef INODE_H
 #define INODE_H
 
-#include "IParameterized.h"
 #include "INodeVisitor.h"
-#include <vector>
+#include "IParameterized.h"
 #include <memory>
+#include <vector>
 
 //! Base class for tree-like structures containing parameterized objects.
 //! @ingroup tools_internal
@@ -27,10 +27,10 @@ class BA_CORE_API_ INode : public IParameterized
 {
 public:
     INode();
-    virtual ~INode(){}
+    virtual ~INode() {}
 
     //! Calls the INodeVisitor's visit method
-    virtual void accept(INodeVisitor* visitor) const=0;
+    virtual void accept(INodeVisitor* visitor) const = 0;
 
     //! Returns multiline string representing tree structure below the node.
     virtual std::string treeToString() const;
@@ -75,15 +75,13 @@ std::vector<const INode*>& operator<<(std::vector<const INode*>&& v_node,
     return v_node;
 }
 
-inline std::vector<const INode*>& operator<<(std::vector<const INode*>& v_node,
-                                             const INode* node)
+inline std::vector<const INode*>& operator<<(std::vector<const INode*>& v_node, const INode* node)
 {
     v_node.push_back(node);
     return v_node;
 }
 
-inline std::vector<const INode*>& operator<<(std::vector<const INode*>&& v_node,
-                                             const INode* node)
+inline std::vector<const INode*>& operator<<(std::vector<const INode*>&& v_node, const INode* node)
 {
     v_node.push_back(node);
     return v_node;
diff --git a/Core/Parametrization/INodeVisitor.cpp b/Core/Parametrization/INodeVisitor.cpp
index f88e96fc020..4f4a1c719ca 100644
--- a/Core/Parametrization/INodeVisitor.cpp
+++ b/Core/Parametrization/INodeVisitor.cpp
@@ -21,7 +21,7 @@ void VisitNodesPreorder(const INode& node, INodeVisitor& visitor)
     it.first();
     while (!it.isDone()) {
         visitor.setDepth(it.depth());
-        const INode *child = it.getCurrent();
+        const INode* child = it.getCurrent();
         child->accept(&visitor);
         it.next();
     }
@@ -33,7 +33,7 @@ void VisitNodesPostorder(const INode& node, INodeVisitor& visitor)
     it.first();
     while (!it.isDone()) {
         visitor.setDepth(it.depth());
-        const INode *child = it.getCurrent();
+        const INode* child = it.getCurrent();
         child->accept(&visitor);
         it.next();
     }
diff --git a/Core/Parametrization/INodeVisitor.h b/Core/Parametrization/INodeVisitor.h
index a5bdc776be0..02c97da2e5b 100644
--- a/Core/Parametrization/INodeVisitor.h
+++ b/Core/Parametrization/INodeVisitor.h
@@ -147,7 +147,7 @@ class BA_CORE_API_ INodeVisitor
 {
 public:
     INodeVisitor() : m_depth(0) {}
-    virtual ~INodeVisitor(){}
+    virtual ~INodeVisitor() {}
 
     virtual void visit(const BasicLattice*) {}
     virtual void visit(const Beam*) {}
diff --git a/Core/Parametrization/IParameter.h b/Core/Parametrization/IParameter.h
index 681e1c15f12..03f3313f0c7 100644
--- a/Core/Parametrization/IParameter.h
+++ b/Core/Parametrization/IParameter.h
@@ -26,21 +26,24 @@
 //! This class is templated on the data type of the wrapped parameter.
 //! @ingroup tools_internal
 
-template<class T>
-class IParameter : public INamed
+template <class T> class IParameter : public INamed
 {
 public:
-    IParameter() =delete;
+    IParameter() = delete;
     IParameter(const std::string& name, T* data, const std::string& parent_name,
                const std::function<void()>& onChange);
 
-    virtual IParameter* clone( const std::string& new_name="" ) const =0;
+    virtual IParameter* clone(const std::string& new_name = "") const = 0;
 
     //! Returns true if wrapped parameter was not initialized with proper real value
     virtual bool isNull() const { return m_data ? false : true; }
 
     T& getData() const { return *m_data; }
-    void setData(T& data) { m_data = &data; m_onChange(); }
+    void setData(T& data)
+    {
+        m_data = &data;
+        m_onChange();
+    }
 
     bool hasSameData(const IParameter& other);
 
@@ -53,23 +56,18 @@ protected:
     std::string fullName() { return m_parent_name + "/" + getName(); }
 };
 
-template<class T>
-IParameter<T>::IParameter(const std::string& name, T* data,
-                          const std::string& parent_name,
-                          const std::function<void ()>& onChange)
-    : INamed(name)
-    , m_data(data)
-    , m_parent_name(parent_name)
-    , m_onChange(onChange)
+template <class T>
+IParameter<T>::IParameter(const std::string& name, T* data, const std::string& parent_name,
+                          const std::function<void()>& onChange)
+    : INamed(name), m_data(data), m_parent_name(parent_name), m_onChange(onChange)
 {
-    if(!m_data)
+    if (!m_data)
         throw std::runtime_error("Attempt to construct an IParameter with null data pointer");
 }
 
 //! Returns true if two parameters are pointing to the same raw data.
 
-template<class T>
-bool IParameter<T>::hasSameData(const IParameter<T>& other)
+template <class T> bool IParameter<T>::hasSameData(const IParameter<T>& other)
 {
     return &getData() == &other.getData();
 }
diff --git a/Core/Parametrization/IParameterized.cpp b/Core/Parametrization/IParameterized.cpp
index ac8315ecc7c..4c3ffc359f8 100644
--- a/Core/Parametrization/IParameterized.cpp
+++ b/Core/Parametrization/IParameterized.cpp
@@ -22,17 +22,15 @@
 #include <sstream>
 #include <stdexcept>
 
-IParameterized::IParameterized(const std::string& name)
-    : INamed(name)
+IParameterized::IParameterized(const std::string& name) : INamed(name)
 {
     m_pool = new ParameterPool;
 }
 
-IParameterized::IParameterized(const IParameterized& other)
-    : IParameterized(other.getName())
+IParameterized::IParameterized(const IParameterized& other) : IParameterized(other.getName())
 {
-    if( other.parameterPool()->size() )
-        throw std::runtime_error( "BUG: not prepared to copy parameters of " + getName() );
+    if (other.parameterPool()->size())
+        throw std::runtime_error("BUG: not prepared to copy parameters of " + getName());
 }
 
 IParameterized::~IParameterized()
@@ -43,14 +41,14 @@ IParameterized::~IParameterized()
 ParameterPool* IParameterized::createParameterTree() const
 {
     std::unique_ptr<ParameterPool> result(new ParameterPool);
-    m_pool->copyToExternalPool("/"+getName()+"/", result.get());
+    m_pool->copyToExternalPool("/" + getName() + "/", result.get());
     return result.release();
 }
 
 std::string IParameterized::parametersToString() const
 {
     std::ostringstream result;
-    std::unique_ptr<ParameterPool> P_pool( createParameterTree() );
+    std::unique_ptr<ParameterPool> P_pool(createParameterTree());
     result << *P_pool << "\n";
     return result.str();
 }
@@ -58,7 +56,7 @@ std::string IParameterized::parametersToString() const
 RealParameter& IParameterized::registerParameter(const std::string& name, double* data)
 {
     return m_pool->addParameter(
-                new RealParameter( name, data, getName(), [&]()->void{ onChange(); } ));
+        new RealParameter(name, data, getName(), [&]() -> void { onChange(); }));
 }
 
 void IParameterized::registerVector(const std::string& base_name, kvector_t* p_vec,
@@ -71,11 +69,11 @@ void IParameterized::registerVector(const std::string& base_name, kvector_t* p_v
 
 void IParameterized::setParameterValue(const std::string& name, double value)
 {
-    if(name.find('*') == std::string::npos && name.find('/') == std::string::npos) {
+    if (name.find('*') == std::string::npos && name.find('/') == std::string::npos) {
         m_pool->setParameterValue(name, value);
     } else {
-        std::unique_ptr<ParameterPool> P_pool { createParameterTree() };
-        if(name.find('*') != std::string::npos)
+        std::unique_ptr<ParameterPool> P_pool{createParameterTree()};
+        if (name.find('*') != std::string::npos)
             P_pool->setMatchedParametersValue(name, value);
         else
             P_pool->setParameterValue(name, value);
@@ -90,7 +88,8 @@ void IParameterized::setVectorValue(const std::string& base_name, kvector_t valu
 }
 
 //! Returns parameter with given 'name'.
-RealParameter* IParameterized::parameter(const std::string& name) const {
+RealParameter* IParameterized::parameter(const std::string& name) const
+{
     return m_pool->parameter(name);
 }
 
diff --git a/Core/Parametrization/IParameterized.h b/Core/Parametrization/IParameterized.h
index 7e310220f86..9fc8b168168 100644
--- a/Core/Parametrization/IParameterized.h
+++ b/Core/Parametrization/IParameterized.h
@@ -15,9 +15,9 @@
 #ifndef IPARAMETERIZED_H
 #define IPARAMETERIZED_H
 
+#include "BornAgainNamespace.h"
 #include "INamed.h"
 #include "Vectors3D.h"
-#include "BornAgainNamespace.h"
 
 class RealLimits;
 class ParameterPool;
@@ -29,7 +29,7 @@ class RealParameter;
 class BA_CORE_API_ IParameterized : public INamed
 {
 public:
-    IParameterized(const std::string& name="");
+    IParameterized(const std::string& name = "");
     IParameterized(const IParameterized& other);
     ~IParameterized();
 
@@ -47,7 +47,7 @@ public:
     RealParameter& registerParameter(const std::string& name, double* parpointer);
 
     void registerVector(const std::string& base_name, kvector_t* p_vec,
-                        const std::string& units=BornAgain::UnitsNm);
+                        const std::string& units = BornAgain::UnitsNm);
 
     void setParameterValue(const std::string& name, double value);
 
@@ -65,6 +65,7 @@ public:
     static std::string XComponentName(const std::string& base_name);
     static std::string YComponentName(const std::string& base_name);
     static std::string ZComponentName(const std::string& base_name);
+
 private:
     ParameterPool* m_pool; //!< parameter pool (kind of pointer-to-implementation)
 };
diff --git a/Core/Parametrization/NodeIterator.cpp b/Core/Parametrization/NodeIterator.cpp
index c67464b0062..ba7b6e98725 100644
--- a/Core/Parametrization/NodeIterator.cpp
+++ b/Core/Parametrization/NodeIterator.cpp
@@ -14,17 +14,11 @@
 
 #include "NodeIterator.h"
 
-IteratorState::IteratorState(const INode *single_element)
-    : m_position(0)
+IteratorState::IteratorState(const INode* single_element) : m_position(0)
 {
     m_samples.push_back(single_element);
 }
 
-IteratorState::IteratorState(std::vector<const INode *> samples)
-    : m_samples(samples)
-    , m_position(0)
+IteratorState::IteratorState(std::vector<const INode*> samples) : m_samples(samples), m_position(0)
 {
 }
-
-
-
diff --git a/Core/Parametrization/NodeIterator.h b/Core/Parametrization/NodeIterator.h
index c1dec131add..70563ae4d02 100644
--- a/Core/Parametrization/NodeIterator.h
+++ b/Core/Parametrization/NodeIterator.h
@@ -32,13 +32,15 @@ public:
     virtual ~IteratorState() {}
 
     const INode* getCurrent() const { return m_samples[m_position]; }
-    bool isEnd() const { return m_position>=m_samples.size(); }
+    bool isEnd() const { return m_position >= m_samples.size(); }
     void next() { ++m_position; }
 
-    friend std::ostream& operator<<(
-        std::ostream& output_stream, IteratorState const& iterator_state) {
+    friend std::ostream& operator<<(std::ostream& output_stream,
+                                    IteratorState const& iterator_state)
+    {
         return output_stream << "memento state " << iterator_state.m_position << " "
-                             << iterator_state.m_samples.size(); }
+                             << iterator_state.m_samples.size();
+    }
 
 private:
     std::vector<const INode*> m_samples;
@@ -60,15 +62,19 @@ public:
     void pop_state() { m_state_stack.pop(); }
     IteratorState& get_state() { return m_state_stack.top(); }
     bool empty() const { return m_state_stack.empty(); }
-    void reset() { while(!m_state_stack.empty()) m_state_stack.pop(); }
+    void reset()
+    {
+        while (!m_state_stack.empty())
+            m_state_stack.pop();
+    }
     const INode* getCurrent() { return m_state_stack.top().getCurrent(); }
     void next() { m_state_stack.top().next(); }
     size_t size() const { return m_state_stack.size(); }
+
 protected:
-    std::stack<IteratorState > m_state_stack;
+    std::stack<IteratorState> m_state_stack;
 };
 
-
 //! Iterator through INode tree of objects.
 //!
 //! Usage example:
@@ -80,11 +86,10 @@ protected:
 //!     }
 //! @ingroup samples_internal
 
-template <class Strategy>
-class BA_CORE_API_ NodeIterator
+template <class Strategy> class BA_CORE_API_ NodeIterator
 {
 public:
-    NodeIterator(const INode *root);
+    NodeIterator(const INode* root);
     virtual ~NodeIterator() {}
 
     void first();
@@ -92,6 +97,7 @@ public:
     const INode* getCurrent();
     bool isDone() const;
     int depth() const;
+
 protected:
     Strategy m_strategy;
     IteratorMemento m_memento_itor;
@@ -99,37 +105,31 @@ protected:
 };
 
 template <class Strategy>
-inline NodeIterator<Strategy>::NodeIterator(const INode *root)
-    : mp_root(root)
+inline NodeIterator<Strategy>::NodeIterator(const INode* root) : mp_root(root)
 {
 }
 
-template <class Strategy>
-inline void NodeIterator<Strategy>::first()
+template <class Strategy> inline void NodeIterator<Strategy>::first()
 {
     m_memento_itor = m_strategy.first(mp_root);
 }
 
-template <class Strategy>
-inline void NodeIterator<Strategy>::next()
+template <class Strategy> inline void NodeIterator<Strategy>::next()
 {
     m_strategy.next(m_memento_itor);
 }
 
-template <class Strategy>
-inline const INode *NodeIterator<Strategy>::getCurrent()
+template <class Strategy> inline const INode* NodeIterator<Strategy>::getCurrent()
 {
     return m_memento_itor.getCurrent();
 }
 
-template <class Strategy>
-inline bool NodeIterator<Strategy>::isDone() const
+template <class Strategy> inline bool NodeIterator<Strategy>::isDone() const
 {
-    return m_memento_itor.size()==0;
+    return m_memento_itor.size() == 0;
 }
 
-template <class Strategy>
-inline int NodeIterator<Strategy>::depth() const
+template <class Strategy> inline int NodeIterator<Strategy>::depth() const
 {
     return static_cast<int>(m_memento_itor.size());
 }
diff --git a/Core/Parametrization/NodeUtils.cpp b/Core/Parametrization/NodeUtils.cpp
index 62a21823423..e7bd92f6673 100644
--- a/Core/Parametrization/NodeUtils.cpp
+++ b/Core/Parametrization/NodeUtils.cpp
@@ -13,53 +13,57 @@
 // ************************************************************************** //
 
 #include "NodeUtils.h"
-#include "NodeIterator.h"
+#include "Exceptions.h"
+#include "INode.h"
 #include "IterationStrategy.h"
-#include "RealParameter.h"
+#include "NodeIterator.h"
 #include "ParameterPool.h"
-#include "INode.h"
-#include "Exceptions.h"
-#include <functional>
+#include "RealParameter.h"
 #include <algorithm>
+#include <functional>
 #include <iterator>
 #include <sstream>
 
-namespace {
-
-    // Returns string filled with '.'
-    std::string s_indent(int depth) {
-        const int multiplier = 4;
-        return std::string(multiplier*depth, '.');
-    }
+namespace
+{
 
-    // Returns single line string representing pool parameters of given node.
-    std::string poolToString(const INode &node) {
-        std::ostringstream result;
+// Returns string filled with '.'
+std::string s_indent(int depth)
+{
+    const int multiplier = 4;
+    return std::string(multiplier * depth, '.');
+}
 
-        const std::vector<RealParameter*> pars = node.parameterPool()->parameters();
-        if (pars.empty())
-            return {};
+// Returns single line string representing pool parameters of given node.
+std::string poolToString(const INode& node)
+{
+    std::ostringstream result;
 
-        result << " (";
-        size_t index(0);
-        for (auto par : pars) {
-            result << "'" << par->getName() << "':" << par->value();
-            ++index;
-            if (index!=pars.size())
-                result << " ";
-        }
-        result << ")";
+    const std::vector<RealParameter*> pars = node.parameterPool()->parameters();
+    if (pars.empty())
+        return {};
 
-        return result.str();
+    result << " (";
+    size_t index(0);
+    for (auto par : pars) {
+        result << "'" << par->getName() << "':" << par->value();
+        ++index;
+        if (index != pars.size())
+            result << " ";
     }
+    result << ")";
 
-    // Returns a string representing given node.
-    std::string nodeString(const INode& node, int depth) {
-        std::ostringstream result;
-        result << s_indent(depth) << node.displayName() << poolToString(node) << "\n";
-        return result.str();
-    }
+    return result.str();
+}
+
+// Returns a string representing given node.
+std::string nodeString(const INode& node, int depth)
+{
+    std::ostringstream result;
+    result << s_indent(depth) << node.displayName() << poolToString(node) << "\n";
+    return result.str();
 }
+} // namespace
 
 std::string NodeUtils::nodeToString(const INode& node)
 {
@@ -68,8 +72,8 @@ std::string NodeUtils::nodeToString(const INode& node)
     NodeIterator<PreorderStrategy> it(&node);
     it.first();
     while (!it.isDone()) {
-        const INode *child = it.getCurrent();
-        result << nodeString(*child, it.depth()-1);
+        const INode* child = it.getCurrent();
+        result << nodeString(*child, it.depth() - 1);
         it.next();
     }
 
diff --git a/Core/Parametrization/NodeUtils.h b/Core/Parametrization/NodeUtils.h
index aa3fe9655e1..c3ec2625f00 100644
--- a/Core/Parametrization/NodeUtils.h
+++ b/Core/Parametrization/NodeUtils.h
@@ -16,18 +16,19 @@
 #define NODEUTILS_H
 
 #include "WinDllMacros.h"
-#include<string>
+#include <string>
 
 class INode;
 
-namespace NodeUtils {
+namespace NodeUtils
+{
 
-    //! Returns multiline string representing tree structure starting from given node.
-    BA_CORE_API_ std::string nodeToString(const INode& node);
+//! Returns multiline string representing tree structure starting from given node.
+BA_CORE_API_ std::string nodeToString(const INode& node);
 
-    //! Returns path composed of node's displayName, with respect to root node
-    BA_CORE_API_ std::string nodePath(const INode& node, const INode* root = nullptr);
+//! Returns path composed of node's displayName, with respect to root node
+BA_CORE_API_ std::string nodePath(const INode& node, const INode* root = nullptr);
 
-} //namespace NodeUtils
+} // namespace NodeUtils
 
 #endif // NODEUTILS_H
diff --git a/Core/Parametrization/ParameterDistribution.cpp b/Core/Parametrization/ParameterDistribution.cpp
index 9d513daeb49..257c5b8b14f 100644
--- a/Core/Parametrization/ParameterDistribution.cpp
+++ b/Core/Parametrization/ParameterDistribution.cpp
@@ -13,77 +13,62 @@
 // ************************************************************************** //
 
 #include "ParameterDistribution.h"
-#include "ParameterSample.h"
 #include "Distributions.h"
 #include "Exceptions.h"
+#include "ParameterSample.h"
 
-ParameterDistribution::ParameterDistribution(
-    const std::string& par_name, const IDistribution1D& distribution, size_t nbr_samples,
-    double sigma_factor, const RealLimits &limits)
-    : IParameterized("ParameterDistribution")
-    , m_name(par_name)
-    , m_nbr_samples(nbr_samples)
-    , m_sigma_factor(sigma_factor)
-    , m_limits(limits)
-    , m_xmin(1.0)
-    , m_xmax(-1.0)
+ParameterDistribution::ParameterDistribution(const std::string& par_name,
+                                             const IDistribution1D& distribution,
+                                             size_t nbr_samples, double sigma_factor,
+                                             const RealLimits& limits)
+    : IParameterized("ParameterDistribution"), m_name(par_name), m_nbr_samples(nbr_samples),
+      m_sigma_factor(sigma_factor), m_limits(limits), m_xmin(1.0), m_xmax(-1.0)
 {
     mP_distribution.reset(distribution.clone());
     if (m_sigma_factor < 0.0)
         throw Exceptions::RuntimeErrorException(
-                "ParameterDistribution::ParameterDistribution() -> Error."
-                "sigma factor cannot be negative");
-    if(nbr_samples == 0)
+            "ParameterDistribution::ParameterDistribution() -> Error."
+            "sigma factor cannot be negative");
+    if (nbr_samples == 0)
         throw Exceptions::RuntimeErrorException(
             "ParameterDistribution::ParameterDistribution() -> Error."
             "Number of samples can't be zero.");
 }
 
-ParameterDistribution::ParameterDistribution(
-    const std::string& par_name, const IDistribution1D& distribution, size_t nbr_samples,
-    double xmin, double xmax)
-    : IParameterized("ParameterDistribution")
-    , m_name(par_name)
-    , m_nbr_samples(nbr_samples)
-    , m_sigma_factor(0.0)
-    , m_xmin(xmin)
-    , m_xmax(xmax)
+ParameterDistribution::ParameterDistribution(const std::string& par_name,
+                                             const IDistribution1D& distribution,
+                                             size_t nbr_samples, double xmin, double xmax)
+    : IParameterized("ParameterDistribution"), m_name(par_name), m_nbr_samples(nbr_samples),
+      m_sigma_factor(0.0), m_xmin(xmin), m_xmax(xmax)
 {
     mP_distribution.reset(distribution.clone());
     if (m_sigma_factor < 0.0) {
         throw Exceptions::RuntimeErrorException(
-                "ParameterDistribution::ParameterDistribution() -> Error."
-                "sigma factor cannot be negative");
+            "ParameterDistribution::ParameterDistribution() -> Error."
+            "sigma factor cannot be negative");
     }
-    if(nbr_samples == 0) {
+    if (nbr_samples == 0) {
         throw Exceptions::RuntimeErrorException(
-                    "ParameterDistribution::ParameterDistribution() -> Error."
-                    "Number of samples can't be zero.");
+            "ParameterDistribution::ParameterDistribution() -> Error."
+            "Number of samples can't be zero.");
     }
-    if(xmin >=xmax) {
+    if (xmin >= xmax) {
         throw Exceptions::RuntimeErrorException(
-                    "ParameterDistribution::ParameterDistribution() -> Error."
-                    "xmin>=xmax");
+            "ParameterDistribution::ParameterDistribution() -> Error."
+            "xmin>=xmax");
     }
 }
 
-
 ParameterDistribution::ParameterDistribution(const ParameterDistribution& other)
-: IParameterized("ParameterDistribution")
-    , m_name(other.m_name)
-    , m_nbr_samples(other.m_nbr_samples)
-    , m_sigma_factor(other.m_sigma_factor)
-    , m_linked_par_names(other.m_linked_par_names)
-    , m_limits(other.m_limits)
-    , m_xmin(other.m_xmin)
-    , m_xmax(other.m_xmax)
+    : IParameterized("ParameterDistribution"), m_name(other.m_name),
+      m_nbr_samples(other.m_nbr_samples), m_sigma_factor(other.m_sigma_factor),
+      m_linked_par_names(other.m_linked_par_names), m_limits(other.m_limits), m_xmin(other.m_xmin),
+      m_xmax(other.m_xmax)
 {
     mP_distribution.reset(other.mP_distribution->clone());
 }
 
-ParameterDistribution::~ParameterDistribution()
-{
-}
+ParameterDistribution::~ParameterDistribution() {}
 
 ParameterDistribution& ParameterDistribution::operator=(const ParameterDistribution& other)
 {
@@ -115,7 +100,7 @@ size_t ParameterDistribution::getNbrSamples() const
 
 std::vector<ParameterSample> ParameterDistribution::generateSamples() const
 {
-    if(m_xmin < m_xmax)
+    if (m_xmin < m_xmax)
         return mP_distribution->equidistantSamplesInRange(m_nbr_samples, m_xmin, m_xmax);
     else
         return mP_distribution->equidistantSamples(m_nbr_samples, m_sigma_factor, m_limits);
diff --git a/Core/Parametrization/ParameterDistribution.h b/Core/Parametrization/ParameterDistribution.h
index 39224882d2d..8d3c1cd8c4e 100644
--- a/Core/Parametrization/ParameterDistribution.h
+++ b/Core/Parametrization/ParameterDistribution.h
@@ -16,8 +16,8 @@
 #define PARAMETERDISTRIBUTION_H
 
 #include "IParameterized.h"
-#include "RealLimits.h"
 #include "ParameterSample.h"
+#include "RealLimits.h"
 #include <memory>
 #include <vector>
 
@@ -26,13 +26,11 @@ class IDistribution1D;
 class BA_CORE_API_ ParameterDistribution : public IParameterized
 {
 public:
-    ParameterDistribution(const std::string& par_name,
-                          const IDistribution1D& distribution,
-                          size_t nbr_samples, double sigma_factor=0.0,
+    ParameterDistribution(const std::string& par_name, const IDistribution1D& distribution,
+                          size_t nbr_samples, double sigma_factor = 0.0,
                           const RealLimits& limits = RealLimits());
 
-    ParameterDistribution(const std::string& par_name,
-                          const IDistribution1D& distribution,
+    ParameterDistribution(const std::string& par_name, const IDistribution1D& distribution,
                           size_t nbr_samples, double xmin, double xmax);
 
     ParameterDistribution(const ParameterDistribution& other);
diff --git a/Core/Parametrization/ParameterPattern.h b/Core/Parametrization/ParameterPattern.h
index 3d42e2d9b27..4ea88b3ae1c 100644
--- a/Core/Parametrization/ParameterPattern.h
+++ b/Core/Parametrization/ParameterPattern.h
@@ -25,7 +25,7 @@ class BA_CORE_API_ ParameterPattern
 {
 public:
     ParameterPattern() {}
-    ParameterPattern(std::string root_object) : m_pattern ( "/" + root_object ) {}
+    ParameterPattern(std::string root_object) : m_pattern("/" + root_object) {}
 
     ParameterPattern& beginsWith(std::string start_type);
     ParameterPattern& add(std::string object_type);
diff --git a/Core/Parametrization/ParameterPool.cpp b/Core/Parametrization/ParameterPool.cpp
index 39ab6799cab..fbeab5b2f01 100644
--- a/Core/Parametrization/ParameterPool.cpp
+++ b/Core/Parametrization/ParameterPool.cpp
@@ -22,12 +22,10 @@
 #include <iostream>
 #include <sstream>
 #include <stdexcept>
-#include <algorithm>
 
 //! Constructs an empty parameter pool.
 
-ParameterPool::ParameterPool()
-{}
+ParameterPool::ParameterPool() {}
 
 ParameterPool::~ParameterPool()
 {
@@ -39,7 +37,7 @@ ParameterPool::~ParameterPool()
 ParameterPool* ParameterPool::clone() const
 {
     auto result = new ParameterPool();
-    for(auto par : m_params)
+    for (auto par : m_params)
         result->addParameter(par->clone());
     return result;
 }
@@ -48,7 +46,7 @@ ParameterPool* ParameterPool::clone() const
 
 void ParameterPool::clear()
 {
-    for(auto* par: m_params)
+    for (auto* par : m_params)
         delete par;
     m_params.clear();
 }
@@ -60,10 +58,12 @@ void ParameterPool::clear()
 
 RealParameter& ParameterPool::addParameter(RealParameter* newPar)
 {
-    for (const auto* par: m_params )
-        if( par->getName()==newPar->getName() )
+    for (const auto* par : m_params)
+        if (par->getName() == newPar->getName())
             throw Exceptions::RuntimeErrorException("ParameterPool::addParameter() -> Error. "
-                "Parameter '"+newPar->getName()+"' is already registered");
+                                                    "Parameter '"
+                                                    + newPar->getName()
+                                                    + "' is already registered");
     m_params.push_back(newPar);
     return *newPar;
 }
@@ -72,9 +72,9 @@ RealParameter& ParameterPool::addParameter(RealParameter* newPar)
 
 void ParameterPool::copyToExternalPool(const std::string& prefix, ParameterPool* other_pool) const
 {
-    for (const auto* par: m_params) {
-        RealParameter* new_par = par->clone( prefix + par->getName() );
-        other_pool->addParameter( new_par );
+    for (const auto* par : m_params) {
+        RealParameter* new_par = par->clone(prefix + par->getName());
+        other_pool->addParameter(new_par);
     }
 }
 
@@ -82,8 +82,8 @@ void ParameterPool::copyToExternalPool(const std::string& prefix, ParameterPool*
 
 const RealParameter* ParameterPool::parameter(const std::string& name) const
 {
-    for (const auto* par: m_params )
-        if( par->getName()==name )
+    for (const auto* par : m_params)
+        if (par->getName() == name)
             return par;
 
     return nullptr;
@@ -93,8 +93,7 @@ const RealParameter* ParameterPool::parameter(const std::string& name) const
 
 RealParameter* ParameterPool::parameter(const std::string& name)
 {
-    return const_cast<RealParameter *>(
-                static_cast<const ParameterPool *>(this)->parameter(name));
+    return const_cast<RealParameter*>(static_cast<const ParameterPool*>(this)->parameter(name));
 }
 
 //! Returns nonempty vector of parameters that match the _pattern_ ('*' allowed), or throws.
@@ -129,7 +128,7 @@ RealParameter* ParameterPool::getUniqueMatch(const std::string& pattern) const
 
 void ParameterPool::setParameterValue(const std::string& name, double value)
 {
-    if(RealParameter* par = parameter(name)) {
+    if (RealParameter* par = parameter(name)) {
         try {
             par->setValue(value);
         } catch (const std::runtime_error& e) {
@@ -137,7 +136,8 @@ void ParameterPool::setParameterValue(const std::string& name, double value)
         }
     } else {
         std::ostringstream message;
-        message << "ParameterPool::getParameter() -> Warning. No parameter with name '"+name+"'\n"
+        message << "ParameterPool::getParameter() -> Warning. No parameter with name '" + name
+                       + "'\n"
                 << "Available parameters:" << *this;
         throw Exceptions::RuntimeErrorException(message.str());
     }
@@ -166,14 +166,14 @@ int ParameterPool::setMatchedParametersValue(const std::string& pattern, double
 void ParameterPool::setUniqueMatchValue(const std::string& pattern, double value)
 {
     if (setMatchedParametersValue(pattern, value) != 1)
-        throw  Exceptions::RuntimeErrorException(
-            "ParameterPool::setUniqueMatchValue: pattern '"+pattern+"' is not unique");
+        throw Exceptions::RuntimeErrorException("ParameterPool::setUniqueMatchValue: pattern '"
+                                                + pattern + "' is not unique");
 }
 
 std::vector<std::string> ParameterPool::parameterNames() const
 {
     std::vector<std::string> result;
-    for (const auto* par: m_params)
+    for (const auto* par : m_params)
         result.push_back(par->getName());
     return result;
 }
@@ -182,7 +182,7 @@ std::vector<std::string> ParameterPool::parameterNames() const
 
 void ParameterPool::removeParameter(const std::string& name)
 {
-    if(RealParameter *par = parameter(name)) {
+    if (RealParameter* par = parameter(name)) {
         m_params.erase(std::remove(m_params.begin(), m_params.end(), par), m_params.end());
         delete par;
     }
@@ -195,14 +195,14 @@ const RealParameter* ParameterPool::operator[](size_t index) const
 
 RealParameter* ParameterPool::operator[](size_t index)
 {
-    return const_cast<RealParameter*>(static_cast<const ParameterPool*>(this)
-                                      ->operator[](index));
+    return const_cast<RealParameter*>(static_cast<const ParameterPool*>(this)->operator[](index));
 }
 
 void ParameterPool::print(std::ostream& ostr) const
 {
-    for (const auto* par: m_params)
-        ostr << "'" << par->getName() << "'" << ":" << par->value() << "\n";
+    for (const auto* par : m_params)
+        ostr << "'" << par->getName() << "'"
+             << ":" << par->value() << "\n";
 }
 
 //! reports error while finding parameters matching given name.
@@ -211,8 +211,8 @@ void ParameterPool::report_find_matched_parameters_error(const std::string& patt
     std::ostringstream ostr;
     ostr << "ParameterPool::find_matched_parameters_error() -> Error! ";
     ostr << "No parameters matching  pattern '" << pattern
-       << "' have been found. Existing keys are:" << std::endl;
-    for (const auto* par: m_params)
+         << "' have been found. Existing keys are:" << std::endl;
+    for (const auto* par : m_params)
         ostr << "'" << par->getName() << "'\n";
     throw Exceptions::RuntimeErrorException(ostr.str());
 }
diff --git a/Core/Parametrization/ParameterPool.h b/Core/Parametrization/ParameterPool.h
index c059d35a769..8f41056d2c1 100644
--- a/Core/Parametrization/ParameterPool.h
+++ b/Core/Parametrization/ParameterPool.h
@@ -60,8 +60,11 @@ public:
 
     std::vector<std::string> parameterNames() const;
 
-    friend std::ostream& operator<<(std::ostream& ostr, const ParameterPool& obj) {
-        obj.print(ostr); return ostr; }
+    friend std::ostream& operator<<(std::ostream& ostr, const ParameterPool& obj)
+    {
+        obj.print(ostr);
+        return ostr;
+    }
 
     void removeParameter(const std::string& name);
 
@@ -73,7 +76,7 @@ private:
 #ifndef SWIG
     [[noreturn]] void report_find_matched_parameters_error(const std::string& pattern) const;
     [[noreturn]] void report_set_value_error(const std::string& parname, double value,
-                                             std::string message={}) const;
+                                             std::string message = {}) const;
 #endif
     size_t check_index(size_t index) const;
 
diff --git a/Core/Parametrization/ParameterSample.h b/Core/Parametrization/ParameterSample.h
index be936b631f5..a9eb99d13cf 100644
--- a/Core/Parametrization/ParameterSample.h
+++ b/Core/Parametrization/ParameterSample.h
@@ -21,7 +21,7 @@
 class ParameterSample
 {
 public:
-    ParameterSample(double _value=0., double _weight=1.) : value(_value), weight(_weight) {}
+    ParameterSample(double _value = 0., double _weight = 1.) : value(_value), weight(_weight) {}
     double value;
     double weight;
 };
diff --git a/Core/Parametrization/ParameterUtils.cpp b/Core/Parametrization/ParameterUtils.cpp
index 8e18ca0d1af..59ce8a38b9e 100644
--- a/Core/Parametrization/ParameterUtils.cpp
+++ b/Core/Parametrization/ParameterUtils.cpp
@@ -13,27 +13,23 @@
 // ************************************************************************** //
 
 #include "ParameterUtils.h"
-#include "ParameterDistribution.h"
 #include "BornAgainNamespace.h"
-#include "ParticleDistribution.h"
+#include "ParameterDistribution.h"
 #include "ParameterPool.h"
 #include "Particle.h"
+#include "ParticleDistribution.h"
 #include "RealParameter.h"
 
-namespace {
+namespace
+{
 //! Returns list of all angle related parameters used in Core library.
-std::vector<std::string> angleRelatedParameters() {
-    std::vector<std::string> result {
-        BornAgain::Inclination,
-        BornAgain::Azimuth,
-        BornAgain::Alpha,
-        BornAgain::Beta,
-        BornAgain::Gamma,
-        BornAgain::Angle
-    };
+std::vector<std::string> angleRelatedParameters()
+{
+    std::vector<std::string> result{BornAgain::Inclination, BornAgain::Azimuth, BornAgain::Alpha,
+                                    BornAgain::Beta,        BornAgain::Gamma,   BornAgain::Angle};
     return result;
 }
-}
+} // namespace
 
 bool ParameterUtils::isAngleRelated(const std::string& par_name)
 {
@@ -55,6 +51,6 @@ std::string ParameterUtils::mainParUnits(const ParticleDistribution& distr)
 std::string ParameterUtils::poolParameterUnits(const IParameterized& node,
                                                const std::string& parName)
 {
-    std::unique_ptr<ParameterPool> pool {node.createParameterTree()};
+    std::unique_ptr<ParameterPool> pool{node.createParameterTree()};
     return pool->getUniqueMatch(parName)->unit();
 }
diff --git a/Core/Parametrization/ParameterUtils.h b/Core/Parametrization/ParameterUtils.h
index 51f6091054d..ffbf55c464f 100644
--- a/Core/Parametrization/ParameterUtils.h
+++ b/Core/Parametrization/ParameterUtils.h
@@ -34,6 +34,6 @@ BA_CORE_API_ std::string mainParUnits(const ParticleDistribution& distr);
 //! Returns units of main parameter.
 BA_CORE_API_ std::string poolParameterUnits(const IParameterized& node, const std::string& parName);
 
-}
+} // namespace ParameterUtils
 
 #endif // PARAMETERPATTERN_H
diff --git a/Core/Parametrization/RangedDistributions.cpp b/Core/Parametrization/RangedDistributions.cpp
index 4109afc24fd..265cef9f793 100644
--- a/Core/Parametrization/RangedDistributions.cpp
+++ b/Core/Parametrization/RangedDistributions.cpp
@@ -18,35 +18,29 @@
 #include "PythonFormatting.h"
 #include <limits>
 
-namespace {
-template<class T>
-std::unique_ptr<T> makeCopy(const T& item);
+namespace
+{
+template <class T> std::unique_ptr<T> makeCopy(const T& item);
 
 const double gate_stddev_factor = 2.0 * std::sqrt(3.0);
-}
+} // namespace
 
 RangedDistribution::RangedDistribution()
-    : m_n_samples(5)
-    , m_sigma_factor(2.0)
-    , m_limits(RealLimits::limitless())
+    : m_n_samples(5), m_sigma_factor(2.0), m_limits(RealLimits::limitless())
 {
     checkInitialization();
 }
 
 RangedDistribution::RangedDistribution(size_t n_samples, double sigma_factor,
                                        const RealLimits& limits)
-    : m_n_samples(n_samples)
-    , m_sigma_factor(sigma_factor)
-    , m_limits(limits)
+    : m_n_samples(n_samples), m_sigma_factor(sigma_factor), m_limits(limits)
 {
     checkInitialization();
 }
 
 RangedDistribution::RangedDistribution(size_t n_samples, double sigma_factor, double min,
                                        double max)
-    : m_n_samples(n_samples)
-    , m_sigma_factor(sigma_factor)
-    , m_limits(RealLimits::limited(min, max))
+    : m_n_samples(n_samples), m_sigma_factor(sigma_factor), m_limits(RealLimits::limited(min, max))
 {
     checkInitialization();
 }
@@ -144,8 +138,8 @@ std::string RangedDistributionGate::name() const
     return "ba.RangedDistributionGate";
 }
 
-std::unique_ptr<IDistribution1D>
-RangedDistributionGate::distribution_impl(double mean, double stddev) const
+std::unique_ptr<IDistribution1D> RangedDistributionGate::distribution_impl(double mean,
+                                                                           double stddev) const
 {
     const double x_min = mean - gate_stddev_factor * stddev;
     const double x_max = mean + gate_stddev_factor * stddev;
@@ -176,8 +170,8 @@ std::string RangedDistributionLorentz::name() const
     return "ba.RangedDistributionLorentz";
 }
 
-std::unique_ptr<IDistribution1D>
-RangedDistributionLorentz::distribution_impl(double median, double hwhm) const
+std::unique_ptr<IDistribution1D> RangedDistributionLorentz::distribution_impl(double median,
+                                                                              double hwhm) const
 {
     return std::make_unique<DistributionLorentz>(median, hwhm);
 }
@@ -206,8 +200,8 @@ std::string RangedDistributionGaussian::name() const
     return "ba.RangedDistributionGaussian";
 }
 
-std::unique_ptr<IDistribution1D>
-RangedDistributionGaussian::distribution_impl(double mean, double stddev) const
+std::unique_ptr<IDistribution1D> RangedDistributionGaussian::distribution_impl(double mean,
+                                                                               double stddev) const
 {
     return std::make_unique<DistributionGaussian>(mean, stddev);
 }
@@ -236,8 +230,8 @@ std::string RangedDistributionLogNormal::name() const
     return "ba.RangedDistributionLogNormal";
 }
 
-std::unique_ptr<IDistribution1D>
-RangedDistributionLogNormal::distribution_impl(double mean, double stddev) const
+std::unique_ptr<IDistribution1D> RangedDistributionLogNormal::distribution_impl(double mean,
+                                                                                double stddev) const
 {
     const double mean_2 = mean * mean;
     if (mean_2 <= std::numeric_limits<double>::min())
@@ -245,7 +239,7 @@ RangedDistributionLogNormal::distribution_impl(double mean, double stddev) const
                                  "is less or indistinguishable from zero.");
 
     const double scale = std::sqrt(std::log(stddev * stddev / mean_2 + 1.0));
-    const double median = mean * std::exp(- scale * scale / 2.0);
+    const double median = mean * std::exp(-scale * scale / 2.0);
     return std::make_unique<DistributionLogNormal>(median, scale);
 }
 
@@ -273,16 +267,16 @@ std::string RangedDistributionCosine::name() const
     return "ba.RangedDistributionCosine";
 }
 
-std::unique_ptr<IDistribution1D>
-RangedDistributionCosine::distribution_impl(double mean, double stddev) const
+std::unique_ptr<IDistribution1D> RangedDistributionCosine::distribution_impl(double mean,
+                                                                             double stddev) const
 {
     return std::make_unique<DistributionCosine>(mean, stddev);
 }
 
-namespace {
-template<class T>
-std::unique_ptr<T> makeCopy(const T& item)
+namespace
+{
+template <class T> std::unique_ptr<T> makeCopy(const T& item)
 {
     return std::make_unique<T>(item.nSamples(), item.sigmaFactor(), item.limits());
 }
-}
+} // namespace
diff --git a/Core/Parametrization/RangedDistributions.h b/Core/Parametrization/RangedDistributions.h
index 70da5b0ad42..e122cebb128 100644
--- a/Core/Parametrization/RangedDistributions.h
+++ b/Core/Parametrization/RangedDistributions.h
@@ -117,7 +117,6 @@ protected:
     std::unique_ptr<IDistribution1D> distribution_impl(double mean, double stddev) const override;
 };
 
-
 //! Lorentz distribution with median and hwhm.
 //! @ingroup paramDistribution
 
@@ -143,11 +142,10 @@ protected:
     std::unique_ptr<IDistribution1D> distribution_impl(double median, double hwhm) const override;
 };
 
-
 //! Gaussian distribution with standard deviation std_dev.
 //! @ingroup paramDistribution
 
-class BA_CORE_API_ RangedDistributionGaussian: public RangedDistribution
+class BA_CORE_API_ RangedDistributionGaussian : public RangedDistribution
 {
 public:
     RangedDistributionGaussian();
@@ -169,11 +167,10 @@ protected:
     std::unique_ptr<IDistribution1D> distribution_impl(double mean, double stddev) const override;
 };
 
-
 //! Log-normal distribution.
 //! @ingroup paramDistribution
 
-class BA_CORE_API_ RangedDistributionLogNormal: public RangedDistribution
+class BA_CORE_API_ RangedDistributionLogNormal : public RangedDistribution
 {
 public:
     RangedDistributionLogNormal();
@@ -195,11 +192,10 @@ protected:
     std::unique_ptr<IDistribution1D> distribution_impl(double mean, double stddev) const override;
 };
 
-
 //! Cosine distribution.
 //! @ingroup paramDistribution
 
-class BA_CORE_API_ RangedDistributionCosine: public RangedDistribution
+class BA_CORE_API_ RangedDistributionCosine : public RangedDistribution
 {
 public:
     RangedDistributionCosine();
@@ -221,7 +217,6 @@ protected:
     std::unique_ptr<IDistribution1D> distribution_impl(double mean, double stddev) const override;
 };
 
-
 inline std::ostream& operator<<(std::ostream& os, const RangedDistribution& distribution)
 {
     return os << distribution.print();
diff --git a/Core/Parametrization/RealParameter.cpp b/Core/Parametrization/RealParameter.cpp
index 3f0a698487b..ea000ff7d8b 100644
--- a/Core/Parametrization/RealParameter.cpp
+++ b/Core/Parametrization/RealParameter.cpp
@@ -31,8 +31,8 @@ RealParameter::RealParameter(const std::string& name, double* par, const std::st
 
 RealParameter* RealParameter::clone(const std::string& new_name) const
 {
-    auto* ret = new RealParameter(
-        new_name!="" ? new_name : getName(), m_data, m_parent_name, m_onChange, m_limits );
+    auto* ret = new RealParameter(new_name != "" ? new_name : getName(), m_data, m_parent_name,
+                                  m_onChange, m_limits);
     ret->setUnit(unit());
     return ret;
 }
@@ -79,27 +79,27 @@ RealLimits RealParameter::limits() const
 
 RealParameter& RealParameter::setLimited(double lower, double upper)
 {
-    setLimits( RealLimits::limited(lower, upper) );
+    setLimits(RealLimits::limited(lower, upper));
     return *this;
 }
 
 RealParameter& RealParameter::setPositive()
 {
-    setLimits( RealLimits::positive() );
+    setLimits(RealLimits::positive());
     return *this;
 }
 
 RealParameter& RealParameter::setNonnegative()
 {
-    setLimits( RealLimits::nonnegative() );
+    setLimits(RealLimits::nonnegative());
     return *this;
 }
 
 RealParameter& RealParameter::setUnit(const std::string& name)
 {
-    if (! (name==BornAgain::UnitsNone || name == BornAgain::UnitsNm || name == BornAgain::UnitsRad
-           || name == BornAgain::UnitsNm2) )
-        throw std::runtime_error("RealParameter::setUnit() -> Error. Unexpected unit name "+name);
+    if (!(name == BornAgain::UnitsNone || name == BornAgain::UnitsNm || name == BornAgain::UnitsRad
+          || name == BornAgain::UnitsNm2))
+        throw std::runtime_error("RealParameter::setUnit() -> Error. Unexpected unit name " + name);
 
     m_unit.setUnit(name);
     return *this;
@@ -109,4 +109,3 @@ std::string RealParameter::unit() const
 {
     return m_unit.getName();
 }
-
diff --git a/Core/Parametrization/RealParameter.h b/Core/Parametrization/RealParameter.h
index 55f1d779d5c..43077f10efa 100644
--- a/Core/Parametrization/RealParameter.h
+++ b/Core/Parametrization/RealParameter.h
@@ -15,8 +15,8 @@
 #ifndef REALPARAMETER_H
 #define REALPARAMETER_H
 
-#include "IParameter.h"
 #include "Attributes.h"
+#include "IParameter.h"
 #include "RealLimits.h"
 #include "Unit.h"
 #include <string>
@@ -28,15 +28,16 @@ class ParameterPool;
 //! this class holds Limits, Attributes (currently only fixed or not), and a Unit.
 //! @ingroup tools_internal
 
-class BA_CORE_API_ RealParameter : public IParameter<double> {
+class BA_CORE_API_ RealParameter : public IParameter<double>
+{
 public:
     RealParameter(const std::string& name, double* par,
                   const std::string& parent_name = std::string(),
-                  const std::function<void()>& onChange=std::function<void()>(),
-                  const RealLimits& limits=RealLimits::limitless(),
-                  const Attributes& attr=Attributes::free());
+                  const std::function<void()>& onChange = std::function<void()>(),
+                  const RealLimits& limits = RealLimits::limitless(),
+                  const Attributes& attr = Attributes::free());
 
-    RealParameter* clone(const std::string& new_name="" ) const;
+    RealParameter* clone(const std::string& new_name = "") const;
 
     //! Sets value of wrapped parameter and emit signal
     void setValue(double value);
diff --git a/Core/Parametrization/SimulationOptions.cpp b/Core/Parametrization/SimulationOptions.cpp
index 7bd22c1ff51..d6a87e0549c 100644
--- a/Core/Parametrization/SimulationOptions.cpp
+++ b/Core/Parametrization/SimulationOptions.cpp
@@ -17,17 +17,14 @@
 #include <thread>
 
 SimulationOptions::SimulationOptions()
-    : m_mc_integration(false)
-    , m_include_specular(false)
-    , m_use_avg_materials(false)
-    , m_mc_points(1)
+    : m_mc_integration(false), m_include_specular(false), m_use_avg_materials(false), m_mc_points(1)
 {
     m_thread_info.n_threads = getHardwareConcurrency();
 }
 
 bool SimulationOptions::isIntegrate() const
 {
-    return m_mc_integration && m_mc_points>1;
+    return m_mc_integration && m_mc_points > 1;
 }
 
 void SimulationOptions::setMonteCarloIntegration(bool flag, size_t mc_points)
diff --git a/Core/Parametrization/SimulationOptions.h b/Core/Parametrization/SimulationOptions.h
index 9189559a27a..fe1108a3041 100644
--- a/Core/Parametrization/SimulationOptions.h
+++ b/Core/Parametrization/SimulationOptions.h
@@ -35,7 +35,7 @@ public:
     //! @brief Enables/disables MonetCarlo integration
     //! @param flag If true, MonteCarlo integration will be used, otherwise analytical calculations
     //! @param mc_points Number of points for MonteCarlo integrator
-    void setMonteCarloIntegration(bool flag = true, size_t mc_points=50);
+    void setMonteCarloIntegration(bool flag = true, size_t mc_points = 50);
 
     //! @brief Sets number of threads to use during the simulation (0 - take the default value from
     //! the hardware)
@@ -71,5 +71,4 @@ private:
     ThreadInfo m_thread_info;
 };
 
-
 #endif // SIMULATIONOPTIONS_H
diff --git a/Core/Parametrization/ThreadInfo.h b/Core/Parametrization/ThreadInfo.h
index 11cb8c0d38a..ea8bd386092 100644
--- a/Core/Parametrization/ThreadInfo.h
+++ b/Core/Parametrization/ThreadInfo.h
@@ -20,19 +20,13 @@
 //! Information to run simulation with dedicated number of threads.
 //! @ingroup simulation
 
-struct BA_CORE_API_ ThreadInfo
-{
+struct BA_CORE_API_ ThreadInfo {
     ThreadInfo();
     unsigned n_threads;
     unsigned n_batches;
     unsigned current_batch;
 };
 
-inline ThreadInfo::ThreadInfo()
-    : n_threads(0)
-    , n_batches(1)
-    , current_batch(0)
-{
-}
+inline ThreadInfo::ThreadInfo() : n_threads(0), n_batches(1), current_batch(0) {}
 
 #endif // THREADINFO_H
diff --git a/Core/Parametrization/Unit.h b/Core/Parametrization/Unit.h
index a3bb927b4d2..24fa9378089 100644
--- a/Core/Parametrization/Unit.h
+++ b/Core/Parametrization/Unit.h
@@ -23,7 +23,7 @@
 class Unit : public INamed
 {
 public:
-    explicit Unit(const std::string& name="") { setUnit(name); }
+    explicit Unit(const std::string& name = "") { setUnit(name); }
     void setUnit(const std::string& name);
 };
 
diff --git a/Core/Parametrization/Units.h b/Core/Parametrization/Units.h
index e82add3cc8a..ac160a33b85 100644
--- a/Core/Parametrization/Units.h
+++ b/Core/Parametrization/Units.h
@@ -17,36 +17,43 @@
 
 //! Constants and functions for physical unit conversions.
 
-namespace Units {
+namespace Units
+{
 
 // Length
-static const double nanometer   = 1.;
-static const double angstrom    = 1.e-1*nanometer;
-static const double micrometer  = 1.e+3*nanometer;
-static const double millimeter  = 1.e+6*nanometer;
-static const double meter       = 1.e+9*nanometer;
+static const double nanometer = 1.;
+static const double angstrom = 1.e-1 * nanometer;
+static const double micrometer = 1.e+3 * nanometer;
+static const double millimeter = 1.e+6 * nanometer;
+static const double meter = 1.e+9 * nanometer;
 
 // Symbols for length
-static const double nm  = nanometer;
+static const double nm = nanometer;
 
 // Area (cross-section)
 static const double nm2 = nanometer * nanometer;
 static const double barn = nanometer * nanometer * 1e-10;
 
 // Angle
-static const double radian      = 1.;
-static const double milliradian = 1.e-3*radian;
-static const double degree = (3.1415926535897932/180.0)*radian;
+static const double radian = 1.;
+static const double milliradian = 1.e-3 * radian;
+static const double degree = (3.1415926535897932 / 180.0) * radian;
 static const double steradian = 1.;
 
-inline double rad2deg(double angle) {return angle/degree; }
-inline double deg2rad(double angle) {return angle*degree; }
+inline double rad2deg(double angle)
+{
+    return angle / degree;
+}
+inline double deg2rad(double angle)
+{
+    return angle * degree;
+}
 
 // Symbols for (solid) angle
-static const double rad  = radian;
+static const double rad = radian;
 static const double mrad = milliradian;
-static const double sr   = steradian;
-static const double deg  = degree;
+static const double sr = steradian;
+static const double deg = degree;
 
 // Magnetic field
 static const double tesla = 1.;
diff --git a/Core/Particle/Crystal.h b/Core/Particle/Crystal.h
index c8f59248407..30a9f80cb45 100644
--- a/Core/Particle/Crystal.h
+++ b/Core/Particle/Crystal.h
@@ -44,6 +44,7 @@ public:
     void setPositionVariance(double position_variance) { m_position_variance = position_variance; }
 
     std::vector<const INode*> getChildren() const override final;
+
 private:
     Crystal(IParticle* p_lattice_basis, const Lattice& lattice);
 
diff --git a/Core/Particle/FormFactorCoreShell.cpp b/Core/Particle/FormFactorCoreShell.cpp
index b70f1876b53..60290a73996 100644
--- a/Core/Particle/FormFactorCoreShell.cpp
+++ b/Core/Particle/FormFactorCoreShell.cpp
@@ -15,18 +15,15 @@
 #include "FormFactorCoreShell.h"
 #include "BornAgainNamespace.h"
 
-
 FormFactorCoreShell::FormFactorCoreShell(IFormFactor* core, IFormFactor* shell)
-    : mP_core(core)
-    , mP_shell(shell)
+    : mP_core(core), mP_shell(shell)
 {
     setName(BornAgain::FormFactorCoreShellType);
 }
 
-FormFactorCoreShell::~FormFactorCoreShell()
-{}
+FormFactorCoreShell::~FormFactorCoreShell() {}
 
-FormFactorCoreShell*FormFactorCoreShell::clone() const
+FormFactorCoreShell* FormFactorCoreShell::clone() const
 {
     return new FormFactorCoreShell(mP_core->clone(), mP_shell->clone());
 }
diff --git a/Core/Particle/FormFactorCoreShell.h b/Core/Particle/FormFactorCoreShell.h
index 7c2795f3543..51df6228f7d 100644
--- a/Core/Particle/FormFactorCoreShell.h
+++ b/Core/Particle/FormFactorCoreShell.h
@@ -33,7 +33,7 @@ public:
 
     FormFactorCoreShell* clone() const override final;
 
-    void accept(INodeVisitor* visitor) const override  final { visitor->visit(this); }
+    void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     double radialExtension() const override final;
 
diff --git a/Core/Particle/FormFactorCrystal.cpp b/Core/Particle/FormFactorCrystal.cpp
index 7507f742107..1095df05490 100644
--- a/Core/Particle/FormFactorCrystal.cpp
+++ b/Core/Particle/FormFactorCrystal.cpp
@@ -20,10 +20,8 @@
 
 FormFactorCrystal::FormFactorCrystal(const Lattice& lattice, const IFormFactor& basis_form_factor,
                                      const IFormFactor& meso_form_factor, double position_variance)
-    : m_lattice(lattice),
-      mp_basis_form_factor(basis_form_factor.clone()),
-      mp_meso_form_factor(meso_form_factor.clone()),
-      m_position_variance(position_variance)
+    : m_lattice(lattice), mp_basis_form_factor(basis_form_factor.clone()),
+      mp_meso_form_factor(meso_form_factor.clone()), m_position_variance(position_variance)
 {
     setName(BornAgain::FormFactorCrystalType);
     calculateLargestReciprocalDistance();
@@ -55,11 +53,12 @@ complex_t FormFactorCrystal::evaluate(const WavevectorInfo& wavevectors) const
 
     // perform convolution on these lattice vectors
     complex_t result(0.0, 0.0);
-    for (const auto& rec: rec_vectors) {
+    for (const auto& rec : rec_vectors) {
         auto dw_factor = debyeWallerFactor(rec);
         WavevectorInfo basis_wavevectors(kvector_t(), -rec, wavevectors.getWavelength());
         complex_t basis_factor = mp_basis_form_factor->evaluate(basis_wavevectors);
-        WavevectorInfo meso_wavevectors(cvector_t(), rec.complex()-q, wavevectors.getWavelength());
+        WavevectorInfo meso_wavevectors(cvector_t(), rec.complex() - q,
+                                        wavevectors.getWavelength());
         complex_t meso_factor = mp_meso_form_factor->evaluate(meso_wavevectors);
         result += dw_factor * basis_factor * meso_factor;
     }
@@ -79,11 +78,12 @@ Eigen::Matrix2cd FormFactorCrystal::evaluatePol(const WavevectorInfo& wavevector
 
     // perform convolution on these lattice vectors
     Eigen::Matrix2cd result = Eigen::Matrix2cd::Zero();
-    for (const auto& rec: rec_vectors) {
+    for (const auto& rec : rec_vectors) {
         auto dw_factor = debyeWallerFactor(rec);
         WavevectorInfo basis_wavevectors(kvector_t(), -rec, wavevectors.getWavelength());
         Eigen::Matrix2cd basis_factor = mp_basis_form_factor->evaluatePol(basis_wavevectors);
-        WavevectorInfo meso_wavevectors(cvector_t(), rec.complex()-q, wavevectors.getWavelength());
+        WavevectorInfo meso_wavevectors(cvector_t(), rec.complex() - q,
+                                        wavevectors.getWavelength());
         complex_t meso_factor = mp_meso_form_factor->evaluate(meso_wavevectors);
         result += dw_factor * basis_factor * meso_factor;
     }
@@ -103,8 +103,8 @@ void FormFactorCrystal::calculateLargestReciprocalDistance()
     m_max_rec_length = std::max(m_max_rec_length, M_PI / a3.mag());
 }
 
-complex_t FormFactorCrystal::debyeWallerFactor(const kvector_t &q_i) const
+complex_t FormFactorCrystal::debyeWallerFactor(const kvector_t& q_i) const
 {
     auto q2 = q_i.mag2();
-    return std::exp(-q2*m_position_variance/2.0);
+    return std::exp(-q2 * m_position_variance / 2.0);
 }
diff --git a/Core/Particle/FormFactorCrystal.h b/Core/Particle/FormFactorCrystal.h
index eb5d82759ee..9ac0967c877 100644
--- a/Core/Particle/FormFactorCrystal.h
+++ b/Core/Particle/FormFactorCrystal.h
@@ -25,22 +25,24 @@ class BA_CORE_API_ FormFactorCrystal : public IFormFactor
 {
 public:
     FormFactorCrystal(const Lattice& lattice, const IFormFactor& basis_form_factor,
-                      const IFormFactor& meso_form_factor, double position_variance=0.0);
+                      const IFormFactor& meso_form_factor, double position_variance = 0.0);
     ~FormFactorCrystal() override final;
 
-    FormFactorCrystal* clone() const override final {
+    FormFactorCrystal* clone() const override final
+    {
         return new FormFactorCrystal(m_lattice, *mp_basis_form_factor, *mp_meso_form_factor,
-                                     m_position_variance); }
+                                     m_position_variance);
+    }
 
     void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
-    void setAmbientMaterial(Material material) override {
+    void setAmbientMaterial(Material material) override
+    {
         mp_basis_form_factor->setAmbientMaterial(std::move(material));
     }
 
     double volume() const override final { return mp_meso_form_factor->volume(); }
-    double radialExtension() const override final {
-        return mp_meso_form_factor->radialExtension(); }
+    double radialExtension() const override final { return mp_meso_form_factor->radialExtension(); }
 
     double bottomZ(const IRotation& rotation) const override;
 
diff --git a/Core/Particle/FormFactorWeighted.cpp b/Core/Particle/FormFactorWeighted.cpp
index 5a733d8cb7d..53f7d7bcec2 100644
--- a/Core/Particle/FormFactorWeighted.cpp
+++ b/Core/Particle/FormFactorWeighted.cpp
@@ -15,7 +15,6 @@
 #include "FormFactorWeighted.h"
 #include "BornAgainNamespace.h"
 
-
 FormFactorWeighted::FormFactorWeighted()
 {
     setName(BornAgain::FormFactorWeightedType);
@@ -23,44 +22,44 @@ FormFactorWeighted::FormFactorWeighted()
 
 FormFactorWeighted::~FormFactorWeighted()
 {
-    for (size_t index=0; index<m_form_factors.size(); ++index)
+    for (size_t index = 0; index < m_form_factors.size(); ++index)
         delete m_form_factors[index];
 }
 
 FormFactorWeighted* FormFactorWeighted::clone() const
 {
-    FormFactorWeighted *result = new FormFactorWeighted();
-    for (size_t index=0; index<m_form_factors.size(); ++index)
+    FormFactorWeighted* result = new FormFactorWeighted();
+    for (size_t index = 0; index < m_form_factors.size(); ++index)
         result->addFormFactor(*m_form_factors[index], m_weights[index]);
     return result;
 }
 
 double FormFactorWeighted::radialExtension() const
 {
-    double result { 0.0 };
-    for (size_t index=0; index<m_form_factors.size(); ++index)
+    double result{0.0};
+    for (size_t index = 0; index < m_form_factors.size(); ++index)
         result += m_weights[index] * m_form_factors[index]->radialExtension();
     return result;
 }
 
 double FormFactorWeighted::bottomZ(const IRotation& rotation) const
 {
-    if (m_form_factors.size()==0)
+    if (m_form_factors.size() == 0)
         throw std::runtime_error("FormFactorWeighted::bottomZ() -> Error: "
                                  "'this' contains no form factors.");
     double zmin = m_form_factors[0]->bottomZ(rotation);
-    for (size_t index=1; index<m_form_factors.size(); ++index )
+    for (size_t index = 1; index < m_form_factors.size(); ++index)
         zmin = std::min(zmin, m_form_factors[index]->bottomZ(rotation));
     return zmin;
 }
 
 double FormFactorWeighted::topZ(const IRotation& rotation) const
 {
-    if (m_form_factors.size()==0)
+    if (m_form_factors.size() == 0)
         throw std::runtime_error("FormFactorWeighted::topZ() -> Error: "
                                  "'this' contains no form factors.");
     double zmax = m_form_factors[0]->topZ(rotation);
-    for (size_t index=1; index<m_form_factors.size(); ++index )
+    for (size_t index = 1; index < m_form_factors.size(); ++index)
         zmax = std::min(zmax, m_form_factors[index]->topZ(rotation));
     return zmax;
 }
@@ -73,14 +72,14 @@ void FormFactorWeighted::addFormFactor(const IFormFactor& form_factor, double we
 
 void FormFactorWeighted::setAmbientMaterial(Material material)
 {
-    for (size_t index=0; index<m_form_factors.size(); ++index)
+    for (size_t index = 0; index < m_form_factors.size(); ++index)
         m_form_factors[index]->setAmbientMaterial(material);
 }
 
 complex_t FormFactorWeighted::evaluate(const WavevectorInfo& wavevectors) const
 {
     complex_t result(0.0, 0.0);
-    for (size_t index=0; index<m_form_factors.size(); ++index)
+    for (size_t index = 0; index < m_form_factors.size(); ++index)
         result += m_weights[index] * m_form_factors[index]->evaluate(wavevectors);
     return result;
 }
@@ -88,7 +87,7 @@ complex_t FormFactorWeighted::evaluate(const WavevectorInfo& wavevectors) const
 Eigen::Matrix2cd FormFactorWeighted::evaluatePol(const WavevectorInfo& wavevectors) const
 {
     Eigen::Matrix2cd result = Eigen::Matrix2cd::Zero();
-    for (size_t index=0; index<m_form_factors.size(); ++index)
+    for (size_t index = 0; index < m_form_factors.size(); ++index)
         result += m_weights[index] * m_form_factors[index]->evaluatePol(wavevectors);
     return result;
 }
diff --git a/Core/Particle/FormFactorWeighted.h b/Core/Particle/FormFactorWeighted.h
index 1c68e390811..36cd7cac449 100644
--- a/Core/Particle/FormFactorWeighted.h
+++ b/Core/Particle/FormFactorWeighted.h
@@ -33,7 +33,7 @@ public:
 
     FormFactorWeighted* clone() const override final;
 
-    void accept(INodeVisitor* visitor) const override  final { visitor->visit(this); }
+    void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     double radialExtension() const override final;
 
@@ -41,7 +41,7 @@ public:
 
     double topZ(const IRotation& rotation) const override final;
 
-    void addFormFactor(const IFormFactor& form_factor, double weight=1.0);
+    void addFormFactor(const IFormFactor& form_factor, double weight = 1.0);
 
     void setAmbientMaterial(Material material) override final;
 
diff --git a/Core/Particle/HomogeneousRegion.h b/Core/Particle/HomogeneousRegion.h
index 83c31ddb3b4..30de946d28f 100644
--- a/Core/Particle/HomogeneousRegion.h
+++ b/Core/Particle/HomogeneousRegion.h
@@ -24,8 +24,7 @@
 //!
 //! @ingroup intern
 
-struct HomogeneousRegion
-{
+struct HomogeneousRegion {
     double m_volume;
     Material m_material;
 };
diff --git a/Core/Particle/IAbstractParticle.cpp b/Core/Particle/IAbstractParticle.cpp
index 06174b7bd6d..36165da2abb 100644
--- a/Core/Particle/IAbstractParticle.cpp
+++ b/Core/Particle/IAbstractParticle.cpp
@@ -14,7 +14,6 @@
 
 #include "IAbstractParticle.h"
 
-
 IAbstractParticle::IAbstractParticle() : m_abundance(1.0) {}
 
 IAbstractParticle::~IAbstractParticle() {}
diff --git a/Core/Particle/IAbstractParticle.h b/Core/Particle/IAbstractParticle.h
index 1d9e0082371..c2e7183ba42 100644
--- a/Core/Particle/IAbstractParticle.h
+++ b/Core/Particle/IAbstractParticle.h
@@ -32,7 +32,7 @@ public:
     IAbstractParticle();
     virtual ~IAbstractParticle();
 
-    virtual IAbstractParticle* clone() const =0;
+    virtual IAbstractParticle* clone() const = 0;
 
     virtual void accept(INodeVisitor* visitor) const;
 
@@ -44,10 +44,10 @@ public:
     void setAbundance(double abundance) { m_abundance = abundance; }
 
     //! Translates the particle with the given vector
-    virtual void translate(kvector_t translation) =0;
+    virtual void translate(kvector_t translation) = 0;
 
     //! Applies the given rotation to the particle
-    virtual void rotate(const IRotation& rotation) =0;
+    virtual void rotate(const IRotation& rotation) = 0;
 
 protected:
     double m_abundance;
diff --git a/Core/Particle/IClusteredParticles.h b/Core/Particle/IClusteredParticles.h
index 712a65d58f7..e8f0da1c85e 100644
--- a/Core/Particle/IClusteredParticles.h
+++ b/Core/Particle/IClusteredParticles.h
@@ -15,8 +15,8 @@
 #ifndef ICLUSTEREDPARTICLES_H
 #define ICLUSTEREDPARTICLES_H
 
-#include "ISample.h"
 #include "HomogeneousRegion.h"
+#include "ISample.h"
 #include "Vectors3D.h"
 
 class IFormFactor;
@@ -28,18 +28,18 @@ class IRotation;
 class BA_CORE_API_ IClusteredParticles : public ISample
 {
 public:
-    IClusteredParticles* clone() const override=0;
+    IClusteredParticles* clone() const override = 0;
 
-    void accept(INodeVisitor* visitor) const  override=0;
+    void accept(INodeVisitor* visitor) const override = 0;
 
     //! Creates a total form factor for the mesocrystal with a specific shape and content
     //! The bulk content of the mesocrystal is encapsulated by the IClusteredParticles object itself
-    virtual IFormFactor* createTotalFormFactor(
-        const IFormFactor&, const IRotation*, const kvector_t& /*translation*/) const =0;
+    virtual IFormFactor* createTotalFormFactor(const IFormFactor&, const IRotation*,
+                                               const kvector_t& /*translation*/) const = 0;
 
     //! Creates region information with volumetric densities instead of absolute volume
     //! These densities need to be multiplied by the total mesocrystal volume
-    virtual std::vector<HomogeneousRegion> homogeneousRegions() const =0;
+    virtual std::vector<HomogeneousRegion> homogeneousRegions() const = 0;
 };
 
 #endif // ICLUSTEREDPARTICLES_H
diff --git a/Core/Particle/IParticle.cpp b/Core/Particle/IParticle.cpp
index 52bf53195e3..8dfde6c00e3 100644
--- a/Core/Particle/IParticle.cpp
+++ b/Core/Particle/IParticle.cpp
@@ -20,7 +20,7 @@
 
 IFormFactor* IParticle::createFormFactor() const
 {
-    return createSlicedParticle(ZLimits {}).mP_slicedff.release();
+    return createSlicedParticle(ZLimits{}).mP_slicedff.release();
 }
 
 SlicedParticle IParticle::createSlicedParticle(ZLimits) const
@@ -63,8 +63,8 @@ std::vector<const INode*> IParticle::getChildren() const
 
 void IParticle::registerAbundance(bool make_registered)
 {
-    if(make_registered) {
-        if(!parameter(BornAgain::Abundance))
+    if (make_registered) {
+        if (!parameter(BornAgain::Abundance))
             registerParameter(BornAgain::Abundance, &m_abundance);
     } else {
         removeParameter(BornAgain::Abundance);
@@ -73,8 +73,8 @@ void IParticle::registerAbundance(bool make_registered)
 
 void IParticle::registerPosition(bool make_registered)
 {
-    if(make_registered) {
-        if(!parameter(XComponentName(BornAgain::Position))) {
+    if (make_registered) {
+        if (!parameter(XComponentName(BornAgain::Position))) {
             registerVector(BornAgain::Position, &m_position, BornAgain::UnitsNm);
         }
     } else {
@@ -93,7 +93,7 @@ ParticleLimits IParticle::bottomTopZ() const
 {
     std::unique_ptr<IFormFactor> P_ff(createFormFactor());
     std::unique_ptr<IRotation> P_rot(IRotation::createIdentity());
-    return { P_ff->bottomZ(*P_rot), P_ff->topZ(*P_rot) };
+    return {P_ff->bottomZ(*P_rot), P_ff->topZ(*P_rot)};
 }
 
 IRotation* IParticle::createComposedRotation(const IRotation* p_rotation) const
@@ -111,8 +111,7 @@ IRotation* IParticle::createComposedRotation(const IRotation* p_rotation) const
     }
 }
 
-kvector_t IParticle::composedTranslation(
-    const IRotation* p_rotation, kvector_t translation) const
+kvector_t IParticle::composedTranslation(const IRotation* p_rotation, kvector_t translation) const
 {
     if (p_rotation) {
         Transform3D transform = p_rotation->getTransform3D();
@@ -127,4 +126,3 @@ void IParticle::registerParticleProperties()
     registerAbundance();
     registerPosition();
 }
-
diff --git a/Core/Particle/IParticle.h b/Core/Particle/IParticle.h
index 724e8fba114..a9b6b12b920 100644
--- a/Core/Particle/IParticle.h
+++ b/Core/Particle/IParticle.h
@@ -24,8 +24,7 @@
 #include <memory>
 
 //! Vertical extension of a particle, specified by bottom and top z coordinate.
-struct ParticleLimits
-{
+struct ParticleLimits {
     double m_bottom;
     double m_top;
 };
@@ -39,7 +38,7 @@ class BA_CORE_API_ IParticle : public IAbstractParticle
 {
 public:
     ~IParticle() {}
-    IParticle* clone() const  override=0;
+    IParticle* clone() const override = 0;
 
     void accept(INodeVisitor* visitor) const override { visitor->visit(this); }
 
diff --git a/Core/Particle/MesoCrystal.cpp b/Core/Particle/MesoCrystal.cpp
index 781b1262551..3fc79f23adb 100644
--- a/Core/Particle/MesoCrystal.cpp
+++ b/Core/Particle/MesoCrystal.cpp
@@ -25,13 +25,12 @@ MesoCrystal::MesoCrystal(const IClusteredParticles& particle_structure,
     initialize();
 }
 
-MesoCrystal::~MesoCrystal()
-{}
+MesoCrystal::~MesoCrystal() {}
 
 MesoCrystal* MesoCrystal::clone() const
 {
-    MesoCrystal* p_result
-        = new MesoCrystal(mp_particle_structure->clone(), mp_meso_form_factor->clone());
+    MesoCrystal* p_result =
+        new MesoCrystal(mp_particle_structure->clone(), mp_meso_form_factor->clone());
     p_result->setAbundance(m_abundance);
     if (mP_rotation)
         p_result->setRotation(*mP_rotation);
@@ -52,9 +51,9 @@ SlicedParticle MesoCrystal::createSlicedParticle(ZLimits limits) const
     if (mP_rotation)
         P_rotation.reset(mP_rotation->clone());
     std::unique_ptr<IFormFactor> P_temp_ff(
-                mp_meso_form_factor->createSlicedFormFactor(limits, *P_rotation, m_position));
-    std::unique_ptr<IFormFactor> P_total_ff( mp_particle_structure->createTotalFormFactor(
-                                                 *P_temp_ff, P_rotation.get(), m_position) );
+        mp_meso_form_factor->createSlicedFormFactor(limits, *P_rotation, m_position));
+    std::unique_ptr<IFormFactor> P_total_ff(
+        mp_particle_structure->createTotalFormFactor(*P_temp_ff, P_rotation.get(), m_position));
     double meso_volume = mp_meso_form_factor->volume();
     auto regions = mp_particle_structure->homogeneousRegions();
     for (auto& region : regions)
@@ -67,8 +66,8 @@ SlicedParticle MesoCrystal::createSlicedParticle(ZLimits limits) const
 
 std::vector<const INode*> MesoCrystal::getChildren() const
 {
-    return std::vector<const INode*>() <<  IParticle::getChildren()
-                                       << mp_particle_structure << mp_meso_form_factor;
+    return std::vector<const INode*>()
+           << IParticle::getChildren() << mp_particle_structure << mp_meso_form_factor;
 }
 
 MesoCrystal::MesoCrystal(IClusteredParticles* p_particle_structure, IFormFactor* p_form_factor)
diff --git a/Core/Particle/MesoCrystal.h b/Core/Particle/MesoCrystal.h
index c857413dc36..dbcffc62652 100644
--- a/Core/Particle/MesoCrystal.h
+++ b/Core/Particle/MesoCrystal.h
@@ -41,7 +41,7 @@ private:
     void initialize();
 
     std::unique_ptr<IClusteredParticles> mp_particle_structure; //!< Crystal  structure
-    std::unique_ptr<IFormFactor> mp_meso_form_factor; //!< Outer shape of this mesocrystal
+    std::unique_ptr<IFormFactor> mp_meso_form_factor;           //!< Outer shape of this mesocrystal
 };
 
 #endif // MESOCRYSTAL_H
diff --git a/Core/Particle/Particle.cpp b/Core/Particle/Particle.cpp
index 7ad9883a7cd..46ebfdd9f9f 100644
--- a/Core/Particle/Particle.cpp
+++ b/Core/Particle/Particle.cpp
@@ -17,30 +17,25 @@
 #include "FormFactorDecoratorPositionFactor.h"
 #include "MaterialFactoryFuncs.h"
 
-Particle::Particle()
-    : m_material(HomogeneousMaterial())
+Particle::Particle() : m_material(HomogeneousMaterial())
 {
     initialize();
 }
 
-Particle::Particle(Material material)
-    : m_material(std::move(material))
+Particle::Particle(Material material) : m_material(std::move(material))
 {
     initialize();
 }
 
 Particle::Particle(Material material, const IFormFactor& form_factor)
-    : m_material(std::move(material))
-    , mP_form_factor(form_factor.clone())
+    : m_material(std::move(material)), mP_form_factor(form_factor.clone())
 {
     initialize();
     registerChild(mP_form_factor.get());
 }
 
-Particle::Particle(Material material, const IFormFactor& form_factor,
-                   const IRotation& rotation)
-    : m_material(std::move(material))
-    , mP_form_factor(form_factor.clone())
+Particle::Particle(Material material, const IFormFactor& form_factor, const IRotation& rotation)
+    : m_material(std::move(material)), mP_form_factor(form_factor.clone())
 {
     initialize();
     setRotation(rotation);
@@ -68,16 +63,15 @@ SlicedParticle Particle::createSlicedParticle(ZLimits limits) const
     if (mP_rotation)
         P_rotation.reset(mP_rotation->clone());
     std::unique_ptr<IFormFactor> P_temp_ff(
-                mP_form_factor->createSlicedFormFactor(limits, *P_rotation, m_position));
+        mP_form_factor->createSlicedFormFactor(limits, *P_rotation, m_position));
     if (!P_temp_ff)
         return {};
     std::unique_ptr<FormFactorDecoratorMaterial> P_ff(new FormFactorDecoratorMaterial(*P_temp_ff));
     double volume = P_temp_ff->volume();
-    Material transformed_material(
-                m_material.transformedMaterial(P_rotation->getTransform3D()));
+    Material transformed_material(m_material.transformedMaterial(P_rotation->getTransform3D()));
     P_ff->setMaterial(transformed_material);
     SlicedParticle result;
-    result.m_regions.push_back( { volume, transformed_material } );
+    result.m_regions.push_back({volume, transformed_material});
     result.mP_slicedff = std::move(P_ff);
     return result;
 }
diff --git a/Core/Particle/Particle.h b/Core/Particle/Particle.h
index 21ab0951335..2aab0d8dd56 100644
--- a/Core/Particle/Particle.h
+++ b/Core/Particle/Particle.h
@@ -15,9 +15,9 @@
 #ifndef PARTICLE_H
 #define PARTICLE_H
 
-#include "IParticle.h"
 #include "FormFactorDecoratorMaterial.h"
 #include "FormFactorDecoratorRotation.h"
+#include "IParticle.h"
 #include "Material.h"
 
 //! A particle with a form factor and refractive index.
@@ -29,8 +29,7 @@ public:
     Particle();
     Particle(Material material);
     Particle(Material material, const IFormFactor& form_factor);
-    Particle(Material material, const IFormFactor& form_factor,
-             const IRotation& rotation);
+    Particle(Material material, const IFormFactor& form_factor, const IRotation& rotation);
 
     Particle* clone() const override final;
 
@@ -48,6 +47,7 @@ public:
 protected:
     Material m_material;
     std::unique_ptr<IFormFactor> mP_form_factor;
+
 private:
     void initialize();
 };
diff --git a/Core/Particle/ParticleComposition.cpp b/Core/Particle/ParticleComposition.cpp
index 54f32a4768e..8b8bc70478b 100644
--- a/Core/Particle/ParticleComposition.cpp
+++ b/Core/Particle/ParticleComposition.cpp
@@ -24,20 +24,19 @@ ParticleComposition::ParticleComposition()
 }
 
 ParticleComposition::ParticleComposition(const IParticle& particle,
-        std::vector<kvector_t> positions)
+                                         std::vector<kvector_t> positions)
 {
     initialize();
     addParticles(particle, positions);
 }
 
-ParticleComposition::~ParticleComposition()
-{}
+ParticleComposition::~ParticleComposition() {}
 
 ParticleComposition* ParticleComposition::clone() const
 {
     ParticleComposition* p_result = new ParticleComposition();
     p_result->setAbundance(m_abundance);
-    for (size_t index=0; index<m_particles.size(); ++index)
+    for (size_t index = 0; index < m_particles.size(); ++index)
         p_result->addParticle(*m_particles[index]);
     if (mP_rotation)
         p_result->setRotation(*mP_rotation);
@@ -49,16 +48,16 @@ IFormFactor* ParticleComposition::createFormFactor() const
 {
     if (m_particles.size() == 0)
         return {};
-    std::unique_ptr<FormFactorWeighted> P_result { new FormFactorWeighted() };
+    std::unique_ptr<FormFactorWeighted> P_result{new FormFactorWeighted()};
     auto particles = decompose();
     for (auto p_particle : particles) {
-        std::unique_ptr<IFormFactor> P_particle_ff { p_particle->createFormFactor() };
+        std::unique_ptr<IFormFactor> P_particle_ff{p_particle->createFormFactor()};
         P_result->addFormFactor(*P_particle_ff);
     }
     return P_result.release();
 }
 
-void ParticleComposition::addParticle(const IParticle &particle)
+void ParticleComposition::addParticle(const IParticle& particle)
 {
     IParticle* np = particle.clone();
     addParticlePointer(np);
@@ -75,7 +74,7 @@ void ParticleComposition::addParticle(const IParticle& particle, kvector_t posit
 // enable python lists to std::vector conversion
 void ParticleComposition::addParticles(const IParticle& particle, std::vector<kvector_t> positions)
 {
-    for (size_t i=0; i<positions.size(); ++i)
+    for (size_t i = 0; i < positions.size(); ++i)
         addParticle(particle, positions[i]);
 }
 
@@ -92,8 +91,7 @@ SafePointerVector<IParticle> ParticleComposition::decompose() const
     SafePointerVector<IParticle> result;
     auto p_rotation = rotation();
     auto translation = position();
-    for (auto& P_particle : m_particles)
-    {
+    for (auto& P_particle : m_particles) {
         auto sublist = P_particle->decompose();
         for (auto p_subparticle : sublist) {
             if (p_rotation)
@@ -109,8 +107,7 @@ ParticleLimits ParticleComposition::bottomTopZ() const
 {
     auto particles = decompose();
     ParticleLimits result = particles[check_index(0)]->bottomTopZ();
-    for (auto& P_particle : particles)
-    {
+    for (auto& P_particle : particles) {
         ParticleLimits limits = P_particle->bottomTopZ();
         result.m_bottom = std::min(result.m_bottom, limits.m_bottom);
         result.m_top = std::max(result.m_top, limits.m_top);
@@ -120,8 +117,10 @@ ParticleLimits ParticleComposition::bottomTopZ() const
 
 size_t ParticleComposition::check_index(size_t index) const
 {
-    return index < m_particles.size() ? index : throw Exceptions::OutOfBoundsException(
-        "ParticleComposition::check_index() -> Index is out of bounds");
+    return index < m_particles.size()
+               ? index
+               : throw Exceptions::OutOfBoundsException(
+                   "ParticleComposition::check_index() -> Index is out of bounds");
 }
 
 void ParticleComposition::addParticlePointer(IParticle* p_particle)
diff --git a/Core/Particle/ParticleComposition.h b/Core/Particle/ParticleComposition.h
index 3f11948d41b..40a911ca435 100644
--- a/Core/Particle/ParticleComposition.h
+++ b/Core/Particle/ParticleComposition.h
@@ -25,7 +25,7 @@ class BA_CORE_API_ ParticleComposition : public IParticle
 {
 public:
     ParticleComposition();
-    ParticleComposition(const IParticle& particle, std::vector<kvector_t > positions);
+    ParticleComposition(const IParticle& particle, std::vector<kvector_t> positions);
 
     ~ParticleComposition();
     ParticleComposition* clone() const override final;
@@ -35,8 +35,8 @@ public:
     IFormFactor* createFormFactor() const override final;
 
     void addParticle(const IParticle& particle);
-    void addParticle(const IParticle& particle, kvector_t  position);
-    void addParticles(const IParticle& particle, std::vector<kvector_t > positions);
+    void addParticle(const IParticle& particle, kvector_t position);
+    void addParticles(const IParticle& particle, std::vector<kvector_t> positions);
 
     //! Returns number of different particles
     size_t nbrParticles() const { return m_particles.size(); }
@@ -46,6 +46,7 @@ public:
     SafePointerVector<IParticle> decompose() const override final;
 
     ParticleLimits bottomTopZ() const override final;
+
 private:
     size_t check_index(size_t index) const;
 
diff --git a/Core/Particle/ParticleCoreShell.cpp b/Core/Particle/ParticleCoreShell.cpp
index e5efd5fd197..f0ca80f8469 100644
--- a/Core/Particle/ParticleCoreShell.cpp
+++ b/Core/Particle/ParticleCoreShell.cpp
@@ -17,8 +17,8 @@
 #include "FormFactorCoreShell.h"
 #include "Particle.h"
 
-ParticleCoreShell::ParticleCoreShell(
-    const Particle& shell, const Particle& core, kvector_t relative_core_position)
+ParticleCoreShell::ParticleCoreShell(const Particle& shell, const Particle& core,
+                                     kvector_t relative_core_position)
 {
     setName(BornAgain::ParticleCoreShellType);
     registerParticleProperties();
@@ -26,9 +26,7 @@ ParticleCoreShell::ParticleCoreShell(
     addAndRegisterShell(shell);
 }
 
-ParticleCoreShell::~ParticleCoreShell()
-{
-}
+ParticleCoreShell::~ParticleCoreShell() {}
 
 ParticleCoreShell* ParticleCoreShell::clone() const
 {
@@ -71,7 +69,7 @@ SlicedParticle ParticleCoreShell::createSlicedParticle(ZLimits limits) const
     }
 
     // set core ambient material
-    if (sliced_shell.m_regions.size()!=1)
+    if (sliced_shell.m_regions.size() != 1)
         return {};
     auto shell_material = sliced_shell.m_regions[0].m_material;
     sliced_core.mP_slicedff->setAmbientMaterial(shell_material);
@@ -91,8 +89,7 @@ std::vector<const INode*> ParticleCoreShell::getChildren() const
     return std::vector<const INode*>() << IParticle::getChildren() << mp_core << mp_shell;
 }
 
-void ParticleCoreShell::addAndRegisterCore(const Particle& core,
-                                           kvector_t relative_core_position)
+void ParticleCoreShell::addAndRegisterCore(const Particle& core, kvector_t relative_core_position)
 {
     mp_core.reset(core.clone());
     mp_core->translate(relative_core_position);
@@ -108,8 +105,7 @@ void ParticleCoreShell::addAndRegisterShell(const Particle& shell)
     mp_shell->registerPosition(false);
 }
 
-ParticleCoreShell::ParticleCoreShell()
-    : mp_shell { nullptr }, mp_core { nullptr }
+ParticleCoreShell::ParticleCoreShell() : mp_shell{nullptr}, mp_core{nullptr}
 {
     setName(BornAgain::ParticleCoreShellType);
 }
diff --git a/Core/Particle/ParticleCoreShell.h b/Core/Particle/ParticleCoreShell.h
index 967ea4b2298..796191f2ee6 100644
--- a/Core/Particle/ParticleCoreShell.h
+++ b/Core/Particle/ParticleCoreShell.h
@@ -26,7 +26,7 @@ class BA_CORE_API_ ParticleCoreShell : public IParticle
 {
 public:
     ParticleCoreShell(const Particle& shell, const Particle& core,
-                      kvector_t relative_core_position=kvector_t(0.0, 0.0, 0.0));
+                      kvector_t relative_core_position = kvector_t(0.0, 0.0, 0.0));
     ~ParticleCoreShell();
 
     ParticleCoreShell* clone() const override final;
diff --git a/Core/Particle/ParticleDistribution.cpp b/Core/Particle/ParticleDistribution.cpp
index 0f91a6323f7..73fc59ed91d 100644
--- a/Core/Particle/ParticleDistribution.cpp
+++ b/Core/Particle/ParticleDistribution.cpp
@@ -14,12 +14,12 @@
 
 #include "ParticleDistribution.h"
 #include "BornAgainNamespace.h"
+#include "Distributions.h"
 #include "Exceptions.h"
 #include "IParticle.h"
 #include "ParameterPool.h"
 #include "ParameterSample.h"
 #include "RealParameter.h"
-#include "Distributions.h"
 #include <map>
 
 ParticleDistribution::ParticleDistribution(const IParticle& prototype,
@@ -30,15 +30,14 @@ ParticleDistribution::ParticleDistribution(const IParticle& prototype,
     mP_particle.reset(prototype.clone());
     registerChild(mP_particle.get());
     mP_particle->registerAbundance(false);
-    if(auto dist = m_par_distribution.getDistribution())
+    if (auto dist = m_par_distribution.getDistribution())
         registerChild(dist);
     registerParameter(BornAgain::Abundance, &m_abundance);
 }
 
 ParticleDistribution* ParticleDistribution::clone() const
 {
-    ParticleDistribution* p_result
-        = new ParticleDistribution(*mP_particle, m_par_distribution);
+    ParticleDistribution* p_result = new ParticleDistribution(*mP_particle, m_par_distribution);
     p_result->setAbundance(m_abundance);
     return p_result;
 }
@@ -57,22 +56,22 @@ void ParticleDistribution::rotate(const IRotation& rotation)
 
 SafePointerVector<IParticle> ParticleDistribution::generateParticles() const
 {
-    std::unique_ptr<ParameterPool> P_pool {mP_particle->createParameterTree()};
+    std::unique_ptr<ParameterPool> P_pool{mP_particle->createParameterTree()};
     std::string main_par_name = m_par_distribution.getMainParameterName();
     double main_par_value = P_pool->getUniqueMatch(main_par_name)->value();
 
     // Preset link ratios:
     std::map<std::string, double> linked_ratios;
-    for (const std::string& name: m_par_distribution.getLinkedParameterNames())
-        linked_ratios[name] = main_par_value == 0 ? 1.0 :
-            P_pool->getUniqueMatch(name)->value() / main_par_value;
+    for (const std::string& name : m_par_distribution.getLinkedParameterNames())
+        linked_ratios[name] =
+            main_par_value == 0 ? 1.0 : P_pool->getUniqueMatch(name)->value() / main_par_value;
 
     // Draw distribution samples; for each sample, create one particle clone:
     std::vector<ParameterSample> main_par_samples = m_par_distribution.generateSamples();
     SafePointerVector<IParticle> result;
-    for (const ParameterSample& main_sample: main_par_samples ) {
+    for (const ParameterSample& main_sample : main_par_samples) {
         IParticle* p_particle_clone = mP_particle->clone();
-        std::unique_ptr<ParameterPool> P_new_pool {p_particle_clone->createParameterTree()};
+        std::unique_ptr<ParameterPool> P_new_pool{p_particle_clone->createParameterTree()};
         P_new_pool->setUniqueMatchValue(main_par_name, main_sample.value);
         for (auto it = linked_ratios.begin(); it != linked_ratios.end(); ++it)
             P_new_pool->setUniqueMatchValue(it->first, main_sample.value * it->second);
@@ -85,7 +84,7 @@ SafePointerVector<IParticle> ParticleDistribution::generateParticles() const
 std::vector<const INode*> ParticleDistribution::getChildren() const
 {
     std::vector<const INode*> result = std::vector<const INode*>() << mP_particle;
-    if(auto dist = m_par_distribution.getDistribution())
+    if (auto dist = m_par_distribution.getDistribution())
         result.push_back(dist);
     return result;
 }
diff --git a/Core/Particle/SlicedParticle.cpp b/Core/Particle/SlicedParticle.cpp
index e9de7332f1b..9459bde695f 100644
--- a/Core/Particle/SlicedParticle.cpp
+++ b/Core/Particle/SlicedParticle.cpp
@@ -12,5 +12,4 @@
 //
 // ************************************************************************** //
 
-
 #include "SlicedParticle.h"
diff --git a/Core/Particle/SlicedParticle.h b/Core/Particle/SlicedParticle.h
index 1d404bbe8f2..3b8a6eacfc5 100644
--- a/Core/Particle/SlicedParticle.h
+++ b/Core/Particle/SlicedParticle.h
@@ -15,8 +15,8 @@
 #ifndef SLICEDPARTICLE_H
 #define SLICEDPARTICLE_H
 
-#include "IFormFactor.h"
 #include "HomogeneousRegion.h"
+#include "IFormFactor.h"
 #include <memory>
 
 //! Struct that contains information on a sliced particle.
@@ -25,8 +25,7 @@
 //!
 //! @ingroup intern
 
-struct SlicedParticle
-{
+struct SlicedParticle {
     std::unique_ptr<IFormFactor> mP_slicedff;
     std::vector<HomogeneousRegion> m_regions;
 };
diff --git a/Core/Particle/TRange.h b/Core/Particle/TRange.h
index 57803044c3e..f85b61700e1 100644
--- a/Core/Particle/TRange.h
+++ b/Core/Particle/TRange.h
@@ -22,13 +22,14 @@ template <class T> class TRange
 {
 public:
     TRange(T lowerBound, T upperBound) : m_lower_bound(lowerBound), m_upper_bound(upperBound) {}
-    virtual ~TRange(){}
+    virtual ~TRange() {}
 
     T getLowerBound() const { return m_lower_bound; }
     T getUpperBound() const { return m_upper_bound; }
-    T getDifference() const { return m_upper_bound-m_lower_bound; }
+    T getDifference() const { return m_upper_bound - m_lower_bound; }
 
     bool inRange(T value) const { return value >= m_lower_bound && value < m_upper_bound; }
+
 private:
     T m_lower_bound, m_upper_bound;
 };
@@ -39,9 +40,12 @@ template <class T> class TSampledRange : public TRange<T>
 {
 public:
     TSampledRange(size_t n_samples, T lowerBound, T upperBound)
-        : TRange<T>(lowerBound, upperBound), m_n_samples(n_samples) {}
+        : TRange<T>(lowerBound, upperBound), m_n_samples(n_samples)
+    {
+    }
 
     size_t getNSamples() const { return m_n_samples; }
+
 private:
     size_t m_n_samples;
 };
diff --git a/Core/Particle/ZLimits.cpp b/Core/Particle/ZLimits.cpp
index daa051c6f1a..357b065a2a8 100644
--- a/Core/Particle/ZLimits.cpp
+++ b/Core/Particle/ZLimits.cpp
@@ -12,23 +12,16 @@
 //
 // ************************************************************************** //
 
-
 #include "ZLimits.h"
 #include <algorithm>
 #include <stdexcept>
 
-ZLimits::ZLimits()
-    : m_lower { true, 0 }
-    , m_upper { true, 0 }
-{}
+ZLimits::ZLimits() : m_lower{true, 0}, m_upper{true, 0} {}
 
-ZLimits::ZLimits(double min, double max)
-    : ZLimits( { false, min }, { false, max } )
-{}
+ZLimits::ZLimits(double min, double max) : ZLimits({false, min}, {false, max}) {}
 
 ZLimits::ZLimits(OneSidedLimit lower_limit, OneSidedLimit upper_limit)
-    : m_lower(std::move(lower_limit))
-    , m_upper(std::move(upper_limit))
+    : m_lower(std::move(lower_limit)), m_upper(std::move(upper_limit))
 {
     if (!lower_limit.m_limitless && !upper_limit.m_limitless
         && lower_limit.m_value > upper_limit.m_value)
@@ -56,27 +49,29 @@ OneSidedLimit ZLimits::upperLimit() const
 OneSidedLimit MinLimit(const OneSidedLimit& left, const OneSidedLimit& right)
 {
     if (left.m_limitless || right.m_limitless)
-        return { true, 0 };
-    return { false, std::min(left.m_value, right.m_value) };
+        return {true, 0};
+    return {false, std::min(left.m_value, right.m_value)};
 }
 
 OneSidedLimit MaxLimit(const OneSidedLimit& left, const OneSidedLimit& right)
 {
     if (left.m_limitless || right.m_limitless)
-        return { true, 0 };
-    return { false, std::max(left.m_value, right.m_value) };
+        return {true, 0};
+    return {false, std::max(left.m_value, right.m_value)};
 }
 
 bool operator==(const OneSidedLimit& left, const OneSidedLimit& right)
 {
-    if (left.m_limitless != right.m_limitless) return false;
-    if (!left.m_limitless && left.m_value != right.m_value) return false;
+    if (left.m_limitless != right.m_limitless)
+        return false;
+    if (!left.m_limitless && left.m_value != right.m_value)
+        return false;
     return true;
 }
 
 bool operator!=(const OneSidedLimit& left, const OneSidedLimit& right)
 {
-    return !(left==right);
+    return !(left == right);
 }
 
 std::ostream& operator<<(std::ostream& ostr, const OneSidedLimit& limit)
@@ -86,21 +81,21 @@ std::ostream& operator<<(std::ostream& ostr, const OneSidedLimit& limit)
 
 ZLimits ConvexHull(const ZLimits& left, const ZLimits& right)
 {
-    return { MinLimit(left.lowerLimit(), right.lowerLimit()),
-             MaxLimit(left.upperLimit(), right.upperLimit()) };
+    return {MinLimit(left.lowerLimit(), right.lowerLimit()),
+            MaxLimit(left.upperLimit(), right.upperLimit())};
 }
 
 bool operator==(const ZLimits& left, const ZLimits& right)
 {
-    return (   left.lowerLimit()==right.lowerLimit()
-            && left.upperLimit()==right.upperLimit());
+    return (left.lowerLimit() == right.lowerLimit() && left.upperLimit() == right.upperLimit());
 }
 
 bool operator!=(const ZLimits& left, const ZLimits& right)
 {
-    return !(left==right);
+    return !(left == right);
 }
 
-std::ostream& operator<<(std::ostream& ostr, const ZLimits& limits) {
+std::ostream& operator<<(std::ostream& ostr, const ZLimits& limits)
+{
     return ostr << "Lower: " << limits.lowerLimit() << ", Upper: " << limits.upperLimit();
 }
diff --git a/Core/Particle/ZLimits.h b/Core/Particle/ZLimits.h
index 4974297828a..016d510f4f5 100644
--- a/Core/Particle/ZLimits.h
+++ b/Core/Particle/ZLimits.h
@@ -22,8 +22,7 @@
 //!
 //! @ingroup intern
 
-struct BA_CORE_API_ OneSidedLimit
-{
+struct BA_CORE_API_ OneSidedLimit {
     bool m_limitless;
     double m_value;
 };
@@ -44,6 +43,7 @@ public:
 
     OneSidedLimit lowerLimit() const;
     OneSidedLimit upperLimit() const;
+
 private:
     OneSidedLimit m_lower;
     OneSidedLimit m_upper;
@@ -62,5 +62,4 @@ BA_CORE_API_ bool operator!=(const ZLimits& left, const ZLimits& right);
 
 BA_CORE_API_ std::ostream& operator<<(std::ostream& ostr, const ZLimits& limits);
 
-
 #endif // ZLIMITS_H
diff --git a/Core/Scattering/IFormFactor.cpp b/Core/Scattering/IFormFactor.cpp
index e904de763ed..cc1d6fc6617 100644
--- a/Core/Scattering/IFormFactor.cpp
+++ b/Core/Scattering/IFormFactor.cpp
@@ -13,26 +13,27 @@
 // ************************************************************************** //
 
 #include "IFormFactor.h"
-#include "ILayerRTCoefficients.h"
 #include "Exceptions.h"
 #include "FormFactorDecoratorPositionFactor.h"
 #include "FormFactorDecoratorRotation.h"
+#include "ILayerRTCoefficients.h"
 #include "Rotations.h"
 #include "WavevectorInfo.h"
 #include <memory>
 #include <utility>
 
-namespace {
-bool ShapeIsContainedInLimits(const IFormFactor& formfactor, ZLimits limits,
-                              const IRotation& rot, kvector_t translation);
-bool ShapeOutsideLimits(const IFormFactor& formfactor, ZLimits limits,
-                        const IRotation& rot, kvector_t translation);
-}
+namespace
+{
+bool ShapeIsContainedInLimits(const IFormFactor& formfactor, ZLimits limits, const IRotation& rot,
+                              kvector_t translation);
+bool ShapeOutsideLimits(const IFormFactor& formfactor, ZLimits limits, const IRotation& rot,
+                        kvector_t translation);
+} // namespace
 
 IFormFactor::~IFormFactor() {}
 
 IFormFactor* IFormFactor::createSlicedFormFactor(ZLimits limits, const IRotation& rot,
-                                                kvector_t translation) const
+                                                 kvector_t translation) const
 {
     if (ShapeIsContainedInLimits(*this, limits, rot, translation))
         return CreateTransformedFormFactor(*this, rot, translation);
@@ -40,8 +41,9 @@ IFormFactor* IFormFactor::createSlicedFormFactor(ZLimits limits, const IRotation
         return nullptr;
     if (canSliceAnalytically(rot))
         return sliceFormFactor(limits, rot, translation);
-    throw std::runtime_error(getName() + "::createSlicedFormFactor error: not supported for "
-                             "the given rotation!");
+    throw std::runtime_error(getName()
+                             + "::createSlicedFormFactor error: not supported for "
+                               "the given rotation!");
 }
 
 Eigen::Matrix2cd IFormFactor::evaluatePol(const WavevectorInfo&) const
@@ -59,7 +61,8 @@ double IFormFactor::volume() const
 
 void IFormFactor::setSpecularInfo(std::unique_ptr<const ILayerRTCoefficients>,
                                   std::unique_ptr<const ILayerRTCoefficients>)
-{}
+{
+}
 
 bool IFormFactor::canSliceAnalytically(const IRotation&) const
 {
@@ -72,23 +75,24 @@ IFormFactor* IFormFactor::sliceFormFactor(ZLimits, const IRotation&, kvector_t)
 }
 
 IFormFactor* CreateTransformedFormFactor(const IFormFactor& formfactor, const IRotation& rot,
-                                        kvector_t translation)
+                                         kvector_t translation)
 {
     std::unique_ptr<IFormFactor> P_fftemp, P_result;
     if (!rot.isIdentity())
         P_fftemp.reset(new FormFactorDecoratorRotation(formfactor, rot));
     else
         P_fftemp.reset(formfactor.clone());
-    if (translation!=kvector_t())
+    if (translation != kvector_t())
         P_result.reset(new FormFactorDecoratorPositionFactor(*P_fftemp, translation));
     else
         std::swap(P_fftemp, P_result);
     return P_result.release();
 }
 
-namespace {
-bool ShapeIsContainedInLimits(const IFormFactor& formfactor, ZLimits limits,
-                              const IRotation& rot, kvector_t translation)
+namespace
+{
+bool ShapeIsContainedInLimits(const IFormFactor& formfactor, ZLimits limits, const IRotation& rot,
+                              kvector_t translation)
 {
     double zbottom = formfactor.bottomZ(rot) + translation.z();
     double ztop = formfactor.topZ(rot) + translation.z();
@@ -100,8 +104,8 @@ bool ShapeIsContainedInLimits(const IFormFactor& formfactor, ZLimits limits,
         return false;
     return true;
 }
-bool ShapeOutsideLimits(const IFormFactor& formfactor, ZLimits limits,
-                        const IRotation& rot, kvector_t translation)
+bool ShapeOutsideLimits(const IFormFactor& formfactor, ZLimits limits, const IRotation& rot,
+                        kvector_t translation)
 {
     double zbottom = formfactor.bottomZ(rot) + translation.z();
     double ztop = formfactor.topZ(rot) + translation.z();
@@ -113,4 +117,4 @@ bool ShapeOutsideLimits(const IFormFactor& formfactor, ZLimits limits,
         return true;
     return false;
 }
-}
+} // namespace
diff --git a/Core/Scattering/IFormFactor.h b/Core/Scattering/IFormFactor.h
index 69ff4396fd1..f7bf5d10737 100644
--- a/Core/Scattering/IFormFactor.h
+++ b/Core/Scattering/IFormFactor.h
@@ -15,9 +15,9 @@
 #ifndef IFORMFACTOR_H
 #define IFORMFACTOR_H
 
-#include "ISample.h"
 #include "Complex.h"
 #include "EigenCore.h"
+#include "ISample.h"
 #include "Material.h"
 #include "Vectors3D.h"
 #include "ZLimits.h"
@@ -42,7 +42,7 @@ class BA_CORE_API_ IFormFactor : public ISample
 public:
     IFormFactor() {}
     ~IFormFactor() override;
-    IFormFactor* clone() const override=0;
+    IFormFactor* clone() const override = 0;
 
     //! Creates a (possibly sliced) form factor with the given rotation and translation
     IFormFactor* createSlicedFormFactor(ZLimits limits, const IRotation& rot,
@@ -52,7 +52,7 @@ public:
     virtual void setAmbientMaterial(Material) = 0;
 
     //! Returns scattering amplitude for complex wavevectors ki, kf.
-    virtual complex_t evaluate(const WavevectorInfo& wavevectors) const=0;
+    virtual complex_t evaluate(const WavevectorInfo& wavevectors) const = 0;
 
 #ifndef SWIG
     //! Returns scattering amplitude for matrix interactions
@@ -64,13 +64,13 @@ public:
 
     //! Returns the (approximate in some cases) radial size of the particle of this
     //! form factor's shape. This is used for SSCA calculations
-    virtual double radialExtension() const=0;
+    virtual double radialExtension() const = 0;
 
     //! Returns the z-coordinate of the lowest point in this shape after a given rotation
-    virtual double bottomZ(const IRotation& rotation) const=0;
+    virtual double bottomZ(const IRotation& rotation) const = 0;
 
     //! Returns the z-coordinate of the lowest point in this shape after a given rotation
-    virtual double topZ(const IRotation& rotation) const=0;
+    virtual double topZ(const IRotation& rotation) const = 0;
 
 #ifndef SWIG
     //! Sets reflection/transmission info
diff --git a/Core/Scattering/IFormFactorBorn.cpp b/Core/Scattering/IFormFactorBorn.cpp
index 939d65cf2e2..3651ff7dae8 100644
--- a/Core/Scattering/IFormFactorBorn.cpp
+++ b/Core/Scattering/IFormFactorBorn.cpp
@@ -18,16 +18,14 @@
 #include "Rotations.h"
 #include "WavevectorInfo.h"
 
-IFormFactorBorn::IFormFactorBorn()
-    : mP_shape(new Dot())
-{}
+IFormFactorBorn::IFormFactorBorn() : mP_shape(new Dot()) {}
 
 complex_t IFormFactorBorn::evaluate(const WavevectorInfo& wavevectors) const
 {
     return evaluate_for_q(wavevectors.getQ());
 }
 
-Eigen::Matrix2cd IFormFactorBorn::evaluatePol(const WavevectorInfo &wavevectors) const
+Eigen::Matrix2cd IFormFactorBorn::evaluatePol(const WavevectorInfo& wavevectors) const
 {
     return evaluate_for_q_pol(wavevectors.getQ());
 }
@@ -64,24 +62,28 @@ SlicingEffects IFormFactorBorn::computeSlicingEffects(ZLimits limits, const kvec
     OneSidedLimit upper_limit = limits.upperLimit();
     if (!upper_limit.m_limitless && !lower_limit.m_limitless
         && lower_limit.m_value > upper_limit.m_value)
-        throw std::runtime_error(getName() + "::sliceFormFactor error: "
-                                 "upperlimit < lowerlimit.");
-    double dz_top = upper_limit.m_limitless ? -1
-                                            : z_top - upper_limit.m_value;
-    double dz_bottom = lower_limit.m_limitless ? -1
-                                               : lower_limit.m_value - z_bottom;
+        throw std::runtime_error(getName()
+                                 + "::sliceFormFactor error: "
+                                   "upperlimit < lowerlimit.");
+    double dz_top = upper_limit.m_limitless ? -1 : z_top - upper_limit.m_value;
+    double dz_bottom = lower_limit.m_limitless ? -1 : lower_limit.m_value - z_bottom;
     if (dz_top < 0 && dz_bottom < 0)
-        throw std::runtime_error(getName() + "::sliceFormFactor error: "
-                                 "shape didn't need to be sliced.");
+        throw std::runtime_error(getName()
+                                 + "::sliceFormFactor error: "
+                                   "shape didn't need to be sliced.");
     if (dz_bottom > height)
-        throw std::runtime_error(getName() + "::sliceFormFactor error: "
-                                 "interface outside shape.");
+        throw std::runtime_error(getName()
+                                 + "::sliceFormFactor error: "
+                                   "interface outside shape.");
     if (dz_top > height)
-        throw std::runtime_error(getName() + "::sliceFormFactor error: "
-                                 "interface outside shape.");
-    if (dz_bottom < 0) dz_bottom = 0;
-    if (dz_top < 0) dz_top = 0;
+        throw std::runtime_error(getName()
+                                 + "::sliceFormFactor error: "
+                                   "interface outside shape.");
+    if (dz_bottom < 0)
+        dz_bottom = 0;
+    if (dz_top < 0)
+        dz_top = 0;
     if (dz_bottom > 0)
         new_position.setZ(lower_limit.m_value);
-    return { new_position, dz_bottom, dz_top };
+    return {new_position, dz_bottom, dz_top};
 }
diff --git a/Core/Scattering/IFormFactorBorn.h b/Core/Scattering/IFormFactorBorn.h
index 50eb612d4da..821a51b9c3b 100644
--- a/Core/Scattering/IFormFactorBorn.h
+++ b/Core/Scattering/IFormFactorBorn.h
@@ -35,7 +35,7 @@ public:
     IFormFactorBorn();
     ~IFormFactorBorn() override {}
 
-    IFormFactorBorn* clone() const override=0;
+    IFormFactorBorn* clone() const override = 0;
 
     void setAmbientMaterial(Material) override {}
 
@@ -51,7 +51,7 @@ public:
 
     //! Returns scattering amplitude for complex scattering wavevector q=k_i-k_f.
     //! This method is public only for convenience of plotting form factors in Python.
-    virtual complex_t evaluate_for_q(cvector_t q) const=0;
+    virtual complex_t evaluate_for_q(cvector_t q) const = 0;
 
 protected:
     //! Default implementation only allows rotations along z-axis
@@ -61,7 +61,7 @@ protected:
     //! Returns scattering amplitude for complex scattering wavevector q=k_i-k_f in case
     //! of matrix interactions. Default implementation calls evaluate_for_q(q) and
     //! multiplies with the unit matrix.
-    virtual Eigen::Matrix2cd  evaluate_for_q_pol(cvector_t q) const;
+    virtual Eigen::Matrix2cd evaluate_for_q_pol(cvector_t q) const;
 #endif
 
     //! IShape object, used to retrieve vertices (which may be approximate in the case
@@ -86,16 +86,20 @@ struct SlicingEffects {
 #ifdef POLYHEDRAL_DIAGNOSTIC
 //! Information about the latest form factor evaluation. Not thread-safe.
 //! Used only by external test program.
-class Diagnosis {
+class Diagnosis
+{
 public:
     int maxOrder;
     int nExpandedFaces;
     int debmsg;
     bool request_convergence;
-    bool operator!=( const Diagnosis& other ) const {
-        return maxOrder!=other.maxOrder || nExpandedFaces!=other.nExpandedFaces; }
-    friend std::ostream& operator<< (std::ostream& stream, const Diagnosis& diag) {
-        return stream<<" ["<<diag.nExpandedFaces<<":"<<diag.maxOrder<<"]";
+    bool operator!=(const Diagnosis& other) const
+    {
+        return maxOrder != other.maxOrder || nExpandedFaces != other.nExpandedFaces;
+    }
+    friend std::ostream& operator<<(std::ostream& stream, const Diagnosis& diag)
+    {
+        return stream << " [" << diag.nExpandedFaces << ":" << diag.maxOrder << "]";
     }
 };
 #endif
diff --git a/Core/Scattering/ISample.cpp b/Core/Scattering/ISample.cpp
index 4ef83807539..7a7ef60eac6 100644
--- a/Core/Scattering/ISample.cpp
+++ b/Core/Scattering/ISample.cpp
@@ -15,19 +15,18 @@
 #include "ISample.h"
 #include "Exceptions.h"
 #include "ParameterPool.h"
-#include "Exceptions.h"
 #include <algorithm>
 #include <sstream>
 
 std::vector<const Material*> ISample::containedMaterials() const
 {
     std::vector<const Material*> result;
-    if( const Material* p_material = material() )
-        result.push_back( p_material );
-    for(auto child: getChildren() ) {
-        if(const ISample* sample = dynamic_cast<const ISample *>(child)) {
-            for( const Material* p_material: sample->containedMaterials() )
-                result.push_back( p_material );
+    if (const Material* p_material = material())
+        result.push_back(p_material);
+    for (auto child : getChildren()) {
+        if (const ISample* sample = dynamic_cast<const ISample*>(child)) {
+            for (const Material* p_material : sample->containedMaterials())
+                result.push_back(p_material);
         }
     }
     return result;
diff --git a/Core/Scattering/ISample.h b/Core/Scattering/ISample.h
index 938a8b03018..3490af62fe4 100644
--- a/Core/Scattering/ISample.h
+++ b/Core/Scattering/ISample.h
@@ -28,7 +28,7 @@ class BA_CORE_API_ ISample : public ICloneable, public INode
 {
 public:
     //! Returns a clone of this ISample object.
-    ISample* clone() const override=0;
+    ISample* clone() const override = 0;
 
     //! Returns nullptr, unless overwritten to return a specific material.
     virtual const Material* material() const { return nullptr; }
diff --git a/Core/Scattering/Rotations.cpp b/Core/Scattering/Rotations.cpp
index 6263005e107..d92222332c8 100644
--- a/Core/Scattering/Rotations.cpp
+++ b/Core/Scattering/Rotations.cpp
@@ -20,23 +20,19 @@ IRotation* IRotation::createRotation(const Transform3D& transform)
 {
     auto rot_type = transform.getRotationType();
     switch (rot_type) {
-    case Transform3D::XAXIS:
-    {
+    case Transform3D::XAXIS: {
         double angle = transform.calculateRotateXAngle();
         return new RotationX(angle);
     }
-    case Transform3D::YAXIS:
-    {
+    case Transform3D::YAXIS: {
         double angle = transform.calculateRotateYAngle();
         return new RotationY(angle);
     }
-    case Transform3D::ZAXIS:
-    {
+    case Transform3D::ZAXIS: {
         double angle = transform.calculateRotateZAngle();
         return new RotationZ(angle);
     }
-    case Transform3D::EULER:
-    {
+    case Transform3D::EULER: {
         double alpha, beta, gamma;
         transform.calculateEulerAngles(&alpha, &beta, &gamma);
         return new RotationEuler(alpha, beta, gamma);
@@ -61,7 +57,7 @@ IRotation* createProduct(const IRotation& left, const IRotation& right)
 {
     Transform3D tr_left = left.getTransform3D();
     Transform3D tr_right = right.getTransform3D();
-    IRotation *p_result = IRotation::createRotation(tr_left*tr_right);
+    IRotation* p_result = IRotation::createRotation(tr_left * tr_right);
     return p_result;
 }
 
@@ -82,8 +78,7 @@ Transform3D IdentityRotation::getTransform3D() const
 
 //! Constructor of rotation around x-axis
 //! @param angle: rotation angle around x-axis in radians
-RotationX::RotationX(double angle)
-    : m_angle(angle)
+RotationX::RotationX(double angle) : m_angle(angle)
 {
     setName(BornAgain::XRotationType);
     registerParameter(BornAgain::Angle, &m_angle).setUnit(BornAgain::UnitsRad);
@@ -98,8 +93,7 @@ Transform3D RotationX::getTransform3D() const
 
 //! Constructor of rotation around y-axis
 //! @param angle: rotation angle around y-axis in radians
-RotationY::RotationY(double angle)
-    : m_angle(angle)
+RotationY::RotationY(double angle) : m_angle(angle)
 {
     setName(BornAgain::YRotationType);
     registerParameter(BornAgain::Angle, &m_angle).setUnit(BornAgain::UnitsRad);
@@ -114,8 +108,7 @@ Transform3D RotationY::getTransform3D() const
 
 //! Constructor of rotation around z-axis
 //! @param angle: rotation angle around z-axis in radians
-RotationZ::RotationZ(double angle)
-    : m_angle(angle)
+RotationZ::RotationZ(double angle) : m_angle(angle)
 {
     setName(BornAgain::ZRotationType);
     registerParameter(BornAgain::Angle, &m_angle).setUnit(BornAgain::UnitsRad);
@@ -138,7 +131,7 @@ RotationEuler::RotationEuler(double alpha, double beta, double gamma)
 {
     setName(BornAgain::EulerRotationType);
     registerParameter(BornAgain::Alpha, &m_alpha).setUnit(BornAgain::UnitsRad);
-    registerParameter(BornAgain::Beta, &m_beta  ).setUnit(BornAgain::UnitsRad);
+    registerParameter(BornAgain::Beta, &m_beta).setUnit(BornAgain::UnitsRad);
     registerParameter(BornAgain::Gamma, &m_gamma).setUnit(BornAgain::UnitsRad);
 }
 
diff --git a/Core/Scattering/Rotations.h b/Core/Scattering/Rotations.h
index 4534cddba7d..59e3cb3dc15 100644
--- a/Core/Scattering/Rotations.h
+++ b/Core/Scattering/Rotations.h
@@ -28,15 +28,15 @@ public:
     static IRotation* createIdentity();
     virtual ~IRotation() {}
 
-    virtual IRotation* clone() const=0;
+    virtual IRotation* clone() const = 0;
 
     //! Returns a new IRotation object that is the current object's inverse
-    virtual IRotation* createInverse() const=0;
+    virtual IRotation* createInverse() const = 0;
 
     void accept(INodeVisitor* visitor) const { visitor->visit(this); }
 
     //! Returns transformation.
-    virtual Transform3D getTransform3D() const=0;
+    virtual Transform3D getTransform3D() const = 0;
 
     //! Returns true if rotation matrix is identity matrix (no rotations)
     virtual bool isIdentity() const;
@@ -49,7 +49,7 @@ bool IsZRotation(const IRotation& rot);
 class BA_CORE_API_ IdentityRotation : public IRotation
 {
 public:
-    IdentityRotation() =default;
+    IdentityRotation() = default;
 
     IdentityRotation* clone() const { return new IdentityRotation(); }
     IdentityRotation* createInverse() const { return new IdentityRotation(); }
diff --git a/Core/Shapes/AnisoPyramid.cpp b/Core/Shapes/AnisoPyramid.cpp
index 9d2804d4311..ca472ecc436 100644
--- a/Core/Shapes/AnisoPyramid.cpp
+++ b/Core/Shapes/AnisoPyramid.cpp
@@ -21,12 +21,11 @@ AnisoPyramid::AnisoPyramid(double length, double width, double height, double al
 {
     m_vertices.resize(8);
     double cot_alpha = MathFunctions::cot(alpha);
-    double delta = 2.0*height*cot_alpha;
+    double delta = 2.0 * height * cot_alpha;
     auto bottom_face = RectangleVertices(length, width, 0.0);
-    auto top_face = RectangleVertices(length-delta, width-delta, height);
+    auto top_face = RectangleVertices(length - delta, width - delta, height);
     std::move(bottom_face.begin(), bottom_face.end(), m_vertices.begin());
-    std::move(top_face.begin(), top_face.end(), m_vertices.begin()+4);
+    std::move(top_face.begin(), top_face.end(), m_vertices.begin() + 4);
 }
 
-AnisoPyramid::~AnisoPyramid()
-{}
+AnisoPyramid::~AnisoPyramid() {}
diff --git a/Core/Shapes/BiPyramid.cpp b/Core/Shapes/BiPyramid.cpp
index 57d711dbadb..838a5a05c45 100644
--- a/Core/Shapes/BiPyramid.cpp
+++ b/Core/Shapes/BiPyramid.cpp
@@ -21,16 +21,15 @@ BiPyramid::BiPyramid(double length, double height, double height_ratio, double a
 {
     m_vertices.resize(12);
     double cot_alpha = MathFunctions::cot(alpha);
-    double delta_1 = 2.0*height*cot_alpha;
-    double delta_2 = 2.0*height_ratio*height*cot_alpha;
+    double delta_1 = 2.0 * height * cot_alpha;
+    double delta_2 = 2.0 * height_ratio * height * cot_alpha;
     auto bottom_face = RectangleVertices(length, length, 0.0);
-    auto mid_face = RectangleVertices(length+delta_1, length+delta_1, height);
-    auto top_face = RectangleVertices(length+delta_1-delta_2, length+delta_1-delta_2,
-                                      (height_ratio + 1.0)*height);
+    auto mid_face = RectangleVertices(length + delta_1, length + delta_1, height);
+    auto top_face = RectangleVertices(length + delta_1 - delta_2, length + delta_1 - delta_2,
+                                      (height_ratio + 1.0) * height);
     std::move(bottom_face.begin(), bottom_face.end(), m_vertices.begin());
-    std::move(mid_face.begin(), mid_face.end(), m_vertices.begin()+4);
-    std::move(top_face.begin(), top_face.end(), m_vertices.begin()+8);
+    std::move(mid_face.begin(), mid_face.end(), m_vertices.begin() + 4);
+    std::move(top_face.begin(), top_face.end(), m_vertices.begin() + 8);
 }
 
-BiPyramid::~BiPyramid()
-{}
+BiPyramid::~BiPyramid() {}
diff --git a/Core/Shapes/Box.cpp b/Core/Shapes/Box.cpp
index c5d5aed1006..baee11e3cf8 100644
--- a/Core/Shapes/Box.cpp
+++ b/Core/Shapes/Box.cpp
@@ -22,8 +22,7 @@ Box::Box(double length, double width, double height)
     auto bottom_face = RectangleVertices(length, width, 0.0);
     auto top_face = RectangleVertices(length, width, height);
     std::move(bottom_face.begin(), bottom_face.end(), m_vertices.begin());
-    std::move(top_face.begin(), top_face.end(), m_vertices.begin()+4);
+    std::move(top_face.begin(), top_face.end(), m_vertices.begin() + 4);
 }
 
-Box::~Box()
-{}
+Box::~Box() {}
diff --git a/Core/Shapes/Dodecahedron.cpp b/Core/Shapes/Dodecahedron.cpp
index 3690c9fd702..d9e9896d675 100644
--- a/Core/Shapes/Dodecahedron.cpp
+++ b/Core/Shapes/Dodecahedron.cpp
@@ -14,31 +14,29 @@
 
 #include "Dodecahedron.h"
 
-
 Dodecahedron::Dodecahedron(double edge)
 {
     m_vertices = {
-        {  0.8506508083520399*edge,                   0*edge,  0.0},
-        {  0.2628655560595668*edge,  0.8090169943749473*edge,  0.0},
-        { -0.6881909602355868*edge,                 0.5*edge,  0.0},
-        { -0.6881909602355868*edge,                -0.5*edge,  0.0},
-        {  0.2628655560595668*edge, -0.8090169943749473*edge,  0.0},
-        {   1.376381920471174*edge,                   0*edge, 0.8506508083520403*edge},
-        {    0.42532540417602*edge,   1.309016994374947*edge, 0.8506508083520403*edge},
-        {  -1.113516364411607*edge,  0.8090169943749475*edge, 0.8506508083520403*edge},
-        {  -1.113516364411607*edge, -0.8090169943749475*edge, 0.8506508083520403*edge},
-        {    0.42532540417602*edge,  -1.309016994374947*edge, 0.8506508083520403*edge},
-        {  -1.376381920471174*edge,                   0*edge,  1.3763819204711737*edge},
-        {   -0.42532540417602*edge,  -1.309016994374947*edge,  1.3763819204711737*edge},
-        {   1.113516364411607*edge, -0.8090169943749475*edge,  1.3763819204711737*edge},
-        {   1.113516364411607*edge,  0.8090169943749475*edge,  1.3763819204711737*edge},
-        {   -0.42532540417602*edge,   1.309016994374947*edge,  1.3763819204711737*edge},
-        { -0.8506508083520399*edge,                   0*edge,   2.227032728823214*edge},
-        { -0.2628655560595668*edge, -0.8090169943749473*edge,   2.227032728823214*edge},
-        {  0.6881909602355868*edge,                -0.5*edge,   2.227032728823214*edge},
-        {  0.6881909602355868*edge,                 0.5*edge,   2.227032728823214*edge},
-        { -0.2628655560595668*edge,  0.8090169943749473*edge,   2.227032728823214*edge} };
+        {0.8506508083520399 * edge, 0 * edge, 0.0},
+        {0.2628655560595668 * edge, 0.8090169943749473 * edge, 0.0},
+        {-0.6881909602355868 * edge, 0.5 * edge, 0.0},
+        {-0.6881909602355868 * edge, -0.5 * edge, 0.0},
+        {0.2628655560595668 * edge, -0.8090169943749473 * edge, 0.0},
+        {1.376381920471174 * edge, 0 * edge, 0.8506508083520403 * edge},
+        {0.42532540417602 * edge, 1.309016994374947 * edge, 0.8506508083520403 * edge},
+        {-1.113516364411607 * edge, 0.8090169943749475 * edge, 0.8506508083520403 * edge},
+        {-1.113516364411607 * edge, -0.8090169943749475 * edge, 0.8506508083520403 * edge},
+        {0.42532540417602 * edge, -1.309016994374947 * edge, 0.8506508083520403 * edge},
+        {-1.376381920471174 * edge, 0 * edge, 1.3763819204711737 * edge},
+        {-0.42532540417602 * edge, -1.309016994374947 * edge, 1.3763819204711737 * edge},
+        {1.113516364411607 * edge, -0.8090169943749475 * edge, 1.3763819204711737 * edge},
+        {1.113516364411607 * edge, 0.8090169943749475 * edge, 1.3763819204711737 * edge},
+        {-0.42532540417602 * edge, 1.309016994374947 * edge, 1.3763819204711737 * edge},
+        {-0.8506508083520399 * edge, 0 * edge, 2.227032728823214 * edge},
+        {-0.2628655560595668 * edge, -0.8090169943749473 * edge, 2.227032728823214 * edge},
+        {0.6881909602355868 * edge, -0.5 * edge, 2.227032728823214 * edge},
+        {0.6881909602355868 * edge, 0.5 * edge, 2.227032728823214 * edge},
+        {-0.2628655560595668 * edge, 0.8090169943749473 * edge, 2.227032728823214 * edge}};
 }
 
-Dodecahedron::~Dodecahedron()
-{}
+Dodecahedron::~Dodecahedron() {}
diff --git a/Core/Shapes/Dot.cpp b/Core/Shapes/Dot.cpp
index ad86df16118..7f4cd05453b 100644
--- a/Core/Shapes/Dot.cpp
+++ b/Core/Shapes/Dot.cpp
@@ -14,11 +14,9 @@
 
 #include "Dot.h"
 
-
 Dot::Dot()
 {
     m_vertices.push_back(kvector_t(0.0, 0.0, 0.0));
 }
 
-Dot::~Dot()
-{}
+Dot::~Dot() {}
diff --git a/Core/Shapes/DoubleEllipse.cpp b/Core/Shapes/DoubleEllipse.cpp
index a28e9580972..e0553b93afc 100644
--- a/Core/Shapes/DoubleEllipse.cpp
+++ b/Core/Shapes/DoubleEllipse.cpp
@@ -23,8 +23,7 @@ DoubleEllipse::DoubleEllipse(double r0_x, double r0_y, double z, double rz_x, do
     auto top_face = EllipseVertices(rz_x, rz_y, z);
     m_vertices.resize(n_bottom + top_face.size());
     std::move(bottom_face.begin(), bottom_face.end(), m_vertices.begin());
-    std::move(top_face.begin(), top_face.end(), m_vertices.begin()+n_bottom);
+    std::move(top_face.begin(), top_face.end(), m_vertices.begin() + n_bottom);
 }
 
-DoubleEllipse::~DoubleEllipse()
-{}
+DoubleEllipse::~DoubleEllipse() {}
diff --git a/Core/Shapes/IShape.cpp b/Core/Shapes/IShape.cpp
index fd5c0dd6342..6908bc04c03 100644
--- a/Core/Shapes/IShape.cpp
+++ b/Core/Shapes/IShape.cpp
@@ -27,47 +27,42 @@ std::vector<kvector_t> IShape::vertices() const
 
 std::vector<kvector_t> RectangleVertices(double length, double width, double z)
 {
-    std::vector<kvector_t> result = {
-        {  length/2.0,  width/2.0, z },
-        { -length/2.0,  width/2.0, z },
-        { -length/2.0, -width/2.0, z },
-        {  length/2.0, -width/2.0, z } };
+    std::vector<kvector_t> result = {{length / 2.0, width / 2.0, z},
+                                     {-length / 2.0, width / 2.0, z},
+                                     {-length / 2.0, -width / 2.0, z},
+                                     {length / 2.0, -width / 2.0, z}};
     return result;
 }
 
 std::vector<kvector_t> TriangleVertices(double length, double z)
 {
     static const double sqrt3 = std::sqrt(3.0);
-    double L = length/sqrt3;
+    double L = length / sqrt3;
     std::vector<kvector_t> result = {
-        {      L,         0.0, z },
-        { -L/2.0,  length/2.0, z },
-        { -L/2.0, -length/2.0, z } };
+        {L, 0.0, z}, {-L / 2.0, length / 2.0, z}, {-L / 2.0, -length / 2.0, z}};
     return result;
 }
 
 std::vector<kvector_t> HexagonVertices(double length, double z)
 {
     static const double sqrt3 = std::sqrt(3.0);
-    std::vector<kvector_t> result = {
-        {      length,               0.0, z },
-        {  length/2.0,  length*sqrt3/2.0, z },
-        { -length/2.0,  length*sqrt3/2.0, z },
-        {     -length,               0.0, z },
-        { -length/2.0, -length*sqrt3/2.0, z },
-        {  length/2.0, -length*sqrt3/2.0, z } };
+    std::vector<kvector_t> result = {{length, 0.0, z},
+                                     {length / 2.0, length * sqrt3 / 2.0, z},
+                                     {-length / 2.0, length * sqrt3 / 2.0, z},
+                                     {-length, 0.0, z},
+                                     {-length / 2.0, -length * sqrt3 / 2.0, z},
+                                     {length / 2.0, -length * sqrt3 / 2.0, z}};
     return result;
 }
 
 std::vector<kvector_t> EllipseVertices(double r_x, double r_y, double z)
 {
-    static constexpr double delta_angle = 2.0*M_PI/IShape::N_Circle;
+    static constexpr double delta_angle = 2.0 * M_PI / IShape::N_Circle;
     std::vector<kvector_t> result(IShape::N_Circle);
-    for (size_t i=0; i<IShape::N_Circle; ++i)
-    {
-        double angle = i*delta_angle;
-        double x = r_x*std::cos(angle);
-        double y = r_y*std::sin(angle);
+    for (size_t i = 0; i < IShape::N_Circle; ++i) {
+        double angle = i * delta_angle;
+        double x = r_x * std::cos(angle);
+        double y = r_y * std::sin(angle);
         result[i] = kvector_t(x, y, z);
     }
     return result;
diff --git a/Core/Shapes/IShape.h b/Core/Shapes/IShape.h
index b1c837964f9..3bdfcfe1d05 100644
--- a/Core/Shapes/IShape.h
+++ b/Core/Shapes/IShape.h
@@ -34,6 +34,7 @@ public:
     //! Retrieves a list of the vertices constituting this concrete shape
     virtual std::vector<kvector_t> vertices() const;
     static const size_t N_Circle;
+
 protected:
     //! List of vertices initialized during construction
     std::vector<kvector_t> m_vertices;
diff --git a/Core/Shapes/Icosahedron.cpp b/Core/Shapes/Icosahedron.cpp
index 705f1f935f4..3498ca8e23f 100644
--- a/Core/Shapes/Icosahedron.cpp
+++ b/Core/Shapes/Icosahedron.cpp
@@ -21,19 +21,18 @@ Icosahedron::Icosahedron(double edge)
     // 2. radius of inscribed sphere = sqrt(3)/12*(3+sqrt(5))*edge
 
     m_vertices = {
-        { -0.57735026918962573*edge,                  0.0*edge, 0.0},
-        {  0.28867513459481281*edge,                  0.5*edge, 0.0},
-        {  0.28867513459481281*edge,                 -0.5*edge, 0.0},
-        {  0.93417235896271578*edge,                  0.0*edge, 0.57735026918962562*edge},
-        { -0.46708617948135783*edge,  0.80901699437494756*edge, 0.57735026918962562*edge},
-        { -0.46708617948135783*edge, -0.80901699437494756*edge, 0.57735026918962562*edge},
-        { -0.93417235896271578*edge,                  0.0*edge, 0.93417235896271589*edge},
-        {  0.46708617948135783*edge,  0.80901699437494756*edge, 0.93417235896271589*edge},
-        {  0.46708617948135783*edge, -0.80901699437494756*edge, 0.93417235896271589*edge},
-        {  0.57735026918962573*edge,                  0.0*edge, 1.5115226281523415*edge},
-        { -0.28867513459481281*edge,                  0.5*edge, 1.5115226281523415*edge},
-        { -0.28867513459481281*edge,                 -0.5*edge, 1.5115226281523415*edge} };
+        {-0.57735026918962573 * edge, 0.0 * edge, 0.0},
+        {0.28867513459481281 * edge, 0.5 * edge, 0.0},
+        {0.28867513459481281 * edge, -0.5 * edge, 0.0},
+        {0.93417235896271578 * edge, 0.0 * edge, 0.57735026918962562 * edge},
+        {-0.46708617948135783 * edge, 0.80901699437494756 * edge, 0.57735026918962562 * edge},
+        {-0.46708617948135783 * edge, -0.80901699437494756 * edge, 0.57735026918962562 * edge},
+        {-0.93417235896271578 * edge, 0.0 * edge, 0.93417235896271589 * edge},
+        {0.46708617948135783 * edge, 0.80901699437494756 * edge, 0.93417235896271589 * edge},
+        {0.46708617948135783 * edge, -0.80901699437494756 * edge, 0.93417235896271589 * edge},
+        {0.57735026918962573 * edge, 0.0 * edge, 1.5115226281523415 * edge},
+        {-0.28867513459481281 * edge, 0.5 * edge, 1.5115226281523415 * edge},
+        {-0.28867513459481281 * edge, -0.5 * edge, 1.5115226281523415 * edge}};
 }
 
-Icosahedron::~Icosahedron()
-{}
+Icosahedron::~Icosahedron() {}
diff --git a/Core/Shapes/Pyramid3.cpp b/Core/Shapes/Pyramid3.cpp
index fc7fe7892c9..22830871b7d 100644
--- a/Core/Shapes/Pyramid3.cpp
+++ b/Core/Shapes/Pyramid3.cpp
@@ -23,12 +23,11 @@ Pyramid3::Pyramid3(double length, double height, double alpha)
 {
     m_vertices.resize(6);
     double cot_alpha = MathFunctions::cot(alpha);
-    double delta = 2.0*sqrt3*height*cot_alpha;
+    double delta = 2.0 * sqrt3 * height * cot_alpha;
     auto bottom_face = TriangleVertices(length, 0.0);
-    auto top_face = TriangleVertices(length-delta, height);
+    auto top_face = TriangleVertices(length - delta, height);
     std::move(bottom_face.begin(), bottom_face.end(), m_vertices.begin());
-    std::move(top_face.begin(), top_face.end(), m_vertices.begin()+3);
+    std::move(top_face.begin(), top_face.end(), m_vertices.begin() + 3);
 }
 
-Pyramid3::~Pyramid3()
-{}
+Pyramid3::~Pyramid3() {}
diff --git a/Core/Shapes/Pyramid3.h b/Core/Shapes/Pyramid3.h
index cf774b9c967..4b997e681e6 100644
--- a/Core/Shapes/Pyramid3.h
+++ b/Core/Shapes/Pyramid3.h
@@ -22,6 +22,7 @@ class Pyramid3 : public IShape
 public:
     Pyramid3(double length, double height, double alpha);
     ~Pyramid3();
+
 private:
     static const double sqrt3;
 };
diff --git a/Core/Shapes/Pyramid6.cpp b/Core/Shapes/Pyramid6.cpp
index e0c99894baa..de10099847c 100644
--- a/Core/Shapes/Pyramid6.cpp
+++ b/Core/Shapes/Pyramid6.cpp
@@ -23,12 +23,11 @@ Pyramid6::Pyramid6(double length, double height, double alpha)
 {
     m_vertices.resize(12);
     double cot_alpha = MathFunctions::cot(alpha);
-    double delta = height*cot_alpha;
+    double delta = height * cot_alpha;
     auto bottom_face = HexagonVertices(length, 0.0);
-    auto top_face = HexagonVertices(length-delta, height);
+    auto top_face = HexagonVertices(length - delta, height);
     std::move(bottom_face.begin(), bottom_face.end(), m_vertices.begin());
-    std::move(top_face.begin(), top_face.end(), m_vertices.begin()+6);
+    std::move(top_face.begin(), top_face.end(), m_vertices.begin() + 6);
 }
 
-Pyramid6::~Pyramid6()
-{}
+Pyramid6::~Pyramid6() {}
diff --git a/Core/Shapes/Pyramid6.h b/Core/Shapes/Pyramid6.h
index c81d9213814..7fe6e3d3faf 100644
--- a/Core/Shapes/Pyramid6.h
+++ b/Core/Shapes/Pyramid6.h
@@ -22,6 +22,7 @@ class Pyramid6 : public IShape
 public:
     Pyramid6(double length, double height, double alpha);
     ~Pyramid6();
+
 private:
     static const double sqrt3;
 };
diff --git a/Core/Shapes/RippleCosine.cpp b/Core/Shapes/RippleCosine.cpp
index 0e7071c59c2..dbcb9ed6f0d 100644
--- a/Core/Shapes/RippleCosine.cpp
+++ b/Core/Shapes/RippleCosine.cpp
@@ -19,16 +19,14 @@
 RippleCosine::RippleCosine(double length, double width, double height)
 {
     size_t n_y = IShape::N_Circle + 1;
-    double y_step = width/(IShape::N_Circle);
-    m_vertices.resize(2*n_y);
-    for (size_t i=0; i<n_y; ++i)
-    {
-        double y = i*y_step - width/2.0;
-        double z = height*(1.0 + std::cos(2.0*M_PI*y/width))/2.0;
-        m_vertices[i] = kvector_t(length/2.0, y, z);
-        m_vertices[n_y+i] = kvector_t(-length/2.0, y, z);
+    double y_step = width / (IShape::N_Circle);
+    m_vertices.resize(2 * n_y);
+    for (size_t i = 0; i < n_y; ++i) {
+        double y = i * y_step - width / 2.0;
+        double z = height * (1.0 + std::cos(2.0 * M_PI * y / width)) / 2.0;
+        m_vertices[i] = kvector_t(length / 2.0, y, z);
+        m_vertices[n_y + i] = kvector_t(-length / 2.0, y, z);
     }
 }
 
-RippleCosine::~RippleCosine()
-{}
+RippleCosine::~RippleCosine() {}
diff --git a/Core/Shapes/RippleSawtooth.cpp b/Core/Shapes/RippleSawtooth.cpp
index aa06f30e264..fd87bbbf3c6 100644
--- a/Core/Shapes/RippleSawtooth.cpp
+++ b/Core/Shapes/RippleSawtooth.cpp
@@ -14,19 +14,17 @@
 
 #include "RippleSawtooth.h"
 
-
 RippleSawtooth::RippleSawtooth(double length, double width, double height, double asymmetry)
 {
-    double ymax = width/2.0 - asymmetry;
-    double ymin = -width/2.0 - asymmetry;
+    double ymax = width / 2.0 - asymmetry;
+    double ymin = -width / 2.0 - asymmetry;
     m_vertices.resize(6);
-    m_vertices[0] = kvector_t(length/2.0, ymax, 0.0);
-    m_vertices[1] = kvector_t(length/2.0, ymin, 0.0);
-    m_vertices[2] = kvector_t(length/2.0, 0.0, height);
-    m_vertices[3] = kvector_t(-length/2.0, ymax, 0.0);
-    m_vertices[4] = kvector_t(-length/2.0, ymin, 0.0);
-    m_vertices[5] = kvector_t(-length/2.0, 0.0, height);
+    m_vertices[0] = kvector_t(length / 2.0, ymax, 0.0);
+    m_vertices[1] = kvector_t(length / 2.0, ymin, 0.0);
+    m_vertices[2] = kvector_t(length / 2.0, 0.0, height);
+    m_vertices[3] = kvector_t(-length / 2.0, ymax, 0.0);
+    m_vertices[4] = kvector_t(-length / 2.0, ymin, 0.0);
+    m_vertices[5] = kvector_t(-length / 2.0, 0.0, height);
 }
 
-RippleSawtooth::~RippleSawtooth()
-{}
+RippleSawtooth::~RippleSawtooth() {}
diff --git a/Core/Shapes/Triangle.cpp b/Core/Shapes/Triangle.cpp
index 6dce0a23b15..260b228c9ae 100644
--- a/Core/Shapes/Triangle.cpp
+++ b/Core/Shapes/Triangle.cpp
@@ -14,11 +14,9 @@
 
 #include "Triangle.h"
 
-
 Triangle::Triangle(double length, double z)
 {
     m_vertices = TriangleVertices(length, z);
 }
 
-Triangle::~Triangle()
-{}
+Triangle::~Triangle() {}
diff --git a/Core/Shapes/TruncatedCube.cpp b/Core/Shapes/TruncatedCube.cpp
index 07a1c92d7d0..622b1b268c4 100644
--- a/Core/Shapes/TruncatedCube.cpp
+++ b/Core/Shapes/TruncatedCube.cpp
@@ -14,37 +14,18 @@
 
 #include "TruncatedCube.h"
 
-
 TruncatedCube::TruncatedCube(double length, double removed_length)
 {
-    double L2 = length/2.0;
+    double L2 = length / 2.0;
     double t = removed_length;
-    m_vertices = {
-        { -L2+t, -L2  , 0.0 },
-        { -L2  , -L2+t, 0.0 },
-        { -L2  , -L2  , t   },
-        {  L2-t, -L2  , 0.0 },
-        {  L2  , -L2+t, 0.0 },
-        {  L2  , -L2  , t   },
-        { -L2+t,  L2  , 0.0 },
-        { -L2  ,  L2-t, 0.0 },
-        { -L2  ,  L2  , t   },
-        {  L2-t,  L2  , 0.0 },
-        {  L2  ,  L2-t, 0.0 },
-        {  L2  ,  L2  , t   },
-        { -L2+t, -L2  ,  length   },
-        { -L2  , -L2+t,  length   },
-        { -L2  , -L2  ,  length-t },
-        {  L2-t, -L2  ,  length   },
-        {  L2  , -L2+t,  length   },
-        {  L2  , -L2  ,  length-t },
-        { -L2+t,  L2  ,  length   },
-        { -L2  ,  L2-t,  length   },
-        { -L2  ,  L2  ,  length-t },
-        {  L2-t,  L2  ,  length   },
-        {  L2  ,  L2-t,  length   },
-        {  L2  ,  L2  ,  length-t } };
+    m_vertices = {{-L2 + t, -L2, 0.0},    {-L2, -L2 + t, 0.0},    {-L2, -L2, t},
+                  {L2 - t, -L2, 0.0},     {L2, -L2 + t, 0.0},     {L2, -L2, t},
+                  {-L2 + t, L2, 0.0},     {-L2, L2 - t, 0.0},     {-L2, L2, t},
+                  {L2 - t, L2, 0.0},      {L2, L2 - t, 0.0},      {L2, L2, t},
+                  {-L2 + t, -L2, length}, {-L2, -L2 + t, length}, {-L2, -L2, length - t},
+                  {L2 - t, -L2, length},  {L2, -L2 + t, length},  {L2, -L2, length - t},
+                  {-L2 + t, L2, length},  {-L2, L2 - t, length},  {-L2, L2, length - t},
+                  {L2 - t, L2, length},   {L2, L2 - t, length},   {L2, L2, length - t}};
 }
 
-TruncatedCube::~TruncatedCube()
-{}
+TruncatedCube::~TruncatedCube() {}
diff --git a/Core/Shapes/TruncatedEllipsoid.cpp b/Core/Shapes/TruncatedEllipsoid.cpp
index 6e7412031a7..4d0f708db00 100644
--- a/Core/Shapes/TruncatedEllipsoid.cpp
+++ b/Core/Shapes/TruncatedEllipsoid.cpp
@@ -19,20 +19,19 @@
 
 TruncatedEllipsoid::TruncatedEllipsoid(double r_x, double r_y, double r_z, double height, double dh)
 {
-    static const int n_heights = std::max(2, static_cast<int>(
-            std::round(static_cast<double>(IShape::N_Circle)*height/2.0/r_z + 0.5)) );
-    double h_step = (height-dh)/(n_heights-1);
-    m_vertices.resize(n_heights*IShape::N_Circle);
+    static const int n_heights =
+        std::max(2, static_cast<int>(std::round(
+                        static_cast<double>(IShape::N_Circle) * height / 2.0 / r_z + 0.5)));
+    double h_step = (height - dh) / (n_heights - 1);
+    m_vertices.resize(n_heights * IShape::N_Circle);
     auto it = m_vertices.begin();
-    for (int i=0; i<n_heights; ++i)
-    {
-        double z = i*h_step;
-        double radius_factor = std::sqrt(1.0 - std::pow((z+r_z-height)/r_z, 2));
-        auto ellipse = EllipseVertices(radius_factor*r_x, radius_factor*r_y, i*h_step);
+    for (int i = 0; i < n_heights; ++i) {
+        double z = i * h_step;
+        double radius_factor = std::sqrt(1.0 - std::pow((z + r_z - height) / r_z, 2));
+        auto ellipse = EllipseVertices(radius_factor * r_x, radius_factor * r_y, i * h_step);
         std::move(ellipse.begin(), ellipse.end(), it);
         it = it + ellipse.size();
     }
 }
 
-TruncatedEllipsoid::~TruncatedEllipsoid()
-{}
+TruncatedEllipsoid::~TruncatedEllipsoid() {}
diff --git a/Core/Simulation/DepthProbeSimulation.cpp b/Core/Simulation/DepthProbeSimulation.cpp
index c863aa54925..ea947757b5b 100644
--- a/Core/Simulation/DepthProbeSimulation.cpp
+++ b/Core/Simulation/DepthProbeSimulation.cpp
@@ -13,26 +13,26 @@
 // ************************************************************************** //
 
 #include "DepthProbeSimulation.h"
+#include "DepthProbeComputation.h"
 #include "Distributions.h"
 #include "Histogram1D.h"
 #include "IBackground.h"
 #include "IFootprintFactor.h"
 #include "IMultiLayerBuilder.h"
+#include "MaterialUtils.h"
 #include "MathConstants.h"
 #include "MultiLayer.h"
-#include "MaterialUtils.h"
 #include "ParameterPool.h"
 #include "RealParameter.h"
-#include "DepthProbeComputation.h"
-#include "SpecularDetector1D.h"
 #include "SimpleUnitConverters.h"
+#include "SpecularDetector1D.h"
 
 namespace
 {
 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;
-}
+} // namespace
 
 DepthProbeSimulation::DepthProbeSimulation() : Simulation()
 {
@@ -70,7 +70,7 @@ SimulationResult DepthProbeSimulation::result() const
 }
 
 void DepthProbeSimulation::setBeamParameters(double lambda, int nbins, double alpha_i_min,
-                                           double alpha_i_max, const IFootprintFactor* beam_shape)
+                                             double alpha_i_max, const IFootprintFactor* beam_shape)
 {
     FixedBinAxis axis("alpha_i", static_cast<size_t>(nbins), alpha_i_min, alpha_i_max);
     setBeamParameters(lambda, axis, beam_shape);
@@ -114,9 +114,7 @@ std::unique_ptr<IUnitConverter> DepthProbeSimulation::createUnitConverter() cons
 }
 
 DepthProbeSimulation::DepthProbeSimulation(const DepthProbeSimulation& other)
-    : Simulation(other)
-    , m_sim_elements(other.m_sim_elements)
-    , m_cache(other.m_cache)
+    : Simulation(other), m_sim_elements(other.m_sim_elements), m_cache(other.m_cache)
 {
     if (other.m_alpha_axis)
         m_alpha_axis.reset(other.m_alpha_axis->clone());
@@ -129,17 +127,19 @@ DepthProbeSimulation::DepthProbeSimulation(const DepthProbeSimulation& other)
 }
 
 void DepthProbeSimulation::setBeamParameters(double lambda, const IAxis& alpha_axis,
-                                           const IFootprintFactor* beam_shape)
+                                             const IFootprintFactor* beam_shape)
 {
     if (lambda <= 0.0)
         throw std::runtime_error(
             "Error in DepthProbeSimulation::setBeamParameters: wavelength must be positive.");
     if (alpha_axis.getMin() < 0.0)
-        throw std::runtime_error("Error in DepthProbeSimulation::setBeamParameters: minimum value on "
-                                 "angle axis is negative.");
+        throw std::runtime_error(
+            "Error in DepthProbeSimulation::setBeamParameters: minimum value on "
+            "angle axis is negative.");
     if (alpha_axis.getMin() >= alpha_axis.getMax())
-        throw std::runtime_error("Error in DepthProbeSimulation::setBeamParameters: maximal value on "
-                                 "angle axis is less or equal to the minimal one.");
+        throw std::runtime_error(
+            "Error in DepthProbeSimulation::setBeamParameters: maximal value on "
+            "angle axis is less or equal to the minimal one.");
     if (alpha_axis.size() == 0)
         throw std::runtime_error(
             "Error in DepthProbeSimulation::setBeamParameters: angle axis is empty");
@@ -167,8 +167,7 @@ void DepthProbeSimulation::initSimulationElementVector()
     m_cache.resize(m_sim_elements.size(), std::valarray<double>(0.0, getZAxis()->size()));
 }
 
-std::vector<DepthProbeElement>
-DepthProbeSimulation::generateSimulationElements(const Beam& beam)
+std::vector<DepthProbeElement> DepthProbeSimulation::generateSimulationElements(const Beam& beam)
 {
     std::vector<DepthProbeElement> result;
 
@@ -223,8 +222,8 @@ void DepthProbeSimulation::validateParametrization(const ParameterDistribution&
         return;
 
     std::unique_ptr<ParameterPool> parameter_pool(createParameterTree());
-    const std::vector<RealParameter*> names
-        = parameter_pool->getMatchedParameters(par_distr.getMainParameterName());
+    const std::vector<RealParameter*> names =
+        parameter_pool->getMatchedParameters(par_distr.getMainParameterName());
     for (const auto par : names)
         if (par->getName().find(BornAgain::Inclination) != std::string::npos && !zero_mean)
             throw std::runtime_error("Error in DepthProbeSimulation: parameter distribution of "
diff --git a/Core/Simulation/DepthProbeSimulation.h b/Core/Simulation/DepthProbeSimulation.h
index 602d8bec952..b0b016edc37 100644
--- a/Core/Simulation/DepthProbeSimulation.h
+++ b/Core/Simulation/DepthProbeSimulation.h
@@ -1,10 +1,10 @@
 #ifndef DEPTHPROBESIMULATION_H
 #define DEPTHPROBESIMULATION_H
 
-#include "Simulation.h"
 #include "DepthProbeElement.h"
 #include "ILayerRTCoefficients.h"
 #include "OutputData.h"
+#include "Simulation.h"
 
 #include <vector>
 
@@ -27,7 +27,7 @@ public:
 
     DepthProbeSimulation* clone() const override;
 
-    void accept(INodeVisitor* visitor) const override final {visitor->visit(this);}
+    void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     //! Returns the results of the simulation in a format that supports unit conversion and export
     //! to numpy arrays
diff --git a/Core/Simulation/MPISimulation.cpp b/Core/Simulation/MPISimulation.cpp
index 3b2b9cc032c..b9b083ec907 100644
--- a/Core/Simulation/MPISimulation.cpp
+++ b/Core/Simulation/MPISimulation.cpp
@@ -17,8 +17,8 @@
 
 #ifdef BORNAGAIN_MPI
 
-#include <mpi.h>
 #include "Simulation.h"
+#include <mpi.h>
 
 // -----------------------------------------------------------------------------
 // MPI support
@@ -32,7 +32,7 @@ void MPISimulation::runSimulation(Simulation* simulation)
     MPI_Comm_size(MPI_COMM_WORLD, &world_size);
     MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
 
-    if(world_size == 1) {
+    if (world_size == 1) {
         simulation->runSimulation();
         return;
     }
@@ -48,17 +48,17 @@ void MPISimulation::runSimulation(Simulation* simulation)
     sim_options.setThreadInfo(info);
     simulation->runSimulation();
 
-    if(world_rank != 0) {
+    if (world_rank != 0) {
         std::vector<double> raw = simulation->rawResults();
         MPI_Send(&raw[0], raw.size(), MPI_DOUBLE, 0, 0, MPI_COMM_WORLD);
     }
-    if(world_rank == 0) {
+    if (world_rank == 0) {
         auto sum_of_raw = simulation->rawResults();
         size_t total_size = sum_of_raw.size();
-        for(int i=1; i<world_size; ++i) {
+        for (int i = 1; i < world_size; ++i) {
             std::vector<double> raw(total_size);
             MPI_Recv(&raw[0], total_size, MPI_DOUBLE, i, 0, MPI_COMM_WORLD, &st);
-            for(size_t i_raw=0; i_raw<total_size; ++i_raw)
+            for (size_t i_raw = 0; i_raw < total_size; ++i_raw)
                 sum_of_raw[i_raw] += raw[i_raw];
         }
         simulation->setRawResults(sum_of_raw);
@@ -76,6 +76,6 @@ void MPISimulation::runSimulation(Simulation* /* simulation */)
 {
     throw std::runtime_error(
         "MPISimulation::runSimulation() -> Error! Can't run MPI simulation. "
-        "The package was compiled without MPI support (compile with -DBORNAGAIN_MPI=ON)" );
+        "The package was compiled without MPI support (compile with -DBORNAGAIN_MPI=ON)");
 }
-#endif  // BORNAGAIN_MPI
+#endif // BORNAGAIN_MPI
diff --git a/Core/Simulation/MPISimulation.h b/Core/Simulation/MPISimulation.h
index d0927d8f725..7b874c9c676 100644
--- a/Core/Simulation/MPISimulation.h
+++ b/Core/Simulation/MPISimulation.h
@@ -21,7 +21,7 @@ class Simulation;
 class MPISimulation
 {
 public:
-    void runSimulation(Simulation *simulation);
+    void runSimulation(Simulation* simulation);
 };
 
 #endif // MPISIMULATION_H
diff --git a/Core/Simulation/Simulation.h b/Core/Simulation/Simulation.h
index 63359b799a5..deb94d54892 100644
--- a/Core/Simulation/Simulation.h
+++ b/Core/Simulation/Simulation.h
@@ -15,16 +15,16 @@
 #ifndef SIMULATION_H
 #define SIMULATION_H
 
-#include "INode.h"
 #include "DistributionHandler.h"
 #include "IDetector2D.h"
+#include "INode.h"
 #include "Instrument.h"
 #include "ProgressHandler.h"
+#include "SampleProvider.h"
 #include "SimulationOptions.h"
 #include "SimulationResult.h"
-#include "SampleProvider.h"
 
-template<class T> class OutputData;
+template <class T> class OutputData;
 class IBackground;
 class IComputation;
 class IMultiLayerBuilder;
@@ -43,7 +43,7 @@ public:
     Simulation(const std::shared_ptr<IMultiLayerBuilder> p_sample_builder);
     virtual ~Simulation();
 
-    virtual Simulation* clone() const =0;
+    virtual Simulation* clone() const = 0;
 
     //! Put into a clean state for running a simulation
     virtual void prepareSimulation();
@@ -82,11 +82,12 @@ public:
 
     //! Returns the results of the simulation in a format that supports unit conversion and export
     //! to numpy arrays
-    virtual SimulationResult result() const=0;
+    virtual SimulationResult result() const = 0;
 
-    void addParameterDistribution(
-        const std::string& param_name, const IDistribution1D& distribution, size_t nbr_samples,
-        double sigma_factor=0.0, const RealLimits& limits = RealLimits());
+    void addParameterDistribution(const std::string& param_name,
+                                  const IDistribution1D& distribution, size_t nbr_samples,
+                                  double sigma_factor = 0.0,
+                                  const RealLimits& limits = RealLimits());
     void addParameterDistribution(const ParameterDistribution& par_distr);
     const DistributionHandler& getDistributionHandler() const { return m_distribution_handler; }
 
@@ -100,6 +101,7 @@ public:
     std::vector<const INode*> getChildren() const;
 
     friend class MPISimulation;
+
 protected:
     Simulation(const Simulation& other);
 
@@ -133,8 +135,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
-    virtual std::unique_ptr<IComputation>
-    generateSingleThreadedComputation(size_t start, size_t n_elements) = 0;
+    virtual std::unique_ptr<IComputation> generateSingleThreadedComputation(size_t start,
+                                                                            size_t n_elements) = 0;
 
     //! Checks the distribution validity for simulation.
     virtual void validateParametrization(const ParameterDistribution&) const {}
@@ -151,8 +153,8 @@ private:
     virtual void moveDataFromCache() = 0;
 
     // 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;
+    virtual std::vector<double> rawResults() const = 0;
+    virtual void setRawResults(const std::vector<double>& raw_data) = 0;
 };
 
 #endif // SIMULATION_H
diff --git a/Core/Simulation/SpecularSimulation.cpp b/Core/Simulation/SpecularSimulation.cpp
index 31711d0834a..073118eaa0f 100644
--- a/Core/Simulation/SpecularSimulation.cpp
+++ b/Core/Simulation/SpecularSimulation.cpp
@@ -20,9 +20,9 @@
 #include "IFootprintFactor.h"
 #include "IMultiLayerBuilder.h"
 #include "ISpecularScan.h"
+#include "MaterialUtils.h"
 #include "MathConstants.h"
 #include "MultiLayer.h"
-#include "MaterialUtils.h"
 #include "ParameterPool.h"
 #include "PointwiseAxis.h"
 #include "RealParameter.h"
@@ -35,12 +35,12 @@ namespace
 {
 // TODO: remove when pointwise resolution is implemented
 std::unique_ptr<ISpecularScan> mangledDataHandler(const ISpecularScan& data_handler,
-                                                         const Beam& beam);
+                                                  const Beam& beam);
 
 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;
-}
+} // namespace
 
 SpecularSimulation::SpecularSimulation() : Simulation()
 {
@@ -152,7 +152,7 @@ SpecularSimulation::generateSimulationElements(const Beam& beam)
     const auto& polarization = beam.getPolarization();
     const auto& analyzer = m_instrument.getDetector()->detectionProperties().analyzerOperator();
 
-    for (auto& elem: elements)
+    for (auto& elem : elements)
         elem.setPolarizationHandler({polarization, analyzer});
 
     return elements;
@@ -168,10 +168,9 @@ SpecularSimulation::generateSingleThreadedComputation(size_t start, size_t n_ele
 }
 
 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)
+    : 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();
 }
@@ -190,8 +189,8 @@ void SpecularSimulation::validateParametrization(const ParameterDistribution& pa
         return;
 
     std::unique_ptr<ParameterPool> parameter_pool(createParameterTree());
-    const std::vector<RealParameter*> names
-        = parameter_pool->getMatchedParameters(par_distr.getMainParameterName());
+    const std::vector<RealParameter*> names =
+        parameter_pool->getMatchedParameters(par_distr.getMainParameterName());
     for (const auto par : names)
         if (par->getName().find(BornAgain::Inclination) != std::string::npos && !zero_mean)
             throw std::runtime_error("Error in SpecularSimulation: parameter distribution of "
@@ -272,7 +271,7 @@ std::vector<double> SpecularSimulation::rawResults() const
 {
     std::vector<double> result;
     result.resize(m_sim_elements.size());
-    for (unsigned i=0; i<m_sim_elements.size(); ++i) {
+    for (unsigned i = 0; i < m_sim_elements.size(); ++i) {
         result[i] = m_sim_elements[i].getIntensity();
     }
     return result;
@@ -284,16 +283,17 @@ void SpecularSimulation::setRawResults(const std::vector<double>& raw_data)
     if (raw_data.size() != m_sim_elements.size())
         throw std::runtime_error("SpecularSimulation::setRawResults: size of vector passed as "
                                  "argument doesn't match number of elements in this simulation");
-    for (unsigned i=0; i<raw_data.size(); i++) {
+    for (unsigned i = 0; i < raw_data.size(); i++) {
         m_sim_elements[i].setIntensity(raw_data[i]);
     }
     transferResultsToIntensityMap();
 }
 
-namespace {
+namespace
+{
 // TODO: remove when pointwise resolution is implemented
 std::unique_ptr<ISpecularScan> mangledDataHandler(const ISpecularScan& data_handler,
-                                                         const Beam& beam)
+                                                  const Beam& beam)
 {
     if (data_handler.dataType() != ISpecularScan::angle)
         throw std::runtime_error("Error in mangledDataHandler: invalid usage");
@@ -311,4 +311,4 @@ std::unique_ptr<ISpecularScan> mangledDataHandler(const ISpecularScan& data_hand
     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 f667dccbbc6..f4e1bc79847 100644
--- a/Core/Simulation/SpecularSimulation.h
+++ b/Core/Simulation/SpecularSimulation.h
@@ -15,9 +15,9 @@
 #ifndef SPECULARSIMULATION_H
 #define SPECULARSIMULATION_H
 
-#include "Simulation.h"
 #include "ILayerRTCoefficients.h"
 #include "OutputData.h"
+#include "Simulation.h"
 
 class IAxis;
 class IComputation;
@@ -44,7 +44,7 @@ public:
     //! Put into a clean state for running a simulation.
     void prepareSimulation() override;
 
-    void accept(INodeVisitor* visitor) const override final {visitor->visit(this);}
+    void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     //! Returns the results of the simulation in a format that supports unit conversion and export
     //! to numpy arrays. If simulation was not run, returns an array of proper size filled with
@@ -66,7 +66,7 @@ public:
 #ifndef SWIG
     //! Returns internal data handler
     const ISpecularScan* dataHandler() const { return m_data_handler.get(); }
-#endif //SWIG
+#endif // SWIG
 
 private:
     SpecularSimulation(const SpecularSimulation& other);
diff --git a/Core/SimulationElement/DepthProbeElement.cpp b/Core/SimulationElement/DepthProbeElement.cpp
index 237a099abd0..7582c52960c 100644
--- a/Core/SimulationElement/DepthProbeElement.cpp
+++ b/Core/SimulationElement/DepthProbeElement.cpp
@@ -17,12 +17,9 @@
 
 const double phi_i_0 = 0.0;
 
-DepthProbeElement::DepthProbeElement(double wavelength, double alpha_i,
-                                     const IAxis* z_positions)
-    : m_wavelength(wavelength)
-    , m_alpha_i(alpha_i)
-    , m_z_positions(z_positions)
-    , m_calculation_flag(true)
+DepthProbeElement::DepthProbeElement(double wavelength, double alpha_i, const IAxis* z_positions)
+    : m_wavelength(wavelength), m_alpha_i(alpha_i), m_z_positions(z_positions),
+      m_calculation_flag(true)
 {
     if (!z_positions)
         throw std::runtime_error(
@@ -31,26 +28,22 @@ DepthProbeElement::DepthProbeElement(double wavelength, double alpha_i,
 }
 
 DepthProbeElement::DepthProbeElement(const DepthProbeElement& other)
-    : m_wavelength(other.m_wavelength)
-    , m_alpha_i(other.m_alpha_i)
-    , m_intensities(other.m_intensities)
-    , m_z_positions(other.m_z_positions)
-    , m_calculation_flag(other.m_calculation_flag)
+    : m_wavelength(other.m_wavelength), m_alpha_i(other.m_alpha_i),
+      m_intensities(other.m_intensities), m_z_positions(other.m_z_positions),
+      m_calculation_flag(other.m_calculation_flag)
 {
 }
 
 DepthProbeElement::DepthProbeElement(DepthProbeElement&& other) noexcept
-    : m_wavelength(other.m_wavelength)
-    , m_alpha_i(other.m_alpha_i)
-    , m_intensities(std::move(other.m_intensities))
-    , m_z_positions(other.m_z_positions)
-    , m_calculation_flag(other.m_calculation_flag)
+    : m_wavelength(other.m_wavelength), m_alpha_i(other.m_alpha_i),
+      m_intensities(std::move(other.m_intensities)), m_z_positions(other.m_z_positions),
+      m_calculation_flag(other.m_calculation_flag)
 {
 }
 
 DepthProbeElement::~DepthProbeElement() = default;
 
-DepthProbeElement& DepthProbeElement::operator=(const DepthProbeElement &other)
+DepthProbeElement& DepthProbeElement::operator=(const DepthProbeElement& other)
 {
     if (this != &other) {
         DepthProbeElement tmp(other);
diff --git a/Core/SimulationElement/DepthProbeElement.h b/Core/SimulationElement/DepthProbeElement.h
index 792d6439f24..02888782923 100644
--- a/Core/SimulationElement/DepthProbeElement.h
+++ b/Core/SimulationElement/DepthProbeElement.h
@@ -46,21 +46,21 @@ public:
 
     const std::valarray<double>& getIntensities() const { return m_intensities; }
 
-    void setZPositions(const IAxis* z_positions) {m_z_positions = z_positions;}
-    const IAxis* getZPositions() const {return m_z_positions;}
+    void setZPositions(const IAxis* z_positions) { m_z_positions = z_positions; }
+    const IAxis* getZPositions() const { return m_z_positions; }
 
-    size_t size() const {return m_intensities.size();}
+    size_t size() const { return m_intensities.size(); }
 
     //! Set calculation flag (if it's false, zero intensity is assigned to the element)
-    void setCalculationFlag(bool calculation_flag) {m_calculation_flag = calculation_flag;}
-    bool isCalculated() const {return m_calculation_flag;}
+    void setCalculationFlag(bool calculation_flag) { m_calculation_flag = calculation_flag; }
+    bool isCalculated() const { return m_calculation_flag; }
 
 private:
     void swapContent(DepthProbeElement& other);
 
-    double m_wavelength, m_alpha_i;  //!< the wavelength and the incident angle of the beam
+    double m_wavelength, m_alpha_i;      //!< the wavelength and the incident angle of the beam
     std::valarray<double> m_intensities; //!< simulated intensity for the set of z positions
-    const IAxis* m_z_positions; //!< positions (lower z corresponds to a greater depth)
+    const IAxis* m_z_positions;          //!< positions (lower z corresponds to a greater depth)
     bool m_calculation_flag;
 };
 
diff --git a/Core/SimulationElement/PolarizationHandler.cpp b/Core/SimulationElement/PolarizationHandler.cpp
index cd291002535..6eb96c524bc 100644
--- a/Core/SimulationElement/PolarizationHandler.cpp
+++ b/Core/SimulationElement/PolarizationHandler.cpp
@@ -16,15 +16,16 @@
 
 // corresponds to completely unpolarized beam and the absence of spin selection in the analyzer
 PolarizationHandler::PolarizationHandler()
-    : m_polarization(Eigen::Matrix2cd::Identity() / 2.0)
-    , m_analyzer_operator(Eigen::Matrix2cd::Identity())
-{}
+    : m_polarization(Eigen::Matrix2cd::Identity() / 2.0),
+      m_analyzer_operator(Eigen::Matrix2cd::Identity())
+{
+}
 
 PolarizationHandler::PolarizationHandler(const Eigen::Matrix2cd& polarization,
                                          const Eigen::Matrix2cd& analyzer)
-    : m_polarization(polarization)
-    , m_analyzer_operator(analyzer)
-{}
+    : m_polarization(polarization), m_analyzer_operator(analyzer)
+{
+}
 
 void PolarizationHandler::swapContent(PolarizationHandler& other)
 {
diff --git a/Core/SimulationElement/PolarizationHandler.h b/Core/SimulationElement/PolarizationHandler.h
index 6daebf5848a..1dc4d38c63a 100644
--- a/Core/SimulationElement/PolarizationHandler.h
+++ b/Core/SimulationElement/PolarizationHandler.h
@@ -21,7 +21,8 @@
 //! Convenience class for handling polarization density matrix and polarization analyzer operator
 //! @ingroup simulation
 
-class BA_CORE_API_ PolarizationHandler {
+class BA_CORE_API_ PolarizationHandler
+{
 public:
     PolarizationHandler();
     PolarizationHandler(const Eigen::Matrix2cd& polarization, const Eigen::Matrix2cd& analyzer);
@@ -41,8 +42,8 @@ public:
     void swapContent(PolarizationHandler& other);
 
 private:
-    Eigen::Matrix2cd m_polarization;         //!< polarization density matrix
-    Eigen::Matrix2cd m_analyzer_operator;    //!< polarization analyzer operator
+    Eigen::Matrix2cd m_polarization;      //!< polarization density matrix
+    Eigen::Matrix2cd m_analyzer_operator; //!< polarization analyzer operator
 };
 
 #endif /* POLARIZATIONHANDLER_H_ */
diff --git a/Core/SimulationElement/SimulationElement.cpp b/Core/SimulationElement/SimulationElement.cpp
index ac98cd5a1b8..3c3d2d8f81e 100644
--- a/Core/SimulationElement/SimulationElement.cpp
+++ b/Core/SimulationElement/SimulationElement.cpp
@@ -17,60 +17,41 @@
 
 SimulationElement::SimulationElement(double wavelength, double alpha_i, double phi_i,
                                      std::unique_ptr<IPixel> pixel)
-    : m_wavelength(wavelength)
-    , m_alpha_i(alpha_i)
-    , m_phi_i(phi_i)
-    , m_k_i(vecOfLambdaAlphaPhi(m_wavelength, m_alpha_i, m_phi_i))
-    , m_mean_kf(pixel->getK(0.5, 0.5, m_wavelength))
-    , m_intensity(0.0)
-    , mP_pixel(std::move(pixel))
-    , m_is_specular(false)
+    : m_wavelength(wavelength), m_alpha_i(alpha_i), m_phi_i(phi_i),
+      m_k_i(vecOfLambdaAlphaPhi(m_wavelength, m_alpha_i, m_phi_i)),
+      m_mean_kf(pixel->getK(0.5, 0.5, m_wavelength)), m_intensity(0.0), mP_pixel(std::move(pixel)),
+      m_is_specular(false)
 {
 }
 
 SimulationElement::SimulationElement(const SimulationElement& other)
-    : m_polarization(other.m_polarization)
-    , m_wavelength(other.m_wavelength)
-    , m_alpha_i(other.m_alpha_i)
-    , m_phi_i(other.m_phi_i)
-    , m_k_i(other.m_k_i)
-    , m_mean_kf(other.m_mean_kf)
-    , m_intensity(other.m_intensity)
-    , m_is_specular(other.isSpecular())
+    : m_polarization(other.m_polarization), m_wavelength(other.m_wavelength),
+      m_alpha_i(other.m_alpha_i), m_phi_i(other.m_phi_i), m_k_i(other.m_k_i),
+      m_mean_kf(other.m_mean_kf), m_intensity(other.m_intensity), m_is_specular(other.isSpecular())
 {
     mP_pixel.reset(other.mP_pixel->clone());
 }
 
 SimulationElement::SimulationElement(const SimulationElement& other, double x, double y)
-    : m_polarization(other.m_polarization)
-    , m_wavelength(other.m_wavelength)
-    , m_alpha_i(other.m_alpha_i)
-    , m_phi_i(other.m_phi_i)
-    , m_k_i(other.m_k_i)
-    , m_mean_kf(other.m_mean_kf)
-    , m_intensity(other.m_intensity)
-    , m_is_specular(other.isSpecular())
+    : m_polarization(other.m_polarization), m_wavelength(other.m_wavelength),
+      m_alpha_i(other.m_alpha_i), m_phi_i(other.m_phi_i), m_k_i(other.m_k_i),
+      m_mean_kf(other.m_mean_kf), m_intensity(other.m_intensity), m_is_specular(other.isSpecular())
 {
     mP_pixel.reset(other.mP_pixel->createZeroSizePixel(x, y));
     m_mean_kf = mP_pixel->getK(0.5, 0.5, m_wavelength);
 }
 
 SimulationElement::SimulationElement(SimulationElement&& other) noexcept
-    : m_polarization(std::move(other.m_polarization))
-    , m_wavelength(other.m_wavelength)
-    , m_alpha_i(other.m_alpha_i)
-    , m_phi_i(other.m_phi_i)
-    , m_k_i(std::move(other.m_k_i))
-    , m_mean_kf(other.m_mean_kf)
-    , m_intensity(other.m_intensity)
-    , mP_pixel(std::move(other.mP_pixel))
-    , m_is_specular(other.isSpecular())
+    : m_polarization(std::move(other.m_polarization)), m_wavelength(other.m_wavelength),
+      m_alpha_i(other.m_alpha_i), m_phi_i(other.m_phi_i), m_k_i(std::move(other.m_k_i)),
+      m_mean_kf(other.m_mean_kf), m_intensity(other.m_intensity),
+      mP_pixel(std::move(other.mP_pixel)), m_is_specular(other.isSpecular())
 {
 }
 
 SimulationElement::~SimulationElement() = default;
 
-SimulationElement& SimulationElement::operator=(const SimulationElement &other)
+SimulationElement& SimulationElement::operator=(const SimulationElement& other)
 {
     if (this != &other) {
         SimulationElement tmp(other);
@@ -91,7 +72,8 @@ kvector_t SimulationElement::getMeanKf() const
 
 //! Returns outgoing wavevector Kf for in-pixel coordinates x,y.
 //! In-pixel coordinates take values from 0 to 1.
-kvector_t SimulationElement::getKf(double x, double y) const {
+kvector_t SimulationElement::getKf(double x, double y) const
+{
     return mP_pixel->getK(x, y, m_wavelength);
 }
 
@@ -107,7 +89,7 @@ kvector_t SimulationElement::getQ(double x, double y) const
     return getKi() - mP_pixel->getK(x, y, m_wavelength);
 }
 
-void SimulationElement::swapContent(SimulationElement &other)
+void SimulationElement::swapContent(SimulationElement& other)
 {
     m_polarization.swapContent(other.m_polarization);
     std::swap(m_wavelength, other.m_wavelength);
@@ -122,18 +104,20 @@ void SimulationElement::swapContent(SimulationElement &other)
 
 double SimulationElement::getAlpha(double x, double y) const
 {
-    return M_PI_2 - getKf(x,y).theta();
+    return M_PI_2 - getKf(x, y).theta();
 }
 
 double SimulationElement::getPhi(double x, double y) const
 {
-    return getKf(x,y).phi();
+    return getKf(x, y).phi();
 }
 
-double SimulationElement::getIntegrationFactor(double x, double y) const {
+double SimulationElement::getIntegrationFactor(double x, double y) const
+{
     return mP_pixel->getIntegrationFactor(x, y);
 }
 
-double SimulationElement::getSolidAngle() const {
+double SimulationElement::getSolidAngle() const
+{
     return mP_pixel->getSolidAngle();
 }
diff --git a/Core/SimulationElement/SimulationElement.h b/Core/SimulationElement/SimulationElement.h
index 4cf5701411b..57571ce551f 100644
--- a/Core/SimulationElement/SimulationElement.h
+++ b/Core/SimulationElement/SimulationElement.h
@@ -16,9 +16,9 @@
 #define SIMULATIONELEMENT_H
 
 #include "Complex.h"
-#include "Vectors3D.h"
 #include "IPixel.h"
 #include "PolarizationHandler.h"
+#include "Vectors3D.h"
 #include <memory>
 
 class IPixel;
@@ -31,14 +31,14 @@ class BA_CORE_API_ SimulationElement
 public:
     SimulationElement(double wavelength, double alpha_i, double phi_i,
                       std::unique_ptr<IPixel> pixel);
-    SimulationElement(const SimulationElement &other);
-    SimulationElement &operator=(const SimulationElement &other);
+    SimulationElement(const SimulationElement& other);
+    SimulationElement& operator=(const SimulationElement& other);
 
     //! Construct SimulationElement from other element and restrict k_f to specific value in
     //! the original detector pixel
-    SimulationElement(const SimulationElement &other, double x, double y);
+    SimulationElement(const SimulationElement& other, double x, double y);
 
-    SimulationElement(SimulationElement &&other) noexcept;
+    SimulationElement(SimulationElement&& other) noexcept;
 
     ~SimulationElement();
 
@@ -55,10 +55,7 @@ public:
     }
 
     //! Returns assigned PolarizationHandler
-    const PolarizationHandler& polarizationHandler() const
-    {
-        return m_polarization;
-    }
+    const PolarizationHandler& polarizationHandler() const { return m_polarization; }
 
     double getWavelength() const { return m_wavelength; }
     double getAlphaI() const { return m_alpha_i; }
@@ -73,7 +70,6 @@ public:
     kvector_t getMeanQ() const;
     kvector_t getQ(double x, double y) const;
 
-
     double getIntegrationFactor(double x, double y) const;
 
     double getSolidAngle() const;
@@ -82,21 +78,21 @@ public:
     double getPhi(double x, double y) const;
 
     //! Set specularity indication on/off.
-    void setSpecular(bool is_specular) {m_is_specular = is_specular;}
+    void setSpecular(bool is_specular) { m_is_specular = is_specular; }
 
     //! Tells if simulation element corresponds to a specular peak
-    bool isSpecular() const {return m_is_specular;}
+    bool isSpecular() const { return m_is_specular; }
 
 private:
-    void swapContent(SimulationElement &other);
+    void swapContent(SimulationElement& other);
 
     kvector_t getKf(double x, double y) const;
 
     PolarizationHandler m_polarization;
-    double m_wavelength, m_alpha_i, m_phi_i;  //!< wavelength and angles of beam
-    kvector_t m_k_i;                          //!< cached value of k_i
-    kvector_t m_mean_kf;                      //!< cached value of mean_kf
-    double m_intensity;                       //!< simulated intensity for detector cell
+    double m_wavelength, m_alpha_i, m_phi_i; //!< wavelength and angles of beam
+    kvector_t m_k_i;                         //!< cached value of k_i
+    kvector_t m_mean_kf;                     //!< cached value of mean_kf
+    double m_intensity;                      //!< simulated intensity for detector cell
     std::unique_ptr<IPixel> mP_pixel;
     bool m_is_specular;
 };
diff --git a/Core/SimulationElement/SpecularSimulationElement.cpp b/Core/SimulationElement/SpecularSimulationElement.cpp
index 7eed86cda4c..1423082a48c 100644
--- a/Core/SimulationElement/SpecularSimulationElement.cpp
+++ b/Core/SimulationElement/SpecularSimulationElement.cpp
@@ -28,7 +28,7 @@ SpecularSimulationElement::SpecularSimulationElement(double kz)
 SpecularSimulationElement::SpecularSimulationElement(double wavelength, double alpha)
     : m_intensity(0.0), m_calculation_flag(true),
       m_kz_computation([k = vecOfLambdaAlphaPhi(wavelength, alpha, /*phi =*/0.0)](
-                             const std::vector<Slice>& slices) {
+                           const std::vector<Slice>& slices) {
           return KzComputation::computeKzFromRefIndices(slices, k);
       })
 {
@@ -36,8 +36,7 @@ SpecularSimulationElement::SpecularSimulationElement(double wavelength, double a
 
 SpecularSimulationElement::SpecularSimulationElement(const SpecularSimulationElement& other)
     : m_polarization(other.m_polarization), m_intensity(other.m_intensity),
-      m_calculation_flag(other.m_calculation_flag),
-      m_kz_computation(other.m_kz_computation)
+      m_calculation_flag(other.m_calculation_flag), m_kz_computation(other.m_kz_computation)
 {
 }
 
@@ -50,8 +49,8 @@ SpecularSimulationElement::SpecularSimulationElement(SpecularSimulationElement&&
 
 SpecularSimulationElement::~SpecularSimulationElement() = default;
 
-SpecularSimulationElement& SpecularSimulationElement::
-operator=(const SpecularSimulationElement& other)
+SpecularSimulationElement&
+SpecularSimulationElement::operator=(const SpecularSimulationElement& other)
 {
     if (this != &other) {
         SpecularSimulationElement tmp(other);
diff --git a/Core/SimulationElement/SpecularSimulationElement.h b/Core/SimulationElement/SpecularSimulationElement.h
index 37333b284b5..9c6abcffcb7 100644
--- a/Core/SimulationElement/SpecularSimulationElement.h
+++ b/Core/SimulationElement/SpecularSimulationElement.h
@@ -16,8 +16,8 @@
 #define SPECULARSIMULATIONELEMENT_H
 
 #include "Complex.h"
-#include "Vectors3D.h"
 #include "PolarizationHandler.h"
+#include "Vectors3D.h"
 #include <memory>
 #include <vector>
 
@@ -48,8 +48,8 @@ public:
     //! Returns assigned PolarizationHandler.
     const PolarizationHandler& polarizationHandler() const { return m_polarization; }
 
-    double getIntensity() const {return m_intensity;}
-    void setIntensity(double intensity) {m_intensity = intensity;}
+    double getIntensity() const { return m_intensity; }
+    void setIntensity(double intensity) { m_intensity = intensity; }
 
     //! Set calculation flag (if it's false, zero intensity is assigned to the element)
     void setCalculationFlag(bool calculation_flag) { m_calculation_flag = calculation_flag; }
@@ -64,7 +64,7 @@ private:
     PolarizationHandler m_polarization;
     double m_intensity; //!< simulated intensity for detector cell
     bool m_calculation_flag;
-    std::function<std::vector<complex_t> (const std::vector<Slice>&)> m_kz_computation;
+    std::function<std::vector<complex_t>(const std::vector<Slice>&)> m_kz_computation;
 };
 
 #endif // SPECULARSIMULATIONELEMENT_H
diff --git a/Core/SoftParticle/FormFactorDebyeBueche.cpp b/Core/SoftParticle/FormFactorDebyeBueche.cpp
index e6b1fe077bd..3877b978319 100644
--- a/Core/SoftParticle/FormFactorDebyeBueche.cpp
+++ b/Core/SoftParticle/FormFactorDebyeBueche.cpp
@@ -27,8 +27,7 @@ FormFactorDebyeBueche::FormFactorDebyeBueche(double I0, double xi)
 
 complex_t FormFactorDebyeBueche::evaluate_for_q(cvector_t q) const
 {
-    complex_t denominator = 1.0 + m_xi*m_xi*q.mag2();
+    complex_t denominator = 1.0 + m_xi * m_xi * q.mag2();
 
-    return std::sqrt(m_I0)/denominator;
+    return std::sqrt(m_I0) / denominator;
 }
-
diff --git a/Core/SoftParticle/FormFactorDebyeBueche.h b/Core/SoftParticle/FormFactorDebyeBueche.h
index c921ffc9db6..dd3fe405a05 100644
--- a/Core/SoftParticle/FormFactorDebyeBueche.h
+++ b/Core/SoftParticle/FormFactorDebyeBueche.h
@@ -25,8 +25,10 @@ class BA_CORE_API_ FormFactorDebyeBueche : public IFormFactorBorn
 public:
     FormFactorDebyeBueche(double I0, double xi);
 
-    FormFactorDebyeBueche* clone() const override final {
-        return new FormFactorDebyeBueche(m_I0, m_xi); }
+    FormFactorDebyeBueche* clone() const override final
+    {
+        return new FormFactorDebyeBueche(m_I0, m_xi);
+    }
     void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     double radialExtension() const override final { return m_xi; }
diff --git a/Core/SoftParticle/FormFactorGauss.cpp b/Core/SoftParticle/FormFactorGauss.cpp
index 2ad56b26562..58217a3db26 100644
--- a/Core/SoftParticle/FormFactorGauss.cpp
+++ b/Core/SoftParticle/FormFactorGauss.cpp
@@ -19,8 +19,7 @@
 #include "RealParameter.h"
 #include <limits>
 
-FormFactorGauss::FormFactorGauss(double length)
-    : FormFactorGauss(length, length) {}
+FormFactorGauss::FormFactorGauss(double length) : FormFactorGauss(length, length) {}
 
 FormFactorGauss::FormFactorGauss(double width, double height)
 {
@@ -46,8 +45,8 @@ complex_t FormFactorGauss::evaluate_for_q(cvector_t q) const
     if (std::abs(qyr) > m_max_ql)
         return 0.0;
 
-    return exp_I(qzHdiv2) * m_height * m_width * m_width *
-            std::exp(-(qxr*qxr + qyr*qyr + qzh*qzh) / 4.0 / M_PI);
+    return exp_I(qzHdiv2) * m_height * m_width * m_width
+           * std::exp(-(qxr * qxr + qyr * qyr + qzh * qzh) / 4.0 / M_PI);
 }
 
 void FormFactorGauss::onChange()
diff --git a/Core/SoftParticle/FormFactorGauss.h b/Core/SoftParticle/FormFactorGauss.h
index 47252f35e9a..d38ee47e34c 100644
--- a/Core/SoftParticle/FormFactorGauss.h
+++ b/Core/SoftParticle/FormFactorGauss.h
@@ -26,8 +26,7 @@ public:
     FormFactorGauss(double length);
     FormFactorGauss(double width, double height);
 
-    FormFactorGauss* clone() const override final {
-        return new FormFactorGauss(m_width, m_height); }
+    FormFactorGauss* clone() const override final { return new FormFactorGauss(m_width, m_height); }
     void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     double getWidth() const { return m_width; }
diff --git a/Core/SoftParticle/FormFactorLorentz.cpp b/Core/SoftParticle/FormFactorLorentz.cpp
index 76aab0f563e..b4bd107a5d7 100644
--- a/Core/SoftParticle/FormFactorLorentz.cpp
+++ b/Core/SoftParticle/FormFactorLorentz.cpp
@@ -15,8 +15,8 @@
 #include "FormFactorLorentz.h"
 #include "BornAgainNamespace.h"
 #include "Box.h"
-#include "RealLimits.h"
 #include "MathConstants.h"
+#include "RealLimits.h"
 #include "RealParameter.h"
 
 FormFactorLorentz::FormFactorLorentz(double width, double height)
@@ -26,14 +26,11 @@ FormFactorLorentz::FormFactorLorentz(double width, double height)
     initialize();
 }
 
-FormFactorLorentz::FormFactorLorentz(double length)
-    : m_width { length }
-    , m_height { length }
+FormFactorLorentz::FormFactorLorentz(double length) : m_width{length}, m_height{length}
 {
     initialize();
 }
 
-
 double FormFactorLorentz::radialExtension() const
 {
     return m_width / 2.0;
@@ -41,15 +38,15 @@ double FormFactorLorentz::radialExtension() const
 
 complex_t FormFactorLorentz::evaluate_for_q(cvector_t q) const
 {
-    static const double sigma2 = 4.0*std::pow(M_PI, 2.0/3.0);
+    static const double sigma2 = 4.0 * std::pow(M_PI, 2.0 / 3.0);
     double R = m_width;
     double H = m_height;
 
-    complex_t xnorm = R*R*q.x()*q.x()/sigma2;
-    complex_t ynorm = R*R*q.y()*q.y()/sigma2;
-    complex_t znorm = H*H*q.z()*q.z()/sigma2;
+    complex_t xnorm = R * R * q.x() * q.x() / sigma2;
+    complex_t ynorm = R * R * q.y() * q.y() / sigma2;
+    complex_t znorm = H * H * q.z() * q.z() / sigma2;
 
-    complex_t result = H*R*R/(1.0 + xnorm + ynorm + znorm);
+    complex_t result = H * R * R / (1.0 + xnorm + ynorm + znorm);
 
     return result;
 }
diff --git a/Core/SoftParticle/FormFactorLorentz.h b/Core/SoftParticle/FormFactorLorentz.h
index 0c12840efc7..7a9ab73f9ec 100644
--- a/Core/SoftParticle/FormFactorLorentz.h
+++ b/Core/SoftParticle/FormFactorLorentz.h
@@ -26,8 +26,10 @@ public:
     FormFactorLorentz(double length);
     FormFactorLorentz(double width, double height);
 
-    FormFactorLorentz* clone() const override final {
-        return new FormFactorLorentz(m_width, m_height); }
+    FormFactorLorentz* clone() const override final
+    {
+        return new FormFactorLorentz(m_width, m_height);
+    }
     void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     double getWidth() const { return m_width; }
diff --git a/Core/SoftParticle/FormFactorOrnsteinZernike.cpp b/Core/SoftParticle/FormFactorOrnsteinZernike.cpp
index 870faa65a5a..fd88d594670 100644
--- a/Core/SoftParticle/FormFactorOrnsteinZernike.cpp
+++ b/Core/SoftParticle/FormFactorOrnsteinZernike.cpp
@@ -28,8 +28,7 @@ FormFactorOrnsteinZernike::FormFactorOrnsteinZernike(double I0, double xi_xy, do
 
 complex_t FormFactorOrnsteinZernike::evaluate_for_q(cvector_t q) const
 {
-    complex_t denominator = 1.0 + m_xi_xy*m_xi_xy*q.magxy2() + m_xi_z*m_xi_z*q.z()*q.z();
+    complex_t denominator = 1.0 + m_xi_xy * m_xi_xy * q.magxy2() + m_xi_z * m_xi_z * q.z() * q.z();
 
-    return std::sqrt(m_I0/denominator);
+    return std::sqrt(m_I0 / denominator);
 }
-
diff --git a/Core/SoftParticle/FormFactorOrnsteinZernike.h b/Core/SoftParticle/FormFactorOrnsteinZernike.h
index 025a4ace4af..934e2af88ec 100644
--- a/Core/SoftParticle/FormFactorOrnsteinZernike.h
+++ b/Core/SoftParticle/FormFactorOrnsteinZernike.h
@@ -25,8 +25,10 @@ class BA_CORE_API_ FormFactorOrnsteinZernike : public IFormFactorBorn
 public:
     FormFactorOrnsteinZernike(double I0, double xi_xy, double xi_z);
 
-    FormFactorOrnsteinZernike* clone() const override final {
-        return new FormFactorOrnsteinZernike(m_I0, m_xi_xy, m_xi_z); }
+    FormFactorOrnsteinZernike* clone() const override final
+    {
+        return new FormFactorOrnsteinZernike(m_I0, m_xi_xy, m_xi_z);
+    }
     void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     double radialExtension() const override final { return m_xi_xy; }
diff --git a/Core/SoftParticle/FormFactorSphereGaussianRadius.cpp b/Core/SoftParticle/FormFactorSphereGaussianRadius.cpp
index d2c6242935e..73e65bdb3de 100644
--- a/Core/SoftParticle/FormFactorSphereGaussianRadius.cpp
+++ b/Core/SoftParticle/FormFactorSphereGaussianRadius.cpp
@@ -19,33 +19,31 @@
 #include "TruncatedEllipsoid.h"
 
 FormFactorSphereGaussianRadius::FormFactorSphereGaussianRadius(double mean, double sigma)
-: m_mean(mean)
-, m_sigma(sigma)
-, m_mean_r3(0.0)
+    : m_mean(mean), m_sigma(sigma), m_mean_r3(0.0)
 {
     setName(BornAgain::FormFactorSphereGaussianRadiusType);
     m_mean_r3 = calculateMeanR3();
     P_ff_sphere.reset(new FormFactorFullSphere(m_mean_r3));
-    registerParameter(BornAgain::MeanRadius, &m_mean).setUnit(BornAgain::UnitsNm)
-        .setNonnegative();
+    registerParameter(BornAgain::MeanRadius, &m_mean).setUnit(BornAgain::UnitsNm).setNonnegative();
     registerParameter(BornAgain::SigmaRadius, &m_sigma)
-        .setUnit(BornAgain::UnitsNm).setNonnegative();
+        .setUnit(BornAgain::UnitsNm)
+        .setNonnegative();
     onChange();
 }
 
 complex_t FormFactorSphereGaussianRadius::evaluate_for_q(cvector_t q) const
 {
     double q2 = std::norm(q.x()) + std::norm(q.y()) + std::norm(q.z());
-    double dw = std::exp(-q2*m_sigma*m_sigma/2.0);
-    return dw*P_ff_sphere->evaluate_for_q(q);
+    double dw = std::exp(-q2 * m_sigma * m_sigma / 2.0);
+    return dw * P_ff_sphere->evaluate_for_q(q);
 }
 
 void FormFactorSphereGaussianRadius::onChange()
 {
-    mP_shape.reset(new TruncatedEllipsoid(m_mean, m_mean, m_mean, 2.0*m_mean, 0.0));
+    mP_shape.reset(new TruncatedEllipsoid(m_mean, m_mean, m_mean, 2.0 * m_mean, 0.0));
 }
 
 double FormFactorSphereGaussianRadius::calculateMeanR3() const
 {
-    return std::pow(m_mean*(m_mean*m_mean+3.0*m_sigma*m_sigma),1.0/3.0);
+    return std::pow(m_mean * (m_mean * m_mean + 3.0 * m_sigma * m_sigma), 1.0 / 3.0);
 }
diff --git a/Core/SoftParticle/FormFactorSphereGaussianRadius.h b/Core/SoftParticle/FormFactorSphereGaussianRadius.h
index 490236645f6..66ad5cc5b00 100644
--- a/Core/SoftParticle/FormFactorSphereGaussianRadius.h
+++ b/Core/SoftParticle/FormFactorSphereGaussianRadius.h
@@ -26,8 +26,10 @@ class BA_CORE_API_ FormFactorSphereGaussianRadius : public IFormFactorBorn
 public:
     FormFactorSphereGaussianRadius(double mean, double sigma);
 
-    FormFactorSphereGaussianRadius* clone() const override final {
-        return new FormFactorSphereGaussianRadius(m_mean, m_sigma); }
+    FormFactorSphereGaussianRadius* clone() const override final
+    {
+        return new FormFactorSphereGaussianRadius(m_mean, m_sigma);
+    }
 
     void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
diff --git a/Core/SoftParticle/FormFactorSphereLogNormalRadius.cpp b/Core/SoftParticle/FormFactorSphereLogNormalRadius.cpp
index b3a1ef40e1f..98b2ccc112c 100644
--- a/Core/SoftParticle/FormFactorSphereLogNormalRadius.cpp
+++ b/Core/SoftParticle/FormFactorSphereLogNormalRadius.cpp
@@ -19,21 +19,20 @@
 #include "RealParameter.h"
 #include "TruncatedEllipsoid.h"
 
-FormFactorSphereLogNormalRadius::FormFactorSphereLogNormalRadius(
-        double mean, double scale_param, size_t n_samples)
-    : m_mean(mean)
-    , m_scale_param(scale_param)
-    , m_n_samples(n_samples)
+FormFactorSphereLogNormalRadius::FormFactorSphereLogNormalRadius(double mean, double scale_param,
+                                                                 size_t n_samples)
+    : m_mean(mean), m_scale_param(scale_param), m_n_samples(n_samples)
 {
     setName(BornAgain::FormFactorSphereLogNormalRadiusType);
     mP_distribution.reset(new DistributionLogNormal(mean, scale_param));
     registerParameter(BornAgain::MeanRadius, &m_mean).setUnit(BornAgain::UnitsNm).setNonnegative();
     registerParameter(BornAgain::ScaleParameter, &m_scale_param);
-    if (!mP_distribution) return;
+    if (!mP_distribution)
+        return;
     // Init vectors:
     m_form_factors.clear();
     m_probabilities.clear();
-    for (ParameterSample& sample: mP_distribution->equidistantSamples(m_n_samples)) {
+    for (ParameterSample& sample : mP_distribution->equidistantSamples(m_n_samples)) {
         double radius = sample.value;
         m_form_factors.push_back(new FormFactorFullSphere(radius));
         m_probabilities.push_back(sample.weight);
@@ -43,15 +42,15 @@ FormFactorSphereLogNormalRadius::FormFactorSphereLogNormalRadius(
 
 complex_t FormFactorSphereLogNormalRadius::evaluate_for_q(cvector_t q) const
 {
-    if (m_form_factors.size()<1)
+    if (m_form_factors.size() < 1)
         return 0.0;
     complex_t result(0.0);
-    for (size_t i=0; i<m_form_factors.size(); ++i)
+    for (size_t i = 0; i < m_form_factors.size(); ++i)
         result += m_form_factors[i]->evaluate_for_q(q) * m_probabilities[i];
     return result;
 }
 
 void FormFactorSphereLogNormalRadius::onChange()
 {
-    mP_shape.reset(new TruncatedEllipsoid(m_mean, m_mean, m_mean, 2.0*m_mean, 0.0));
+    mP_shape.reset(new TruncatedEllipsoid(m_mean, m_mean, m_mean, 2.0 * m_mean, 0.0));
 }
diff --git a/Core/SoftParticle/FormFactorSphereLogNormalRadius.h b/Core/SoftParticle/FormFactorSphereLogNormalRadius.h
index 7c4931f27a1..f24d9024b11 100644
--- a/Core/SoftParticle/FormFactorSphereLogNormalRadius.h
+++ b/Core/SoftParticle/FormFactorSphereLogNormalRadius.h
@@ -15,9 +15,9 @@
 #ifndef FORMFACTORSPHERELOGNORMALRADIUS_H
 #define FORMFACTORSPHERELOGNORMALRADIUS_H
 
+#include "Distributions.h"
 #include "FormFactorFullSphere.h"
 #include "SafePointerVector.h"
-#include "Distributions.h"
 #include <memory>
 
 //! A sphere with log normal radius distribution.
@@ -28,8 +28,10 @@ class BA_CORE_API_ FormFactorSphereLogNormalRadius : public IFormFactorBorn
 public:
     FormFactorSphereLogNormalRadius(double mean, double scale_param, size_t n_samples);
 
-    FormFactorSphereLogNormalRadius* clone() const override final {
-        return new FormFactorSphereLogNormalRadius(m_mean, m_scale_param, m_n_samples); }
+    FormFactorSphereLogNormalRadius* clone() const override final
+    {
+        return new FormFactorSphereLogNormalRadius(m_mean, m_scale_param, m_n_samples);
+    }
     void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     double radialExtension() const override final { return m_mean; }
diff --git a/Core/SoftParticle/FormFactorSphereUniformRadius.cpp b/Core/SoftParticle/FormFactorSphereUniformRadius.cpp
index a4c2cf0f20a..6b188433bb6 100644
--- a/Core/SoftParticle/FormFactorSphereUniformRadius.cpp
+++ b/Core/SoftParticle/FormFactorSphereUniformRadius.cpp
@@ -20,19 +20,17 @@
 #include "TruncatedEllipsoid.h"
 #include <limits>
 
-FormFactorSphereUniformRadius::FormFactorSphereUniformRadius(double mean,
-        double full_width)
-    : m_mean(mean)
-    , m_full_width(full_width)
+FormFactorSphereUniformRadius::FormFactorSphereUniformRadius(double mean, double full_width)
+    : m_mean(mean), m_full_width(full_width)
 {
-    if(!checkParameters())
+    if (!checkParameters())
         throw Exceptions::ClassInitializationException(
-                "FormFactorSphereUniformRadius::FormFactorSphereUniformRadius:"
-                " mean radius must be bigger than the half width");
+            "FormFactorSphereUniformRadius::FormFactorSphereUniformRadius:"
+            " mean radius must be bigger than the half width");
     setName(BornAgain::FormFactorSphereUniformRadiusType);
-    registerParameter(BornAgain::MeanRadius, &m_mean).setUnit(BornAgain::UnitsNm)
-        .setNonnegative();
-    registerParameter(BornAgain::FullWidth, &m_full_width).setUnit(BornAgain::UnitsNm)
+    registerParameter(BornAgain::MeanRadius, &m_mean).setUnit(BornAgain::UnitsNm).setNonnegative();
+    registerParameter(BornAgain::FullWidth, &m_full_width)
+        .setUnit(BornAgain::UnitsNm)
         .setNonnegative();
     onChange();
 }
@@ -43,26 +41,27 @@ complex_t FormFactorSphereUniformRadius::evaluate_for_q(cvector_t q) const
     double W = m_full_width;
     double q2 = std::norm(q.x()) + std::norm(q.y()) + std::norm(q.z());
     double q_r = std::sqrt(q2);
-    if (q_r*R < std::numeric_limits<double>::epsilon())
-        return (4.0*M_PI*R*R*R + M_PI*R*W*W)/3.0;
-    double qR = q_r*R;
-    double qW = q_r*W;
-    double nominator = 4*M_PI*( 4*std::sin(qR)*std::sin(qW/2.0)
-                                  - qW*std::cos(qW/2.0)*std::sin(qR)
-                                  - 2.0*qR*std::cos(qR)*std::sin(qW/2.0) );
-    return nominator/(q2*q2*W);
+    if (q_r * R < std::numeric_limits<double>::epsilon())
+        return (4.0 * M_PI * R * R * R + M_PI * R * W * W) / 3.0;
+    double qR = q_r * R;
+    double qW = q_r * W;
+    double nominator =
+        4 * M_PI
+        * (4 * std::sin(qR) * std::sin(qW / 2.0) - qW * std::cos(qW / 2.0) * std::sin(qR)
+           - 2.0 * qR * std::cos(qR) * std::sin(qW / 2.0));
+    return nominator / (q2 * q2 * W);
 }
 
 void FormFactorSphereUniformRadius::onChange()
 {
-    mP_shape.reset(new TruncatedEllipsoid(m_mean, m_mean, m_mean, 2.0*m_mean, 0.0));
+    mP_shape.reset(new TruncatedEllipsoid(m_mean, m_mean, m_mean, 2.0 * m_mean, 0.0));
 }
 
 bool FormFactorSphereUniformRadius::checkParameters() const
 {
-    if (m_full_width<=0.0)
+    if (m_full_width <= 0.0)
         return false;
-    if (2.0*m_mean<m_full_width)
+    if (2.0 * m_mean < m_full_width)
         return false;
     return true;
 }
diff --git a/Core/SoftParticle/FormFactorSphereUniformRadius.h b/Core/SoftParticle/FormFactorSphereUniformRadius.h
index 0be2f072754..d5f37ebf422 100644
--- a/Core/SoftParticle/FormFactorSphereUniformRadius.h
+++ b/Core/SoftParticle/FormFactorSphereUniformRadius.h
@@ -25,8 +25,10 @@ class BA_CORE_API_ FormFactorSphereUniformRadius : public IFormFactorBorn
 public:
     FormFactorSphereUniformRadius(double mean, double full_width);
 
-    FormFactorSphereUniformRadius* clone() const override final {
-        return new FormFactorSphereUniformRadius(m_mean, m_full_width); }
+    FormFactorSphereUniformRadius* clone() const override final
+    {
+        return new FormFactorSphereUniformRadius(m_mean, m_full_width);
+    }
     void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
 
     double radialExtension() const override final { return m_mean; }
@@ -38,7 +40,7 @@ protected:
 
 private:
     bool checkParameters() const;
-    double m_mean; //!< This is the mean radius
+    double m_mean;       //!< This is the mean radius
     double m_full_width; //!< This is the full width of the radius distribution
 };
 
diff --git a/Core/StandardSamples/BoxCompositionBuilder.cpp b/Core/StandardSamples/BoxCompositionBuilder.cpp
index f19f9fe8178..92a54f12e64 100644
--- a/Core/StandardSamples/BoxCompositionBuilder.cpp
+++ b/Core/StandardSamples/BoxCompositionBuilder.cpp
@@ -24,17 +24,15 @@
 #include "Units.h"
 
 BoxCompositionBuilder::BoxCompositionBuilder()
-    : m_particleMaterial(HomogeneousMaterial("Ag", 1.245e-5, 5.419e-7))
-    , m_layer_thickness(100.0*Units::nanometer)
-    , m_length(50.0*Units::nanometer)
-    , m_width(20.0*Units::nanometer)
-    , m_height(10.0*Units::nanometer)
+    : m_particleMaterial(HomogeneousMaterial("Ag", 1.245e-5, 5.419e-7)),
+      m_layer_thickness(100.0 * Units::nanometer), m_length(50.0 * Units::nanometer),
+      m_width(20.0 * Units::nanometer), m_height(10.0 * Units::nanometer)
 {
 }
 
 BoxCompositionBuilder::~BoxCompositionBuilder() {}
 
-MultiLayer* BoxCompositionBuilder::createMultiLayer(const ParticleComposition &composition) const
+MultiLayer* BoxCompositionBuilder::createMultiLayer(const ParticleComposition& composition) const
 {
     Material mAmbience = HomogeneousMaterial("Air", 0.0, 0.0);
     Material mMiddle = HomogeneousMaterial("Teflon", 2.900e-6, 6.019e-9);
@@ -59,12 +57,12 @@ MultiLayer* BoxCompositionBuilder::createMultiLayer(const ParticleComposition &c
 
 MultiLayer* BoxCompositionRotateXBuilder::buildSample() const
 {
-    Particle box(m_particleMaterial, FormFactorBox(m_length/2.0, m_width, m_height));
+    Particle box(m_particleMaterial, FormFactorBox(m_length / 2.0, m_width, m_height));
     ParticleComposition composition;
     composition.addParticle(box, kvector_t(0.0, 0.0, 0.0));
-    composition.addParticle(box, kvector_t(m_length/2.0, 0.0, 0.0));
-    composition.setRotation(RotationX(90.0*Units::degree));
-    composition.setPosition(kvector_t(0.0, 0.0, -m_layer_thickness/2.0));
+    composition.addParticle(box, kvector_t(m_length / 2.0, 0.0, 0.0));
+    composition.setRotation(RotationX(90.0 * Units::degree));
+    composition.setPosition(kvector_t(0.0, 0.0, -m_layer_thickness / 2.0));
     return createMultiLayer(composition);
 }
 
@@ -72,12 +70,12 @@ MultiLayer* BoxCompositionRotateXBuilder::buildSample() const
 
 MultiLayer* BoxCompositionRotateYBuilder::buildSample() const
 {
-    Particle box(m_particleMaterial, FormFactorBox(m_length/2.0, m_width, m_height));
+    Particle box(m_particleMaterial, FormFactorBox(m_length / 2.0, m_width, m_height));
     ParticleComposition composition;
     composition.addParticle(box, kvector_t(0.0, 0.0, 0.0));
-    composition.addParticle(box, kvector_t(m_length/2.0, 0.0, 0.0));
-    composition.setRotation(RotationY(90.0*Units::degree));
-    composition.setPosition(kvector_t(0.0, 0.0, -m_layer_thickness/2.0 + m_length/4.0));
+    composition.addParticle(box, kvector_t(m_length / 2.0, 0.0, 0.0));
+    composition.setRotation(RotationY(90.0 * Units::degree));
+    composition.setPosition(kvector_t(0.0, 0.0, -m_layer_thickness / 2.0 + m_length / 4.0));
     return createMultiLayer(composition);
 }
 
@@ -85,12 +83,12 @@ MultiLayer* BoxCompositionRotateYBuilder::buildSample() const
 
 MultiLayer* BoxCompositionRotateZBuilder::buildSample() const
 {
-    Particle box(m_particleMaterial, FormFactorBox(m_length/2.0, m_width, m_height));
+    Particle box(m_particleMaterial, FormFactorBox(m_length / 2.0, m_width, m_height));
     ParticleComposition composition;
     composition.addParticle(box, kvector_t(0.0, 0.0, 0.0));
-    composition.addParticle(box, kvector_t(m_length/2.0, 0.0, 0.0));
-    composition.setRotation(RotationZ(90.0*Units::degree));
-    composition.setPosition(kvector_t(0.0, 0.0, -m_layer_thickness/2.0  - m_height/2.0));
+    composition.addParticle(box, kvector_t(m_length / 2.0, 0.0, 0.0));
+    composition.setRotation(RotationZ(90.0 * Units::degree));
+    composition.setPosition(kvector_t(0.0, 0.0, -m_layer_thickness / 2.0 - m_height / 2.0));
     return createMultiLayer(composition);
 }
 
@@ -98,13 +96,13 @@ MultiLayer* BoxCompositionRotateZBuilder::buildSample() const
 
 MultiLayer* BoxCompositionRotateZandYBuilder::buildSample() const
 {
-    Particle box(m_particleMaterial, FormFactorBox(m_length/2.0, m_width, m_height));
+    Particle box(m_particleMaterial, FormFactorBox(m_length / 2.0, m_width, m_height));
     ParticleComposition composition;
     composition.addParticle(box, kvector_t(0.0, 0.0, 0.0));
-    composition.addParticle(box, kvector_t(m_length/2.0, 0.0, 0.0));
-    composition.setRotation(RotationZ(90.0*Units::degree));
-    composition.rotate(RotationY(90.0*Units::degree));
-    composition.setPosition(kvector_t(0.0, 0.0, -m_layer_thickness/2.0 ));
+    composition.addParticle(box, kvector_t(m_length / 2.0, 0.0, 0.0));
+    composition.setRotation(RotationZ(90.0 * Units::degree));
+    composition.rotate(RotationY(90.0 * Units::degree));
+    composition.setPosition(kvector_t(0.0, 0.0, -m_layer_thickness / 2.0));
     return createMultiLayer(composition);
 }
 
@@ -120,20 +118,20 @@ MultiLayer* BoxStackCompositionBuilder::buildSample() const
     const double box1_width = 50;
     const double box1_height = 5;
     Particle box1(m_particleMaterial, FormFactorBox(box1_length, box1_width, box1_height));
-    box1.setRotation(RotationZ(90.*Units::degree));
+    box1.setRotation(RotationZ(90. * Units::degree));
 
     // box2 (5,20,50), rotatedY
     const double box2_length = 5.0;
     const double box2_width = 20.0;
     const double box2_height = 50.0;
     Particle box2(m_particleMaterial, FormFactorBox(box2_length, box2_width, box2_height));
-    box2.setRotation(RotationY(90.*Units::degree));
-    box2.setPosition(kvector_t(-box2_height/2.0, 0.0, box2_length/2.0));
+    box2.setRotation(RotationY(90. * Units::degree));
+    box2.setPosition(kvector_t(-box2_height / 2.0, 0.0, box2_length / 2.0));
 
     composition.addParticle(box1, kvector_t(0.0, 0.0, 0.0));
     composition.addParticle(box2, kvector_t(0.0, 0.0, box1_height));
-    composition.setRotation(RotationY(90.0*Units::degree));
-    composition.setPosition(kvector_t(0.0, 0.0, -m_layer_thickness/2.));
+    composition.setRotation(RotationY(90.0 * Units::degree));
+    composition.setPosition(kvector_t(0.0, 0.0, -m_layer_thickness / 2.));
 
     return createMultiLayer(composition);
 }
diff --git a/Core/StandardSamples/BoxCompositionBuilder.h b/Core/StandardSamples/BoxCompositionBuilder.h
index 77ca77d8a22..6eb0d8fa02a 100644
--- a/Core/StandardSamples/BoxCompositionBuilder.h
+++ b/Core/StandardSamples/BoxCompositionBuilder.h
@@ -46,7 +46,7 @@ protected:
 class BA_CORE_API_ BoxCompositionRotateXBuilder : public BoxCompositionBuilder
 {
 public:
-    BoxCompositionRotateXBuilder(){}
+    BoxCompositionRotateXBuilder() {}
     MultiLayer* buildSample() const;
 };
 
@@ -56,7 +56,7 @@ public:
 class BA_CORE_API_ BoxCompositionRotateYBuilder : public BoxCompositionBuilder
 {
 public:
-    BoxCompositionRotateYBuilder(){}
+    BoxCompositionRotateYBuilder() {}
     MultiLayer* buildSample() const;
 };
 
@@ -66,7 +66,7 @@ public:
 class BA_CORE_API_ BoxCompositionRotateZBuilder : public BoxCompositionBuilder
 {
 public:
-    BoxCompositionRotateZBuilder(){}
+    BoxCompositionRotateZBuilder() {}
     MultiLayer* buildSample() const;
 };
 
@@ -76,7 +76,7 @@ public:
 class BA_CORE_API_ BoxCompositionRotateZandYBuilder : public BoxCompositionBuilder
 {
 public:
-    BoxCompositionRotateZandYBuilder(){}
+    BoxCompositionRotateZandYBuilder() {}
     MultiLayer* buildSample() const;
 };
 
@@ -86,7 +86,7 @@ public:
 class BA_CORE_API_ BoxStackCompositionBuilder : public BoxCompositionBuilder
 {
 public:
-    BoxStackCompositionBuilder(){}
+    BoxStackCompositionBuilder() {}
     MultiLayer* buildSample() const;
 };
 
diff --git a/Core/StandardSamples/BoxesSquareLatticeBuilder.cpp b/Core/StandardSamples/BoxesSquareLatticeBuilder.cpp
index 210ac845584..fafd931f49f 100644
--- a/Core/StandardSamples/BoxesSquareLatticeBuilder.cpp
+++ b/Core/StandardSamples/BoxesSquareLatticeBuilder.cpp
@@ -13,11 +13,11 @@
 // ************************************************************************** //
 
 #include "BoxesSquareLatticeBuilder.h"
-#include "MaterialFactoryFuncs.h"
 #include "BornAgainNamespace.h"
 #include "FormFactorBox.h"
 #include "InterferenceFunction2DLattice.h"
 #include "Layer.h"
+#include "MaterialFactoryFuncs.h"
 #include "MultiLayer.h"
 #include "Particle.h"
 #include "ParticleLayout.h"
@@ -29,9 +29,9 @@
 // -----------------------------------------------------------------------------
 
 BoxesSquareLatticeBuilder::BoxesSquareLatticeBuilder()
-    : m_length(5*Units::nanometer)
-    , m_height(10*Units::nanometer)
-{}
+    : m_length(5 * Units::nanometer), m_height(10 * Units::nanometer)
+{
+}
 
 MultiLayer* BoxesSquareLatticeBuilder::buildSample() const
 {
@@ -45,9 +45,9 @@ MultiLayer* BoxesSquareLatticeBuilder::buildSample() const
     Layer substrate_layer(substrate_material);
 
     std::unique_ptr<InterferenceFunction2DLattice> P_interference_function(
-                InterferenceFunction2DLattice::createSquare(8*Units::nanometer));
+        InterferenceFunction2DLattice::createSquare(8 * Units::nanometer));
 
-    FTDecayFunction2DCauchy pdf(100.0*Units::nanometer, 100.0*Units::nanometer);
+    FTDecayFunction2DCauchy pdf(100.0 * Units::nanometer, 100.0 * Units::nanometer);
     P_interference_function->setDecayFunction(pdf);
 
     // particles
diff --git a/Core/StandardSamples/CoreShellParticleBuilder.cpp b/Core/StandardSamples/CoreShellParticleBuilder.cpp
index e3c8e4aeb90..39ee2f628d8 100644
--- a/Core/StandardSamples/CoreShellParticleBuilder.cpp
+++ b/Core/StandardSamples/CoreShellParticleBuilder.cpp
@@ -13,9 +13,9 @@
 // ************************************************************************** //
 
 #include "CoreShellParticleBuilder.h"
-#include "MaterialFactoryFuncs.h"
 #include "FormFactorBox.h"
 #include "Layer.h"
+#include "MaterialFactoryFuncs.h"
 #include "MultiLayer.h"
 #include "Particle.h"
 #include "ParticleCoreShell.h"
@@ -31,18 +31,18 @@ MultiLayer* CoreShellParticleBuilder::buildSample() const
 
     Material air_material = HomogeneousMaterial("Air", 0.0, 0.0);
 
-    complex_t n_particle_shell(1.0-1e-4, 2e-8);
-    complex_t n_particle_core(1.0-6e-5, 2e-8);
+    complex_t n_particle_shell(1.0 - 1e-4, 2e-8);
+    complex_t n_particle_core(1.0 - 6e-5, 2e-8);
 
     Material shell_material = HomogeneousMaterial("Shell", n_particle_shell);
     Material core_material = HomogeneousMaterial("Core", n_particle_core);
 
     Layer air_layer(air_material);
 
-    FormFactorBox ff_box1(16*Units::nanometer, 16*Units::nanometer, 8*Units::nanometer);
+    FormFactorBox ff_box1(16 * Units::nanometer, 16 * Units::nanometer, 8 * Units::nanometer);
     Particle shell_particle(shell_material, ff_box1);
 
-    FormFactorBox ff_box2(12*Units::nanometer, 12*Units::nanometer, 7*Units::nanometer);
+    FormFactorBox ff_box2(12 * Units::nanometer, 12 * Units::nanometer, 7 * Units::nanometer);
     Particle core_particle(core_material, ff_box2);
 
     kvector_t core_position(0.0, 0.0, 0.0);
@@ -59,7 +59,7 @@ MultiLayer* CoreShellParticleBuilder::buildSample() const
 
 MultiLayer* CoreShellBoxRotateZandYBuilder::buildSample() const
 {
-    const double layer_thickness(100.0*Units::nanometer);
+    const double layer_thickness(100.0 * Units::nanometer);
 
     Material mAmbience = HomogeneousMaterial("Air", 0.0, 0.0);
     Material mMiddle = HomogeneousMaterial("Teflon", 2.900e-6, 6.019e-9);
@@ -68,19 +68,20 @@ MultiLayer* CoreShellBoxRotateZandYBuilder::buildSample() const
     Material mShell = HomogeneousMaterial("AgO2", 8.600e-6, 3.442e-7);
 
     // core shell particle
-    const double shell_length(50.0*Units::nanometer);
-    const double shell_width(20.0*Units::nanometer);
-    const double shell_height(10.0*Units::nanometer);
-    double core_length = shell_length/2.0;
-    double core_width = shell_width/2.0;
-    double core_height = shell_height/2.0;
+    const double shell_length(50.0 * Units::nanometer);
+    const double shell_width(20.0 * Units::nanometer);
+    const double shell_height(10.0 * Units::nanometer);
+    double core_length = shell_length / 2.0;
+    double core_width = shell_width / 2.0;
+    double core_height = shell_height / 2.0;
 
     Particle core(mCore, FormFactorBox(core_length, core_width, core_height));
     Particle shell(mShell, FormFactorBox(shell_length, shell_width, shell_height));
-    ParticleCoreShell coreshell(shell, core, kvector_t(0.0, 0.0, (shell_height-core_height)/2.0));
-    coreshell.setRotation(RotationZ(90.0*Units::degree));
-    coreshell.rotate(RotationY(90.0*Units::degree));
-    coreshell.setPosition(kvector_t(0.0, 0.0, -layer_thickness/2.0));
+    ParticleCoreShell coreshell(shell, core,
+                                kvector_t(0.0, 0.0, (shell_height - core_height) / 2.0));
+    coreshell.setRotation(RotationZ(90.0 * Units::degree));
+    coreshell.rotate(RotationY(90.0 * Units::degree));
+    coreshell.setPosition(kvector_t(0.0, 0.0, -layer_thickness / 2.0));
 
     ParticleLayout layout;
     layout.addParticle(coreshell);
diff --git a/Core/StandardSamples/CoreShellParticleBuilder.h b/Core/StandardSamples/CoreShellParticleBuilder.h
index 502fab55a4b..a064cb2e2ca 100644
--- a/Core/StandardSamples/CoreShellParticleBuilder.h
+++ b/Core/StandardSamples/CoreShellParticleBuilder.h
@@ -25,18 +25,17 @@ class ISample;
 class BA_CORE_API_ CoreShellParticleBuilder : public IMultiLayerBuilder
 {
 public:
-    CoreShellParticleBuilder(){}
+    CoreShellParticleBuilder() {}
     MultiLayer* buildSample() const;
 };
 
-
 //! Rotation and translation of core shell box particle in 3 layers system.
 //! @ingroup standard_samples
 
 class BA_CORE_API_ CoreShellBoxRotateZandYBuilder : public IMultiLayerBuilder
 {
 public:
-    CoreShellBoxRotateZandYBuilder(){}
+    CoreShellBoxRotateZandYBuilder() {}
     MultiLayer* buildSample() const;
 };
 
diff --git a/Core/StandardSamples/CustomMorphologyBuilder.cpp b/Core/StandardSamples/CustomMorphologyBuilder.cpp
index fbfc905455c..427cd2d80dd 100644
--- a/Core/StandardSamples/CustomMorphologyBuilder.cpp
+++ b/Core/StandardSamples/CustomMorphologyBuilder.cpp
@@ -13,9 +13,9 @@
 // ************************************************************************** //
 
 #include "CustomMorphologyBuilder.h"
-#include "MaterialFactoryFuncs.h"
 #include "FormFactorBox.h"
 #include "Layer.h"
+#include "MaterialFactoryFuncs.h"
 #include "MultiLayer.h"
 #include "Particle.h"
 #include "ParticleLayout.h"
@@ -34,71 +34,71 @@ MultiLayer* CustomMorphologyBuilder::buildSample() const
     ParticleLayout particle_layout;
 
     // add particle number 1:
-    FormFactorBox ff1(2.0*Units::nanometer, 2.0*Units::nanometer, 1.0*Units::nanometer);
-    kvector_t pos1(0.0*Units::nanometer, 0.0*Units::nanometer, 0.0);
+    FormFactorBox ff1(2.0 * Units::nanometer, 2.0 * Units::nanometer, 1.0 * Units::nanometer);
+    kvector_t pos1(0.0 * Units::nanometer, 0.0 * Units::nanometer, 0.0);
     Particle p1(particle_material, ff1);
     p1.setPosition(pos1);
     particle_layout.addParticle(p1, 0.5);
     // add particle number 2:
-    FormFactorBox ff2(2.0*Units::nanometer, 4.0*Units::nanometer, 1.0*Units::nanometer);
-    kvector_t pos2(5.0*Units::nanometer, 5.0*Units::nanometer, 0.0);
-    RotationZ m2(10*Units::degree);
+    FormFactorBox ff2(2.0 * Units::nanometer, 4.0 * Units::nanometer, 1.0 * Units::nanometer);
+    kvector_t pos2(5.0 * Units::nanometer, 5.0 * Units::nanometer, 0.0);
+    RotationZ m2(10 * Units::degree);
     Particle p2(particle_material, ff2, m2);
     p2.setPosition(pos2);
     particle_layout.addParticle(p2, 0.5);
     // add particle number 3:
-    FormFactorBox ff3(2.0*Units::nanometer, 6.0*Units::nanometer, 1.0*Units::nanometer);
-    kvector_t pos3(-5.0*Units::nanometer, -5.0*Units::nanometer, 0.0);
-    RotationZ m3(20*Units::degree);
+    FormFactorBox ff3(2.0 * Units::nanometer, 6.0 * Units::nanometer, 1.0 * Units::nanometer);
+    kvector_t pos3(-5.0 * Units::nanometer, -5.0 * Units::nanometer, 0.0);
+    RotationZ m3(20 * Units::degree);
     Particle p3(particle_material, ff3, m3);
     p3.setPosition(pos3);
     particle_layout.addParticle(p3, 0.5);
     // add particle number 4:
-    FormFactorBox ff4(2.0*Units::nanometer, 8.0*Units::nanometer, 1.0*Units::nanometer);
-    kvector_t pos4(5.0*Units::nanometer, -5.0*Units::nanometer, 0.0);
-    RotationZ m4(30*Units::degree);
+    FormFactorBox ff4(2.0 * Units::nanometer, 8.0 * Units::nanometer, 1.0 * Units::nanometer);
+    kvector_t pos4(5.0 * Units::nanometer, -5.0 * Units::nanometer, 0.0);
+    RotationZ m4(30 * Units::degree);
     Particle p4(particle_material, ff4, m4);
     p4.setPosition(pos4);
     particle_layout.addParticle(p4, 0.5);
     // add particle number 5:
-    FormFactorBox ff5(2.0*Units::nanometer, 10.0*Units::nanometer, 1.0*Units::nanometer);
-    kvector_t pos5(-5.0*Units::nanometer, 5.0*Units::nanometer, 0.0);
-    RotationZ m5(40*Units::degree);
+    FormFactorBox ff5(2.0 * Units::nanometer, 10.0 * Units::nanometer, 1.0 * Units::nanometer);
+    kvector_t pos5(-5.0 * Units::nanometer, 5.0 * Units::nanometer, 0.0);
+    RotationZ m5(40 * Units::degree);
     Particle p5(particle_material, ff5, m5);
     p5.setPosition(pos5);
     particle_layout.addParticle(p5, 0.5);
     // add particle number 6:
-    FormFactorBox ff6(2.0*Units::nanometer, 2.0*Units::nanometer, 1.0*Units::nanometer);
-    kvector_t pos6(0.0*Units::nanometer, 0.0*Units::nanometer, 0.0);
-    RotationZ m6(50*Units::degree);
+    FormFactorBox ff6(2.0 * Units::nanometer, 2.0 * Units::nanometer, 1.0 * Units::nanometer);
+    kvector_t pos6(0.0 * Units::nanometer, 0.0 * Units::nanometer, 0.0);
+    RotationZ m6(50 * Units::degree);
     Particle p6(particle_material, ff6, m6);
     p6.setPosition(pos6);
     particle_layout.addParticle(p6, 0.5);
     // add particle number 7:
-    FormFactorBox ff7(2.0*Units::nanometer, 4.0*Units::nanometer, 1.0*Units::nanometer);
-    kvector_t pos7(5.0*Units::nanometer, 5.0*Units::nanometer, 0.0);
-    RotationZ m7(60*Units::degree);
+    FormFactorBox ff7(2.0 * Units::nanometer, 4.0 * Units::nanometer, 1.0 * Units::nanometer);
+    kvector_t pos7(5.0 * Units::nanometer, 5.0 * Units::nanometer, 0.0);
+    RotationZ m7(60 * Units::degree);
     Particle p7(particle_material, ff7, m7);
     p7.setPosition(pos7);
     particle_layout.addParticle(p7, 0.5);
     // add particle number 8:
-    FormFactorBox ff8(2.0*Units::nanometer, 6.0*Units::nanometer, 1.0*Units::nanometer);
-    kvector_t pos8(-5.0*Units::nanometer, -5.0*Units::nanometer, 0.0);
-    RotationZ m8(70*Units::degree);
+    FormFactorBox ff8(2.0 * Units::nanometer, 6.0 * Units::nanometer, 1.0 * Units::nanometer);
+    kvector_t pos8(-5.0 * Units::nanometer, -5.0 * Units::nanometer, 0.0);
+    RotationZ m8(70 * Units::degree);
     Particle p8(particle_material, ff8, m8);
     p8.setPosition(pos8);
     particle_layout.addParticle(p8, 0.5);
     // add particle number 9:
-    FormFactorBox ff9(2.0*Units::nanometer, 8.0*Units::nanometer, 1.0*Units::nanometer);
-    kvector_t pos9(5.0*Units::nanometer, -5.0*Units::nanometer, 0.0);
-    RotationZ m9(80*Units::degree);
+    FormFactorBox ff9(2.0 * Units::nanometer, 8.0 * Units::nanometer, 1.0 * Units::nanometer);
+    kvector_t pos9(5.0 * Units::nanometer, -5.0 * Units::nanometer, 0.0);
+    RotationZ m9(80 * Units::degree);
     Particle p9(particle_material, ff9, m9);
     p9.setPosition(pos9);
     particle_layout.addParticle(p9, 0.5);
     // add particle number 10:
-    FormFactorBox ff10(2.0*Units::nanometer, 10.0*Units::nanometer, 1.0*Units::nanometer);
-    kvector_t pos10(-5.0*Units::nanometer, 5.0*Units::nanometer, 0.0);
-    RotationZ m10(90*Units::degree);
+    FormFactorBox ff10(2.0 * Units::nanometer, 10.0 * Units::nanometer, 1.0 * Units::nanometer);
+    kvector_t pos10(-5.0 * Units::nanometer, 5.0 * Units::nanometer, 0.0);
+    RotationZ m10(90 * Units::degree);
     Particle p10(particle_material, ff10, m10);
     p10.setPosition(pos10);
     particle_layout.addParticle(p10, 0.5);
diff --git a/Core/StandardSamples/CylindersAndPrismsBuilder.cpp b/Core/StandardSamples/CylindersAndPrismsBuilder.cpp
index c4479d2cafe..6b540ea1dca 100644
--- a/Core/StandardSamples/CylindersAndPrismsBuilder.cpp
+++ b/Core/StandardSamples/CylindersAndPrismsBuilder.cpp
@@ -13,19 +13,18 @@
 // ************************************************************************** //
 
 #include "CylindersAndPrismsBuilder.h"
-#include "MaterialFactoryFuncs.h"
 #include "BornAgainNamespace.h"
 #include "FormFactorCylinder.h"
 #include "FormFactorPrism3.h"
 #include "Layer.h"
+#include "MaterialFactoryFuncs.h"
 #include "MultiLayer.h"
 #include "Particle.h"
 #include "ParticleLayout.h"
 #include "RealParameter.h"
 #include "Units.h"
 
-CylindersAndPrismsBuilder::CylindersAndPrismsBuilder()
-{}
+CylindersAndPrismsBuilder::CylindersAndPrismsBuilder() {}
 
 MultiLayer* CylindersAndPrismsBuilder::buildSample() const
 {
diff --git a/Core/StandardSamples/CylindersBuilder.cpp b/Core/StandardSamples/CylindersBuilder.cpp
index dc23e80a908..6374a59ea40 100644
--- a/Core/StandardSamples/CylindersBuilder.cpp
+++ b/Core/StandardSamples/CylindersBuilder.cpp
@@ -13,11 +13,11 @@
 // ************************************************************************** //
 
 #include "CylindersBuilder.h"
-#include "MaterialFactoryFuncs.h"
 #include "BornAgainNamespace.h"
 #include "FormFactorCylinder.h"
 #include "Layer.h"
 #include "LayerInterface.h"
+#include "MaterialFactoryFuncs.h"
 #include "MultiLayer.h"
 #include "Particle.h"
 #include "ParticleLayout.h"
@@ -29,9 +29,9 @@
 // Cylinders in DWBA
 // -----------------------------------------------------------------------------
 CylindersInDWBABuilder::CylindersInDWBABuilder()
-    : m_height(5*Units::nanometer)
-    , m_radius(5*Units::nanometer)
-{}
+    : m_height(5 * Units::nanometer), m_radius(5 * Units::nanometer)
+{
+}
 
 MultiLayer* CylindersInDWBABuilder::buildSample() const
 {
@@ -61,8 +61,7 @@ MultiLayer* CylindersInDWBABuilder::buildSample() const
 // Cylinders in BA
 // -----------------------------------------------------------------------------
 CylindersInBABuilder::CylindersInBABuilder()
-    : m_height(5*Units::nanometer)
-    , m_radius(5*Units::nanometer)
+    : m_height(5 * Units::nanometer), m_radius(5 * Units::nanometer)
 {
     registerParameter("height", &m_height);
     registerParameter("radius", &m_radius);
@@ -78,7 +77,7 @@ MultiLayer* CylindersInBABuilder::buildSample() const
     Layer air_layer(air_material);
 
     FormFactorCylinder ff_cylinder(m_radius, m_height);
-    Particle cylinder(particle_material,ff_cylinder);
+    Particle cylinder(particle_material, ff_cylinder);
 
     ParticleLayout particle_layout(cylinder);
 
@@ -92,9 +91,9 @@ MultiLayer* CylindersInBABuilder::buildSample() const
 // Large cylinders in DWBA
 // -----------------------------------------------------------------------------
 LargeCylindersInDWBABuilder::LargeCylindersInDWBABuilder()
-    : m_height(1000*Units::nanometer)
-    , m_radius(500*Units::nanometer)
-{}
+    : m_height(1000 * Units::nanometer), m_radius(500 * Units::nanometer)
+{
+}
 
 MultiLayer* LargeCylindersInDWBABuilder::buildSample() const
 {
@@ -124,9 +123,9 @@ MultiLayer* LargeCylindersInDWBABuilder::buildSample() const
 // Rotated cylinders in DWBA
 // -----------------------------------------------------------------------------
 RotatedCylindersBuilder::RotatedCylindersBuilder()
-    : m_height(5*Units::nanometer)
-    , m_radius(5*Units::nanometer)
-{}
+    : m_height(5 * Units::nanometer), m_radius(5 * Units::nanometer)
+{
+}
 
 MultiLayer* RotatedCylindersBuilder::buildSample() const
 {
diff --git a/Core/StandardSamples/CylindersBuilder.h b/Core/StandardSamples/CylindersBuilder.h
index c5f6e202db6..22dac4f280b 100644
--- a/Core/StandardSamples/CylindersBuilder.h
+++ b/Core/StandardSamples/CylindersBuilder.h
@@ -75,5 +75,4 @@ private:
     double m_radius;
 };
 
-
 #endif // CYLINDERSBUILDER_H
diff --git a/Core/StandardSamples/HomogeneousMultilayerBuilder.cpp b/Core/StandardSamples/HomogeneousMultilayerBuilder.cpp
index 1f36410691f..eda0f8950d5 100644
--- a/Core/StandardSamples/HomogeneousMultilayerBuilder.cpp
+++ b/Core/StandardSamples/HomogeneousMultilayerBuilder.cpp
@@ -13,18 +13,17 @@
 // ************************************************************************** //
 
 #include "HomogeneousMultilayerBuilder.h"
-#include "MaterialFactoryFuncs.h"
 #include "Layer.h"
+#include "MaterialFactoryFuncs.h"
 #include "MultiLayer.h"
 
 HomogeneousMultilayerBuilder::HomogeneousMultilayerBuilder()
-    : m_number_of_layers(10)
-    , m_delta_ti(-7.36e-7)
-    , m_delta_ni(3.557e-6)
-    , m_delta_si(7.81e-7)
-    , m_thick_ti(3.0) // nm
-    , m_thick_ni(7.0) //nm
-{}
+    : m_number_of_layers(10), m_delta_ti(-7.36e-7), m_delta_ni(3.557e-6), m_delta_si(7.81e-7),
+      m_thick_ti(3.0) // nm
+      ,
+      m_thick_ni(7.0) // nm
+{
+}
 
 MultiLayer* HomogeneousMultilayerBuilder::buildSample() const
 {
@@ -42,10 +41,9 @@ MultiLayer* HomogeneousMultilayerBuilder::buildSample() const
 
     multi_layer->addLayer(vacuum_layer);
     for (size_t i = 0; i < m_number_of_layers; ++i) {
-	multi_layer->addLayer(ti_layer);
-	multi_layer->addLayer(ni_layer);
+        multi_layer->addLayer(ti_layer);
+        multi_layer->addLayer(ni_layer);
     }
     multi_layer->addLayer(substrate_layer);
     return multi_layer.release();
 }
-
diff --git a/Core/StandardSamples/IFactory.h b/Core/StandardSamples/IFactory.h
index bc1828d0a6c..f0a0396253c 100644
--- a/Core/StandardSamples/IFactory.h
+++ b/Core/StandardSamples/IFactory.h
@@ -18,14 +18,13 @@
 #include "Exceptions.h"
 #include <functional>
 #include <map>
-#include <sstream>
 #include <memory>
+#include <sstream>
 
 //! Base class for all factories.
 //! @ingroup tools_internal
 
-template<class Key, class AbstractProduct >
-class IFactory
+template <class Key, class AbstractProduct> class IFactory
 {
 public:
     //! function which will be used to create object of AbstractProduct base type
@@ -42,24 +41,24 @@ public:
     IFactory() {}
 
     //! Creates object by calling creation function corresponded to given identifier
-    AbstractProduct* createItem(const Key& item_key) {
+    AbstractProduct* createItem(const Key& item_key)
+    {
         auto it = m_callbacks.find(item_key);
-        if( it == m_callbacks.end() ) {
+        if (it == m_callbacks.end()) {
             std::ostringstream message;
-            message << "IFactory::createItem() -> Error. Unknown item key '"
-                    << item_key << "'";
+            message << "IFactory::createItem() -> Error. Unknown item key '" << item_key << "'";
             throw Exceptions::RuntimeErrorException(message.str());
         }
         return (it->second)();
     }
 
 #ifndef SWIG
-    std::unique_ptr<AbstractProduct> create(const Key& item_key) const{
+    std::unique_ptr<AbstractProduct> create(const Key& item_key) const
+    {
         auto it = m_callbacks.find(item_key);
-        if( it == m_callbacks.end() ) {
+        if (it == m_callbacks.end()) {
             std::ostringstream message;
-            message << "IFactory::createItem() -> Error. Unknown item key '"
-                    << item_key << "'";
+            message << "IFactory::createItem() -> Error. Unknown item key '" << item_key << "'";
             throw Exceptions::RuntimeErrorException(message.str());
         }
         return std::unique_ptr<AbstractProduct>((it->second)());
@@ -68,14 +67,15 @@ public:
 
     //! Registers object's creation function and store object description
     bool registerItem(const Key& item_key, CreateItemCallback CreateFn,
-                      const std::string& itemDescription="") {
+                      const std::string& itemDescription = "")
+    {
         if (m_callbacks.find(item_key) != m_callbacks.end()) {
             std::ostringstream message;
-            message << "IFactory::createItem() -> Error. Already registered item key '"
-                    << item_key << "'";
+            message << "IFactory::createItem() -> Error. Already registered item key '" << item_key
+                    << "'";
             throw Exceptions::RuntimeErrorException(message.str());
         }
-        if (itemDescription!="")
+        if (itemDescription != "")
             m_descriptions.insert(make_pair(item_key, itemDescription));
         return m_callbacks.insert(make_pair(item_key, CreateFn)).second;
     }
@@ -94,10 +94,13 @@ public:
     const_iterator end() const { return m_descriptions.end(); }
 
 protected:
-    CallbackMap_t m_callbacks;     //!< map of correspondence of objectsId and creation functions
-    DescriptionMap_t m_descriptions;     //!< map of correspondence of objectsId and description
+    CallbackMap_t m_callbacks;       //!< map of correspondence of objectsId and creation functions
+    DescriptionMap_t m_descriptions; //!< map of correspondence of objectsId and description
 };
 
-template<class T> T* create_new() { return new T(); }
+template <class T> T* create_new()
+{
+    return new T();
+}
 
 #endif // IFACTORY_H
diff --git a/Core/StandardSamples/IRegistry.h b/Core/StandardSamples/IRegistry.h
index 9ff7c9ac7a9..f8328434ae4 100644
--- a/Core/StandardSamples/IRegistry.h
+++ b/Core/StandardSamples/IRegistry.h
@@ -25,30 +25,32 @@
 //! @ingroup tools_internal
 //! @brief Templated object registry.
 
-template<class ValueType>
-class IRegistry
+template <class ValueType> class IRegistry
 {
 public:
-    const ValueType* getItem(const std::string& key) const {
+    const ValueType* getItem(const std::string& key) const
+    {
         auto it = m_data.find(key);
-        if(it == m_data.end())
+        if (it == m_data.end())
             throw Exceptions::UnknownClassRegistrationException(
                 "IRegistry::createItem() -> Error. Not existing item key '" + key + "'");
         return it->second.get();
     }
 
-    std::vector<std::string> keys() {
+    std::vector<std::string> keys()
+    {
         std::vector<std::string> result;
-        for( auto it=m_data.begin(); it!=m_data.end(); ++it )
-            result.push_back( it->first );
+        for (auto it = m_data.begin(); it != m_data.end(); ++it)
+            result.push_back(it->first);
         return result;
     }
 
     size_t size() const { return m_data.size(); }
 
 protected:
-    void add(const std::string& key, ValueType* item) {
-        if(m_data.find(key) != m_data.end())
+    void add(const std::string& key, ValueType* item)
+    {
+        if (m_data.find(key) != m_data.end())
             throw Exceptions::ExistingClassRegistrationException(
                 "IRegistry::createItem() -> Error. Already existing item with key '" + key + "'");
         m_data[key] = std::unique_ptr<ValueType>(item);
diff --git a/Core/StandardSamples/LatticeBuilder.cpp b/Core/StandardSamples/LatticeBuilder.cpp
index d790ac39594..726bfa109b3 100644
--- a/Core/StandardSamples/LatticeBuilder.cpp
+++ b/Core/StandardSamples/LatticeBuilder.cpp
@@ -13,12 +13,12 @@
 // ************************************************************************** //
 
 #include "LatticeBuilder.h"
-#include "MaterialFactoryFuncs.h"
 #include "BornAgainNamespace.h"
 #include "FTDecayFunctions.h"
 #include "FormFactorCylinder.h"
 #include "InterferenceFunction1DLattice.h"
 #include "Layer.h"
+#include "MaterialFactoryFuncs.h"
 #include "MultiLayer.h"
 #include "Particle.h"
 #include "ParticleLayout.h"
@@ -26,12 +26,11 @@
 #include "Units.h"
 
 Lattice1DBuilder::Lattice1DBuilder()
-    : m_length(20.0*Units::nanometer)
-    , m_xi(10.0*Units::deg)
-    , m_corr_length(1000.0*Units::nanometer)
-    , m_cylinder_height(5*Units::nanometer)
-    , m_cylinder_radius(5*Units::nanometer)
-{}
+    : m_length(20.0 * Units::nanometer), m_xi(10.0 * Units::deg),
+      m_corr_length(1000.0 * Units::nanometer), m_cylinder_height(5 * Units::nanometer),
+      m_cylinder_radius(5 * Units::nanometer)
+{
+}
 
 MultiLayer* Lattice1DBuilder::buildSample() const
 {
diff --git a/Core/StandardSamples/LayersWithAbsorptionBuilder.cpp b/Core/StandardSamples/LayersWithAbsorptionBuilder.cpp
index 3921432c930..ebe77444386 100644
--- a/Core/StandardSamples/LayersWithAbsorptionBuilder.cpp
+++ b/Core/StandardSamples/LayersWithAbsorptionBuilder.cpp
@@ -13,23 +13,22 @@
 // ************************************************************************** //
 
 #include "LayersWithAbsorptionBuilder.h"
-#include "MaterialFactoryFuncs.h"
 #include "Exceptions.h"
+#include "FormFactors.h"
 #include "Layer.h"
 #include "LayerInterface.h"
 #include "LayerRoughness.h"
+#include "MaterialFactoryFuncs.h"
 #include "MultiLayer.h"
 #include "Particle.h"
 #include "ParticleLayout.h"
 #include "RealParameter.h"
-#include "Units.h"
 #include "SampleComponents.h"
-#include "FormFactors.h"
+#include "Units.h"
 
 LayersWithAbsorptionBuilder::LayersWithAbsorptionBuilder()
-    : m_ff(new FormFactorFullSphere(5.0*Units::nanometer))
+    : m_ff(new FormFactorFullSphere(5.0 * Units::nanometer))
 {
-
 }
 
 LayersWithAbsorptionBuilder::~LayersWithAbsorptionBuilder() = default;
@@ -41,13 +40,13 @@ MultiLayer* LayersWithAbsorptionBuilder::buildSample() const
     Material mSubstrate = HomogeneousMaterial("Substrate", 3.212e-6, 3.244e-8);
     Material mParticle = HomogeneousMaterial("Ag", 1.245e-5, 5.419e-7);
 
-    const double middle_layer_thickness(60.0*Units::nanometer);
+    const double middle_layer_thickness(60.0 * Units::nanometer);
 
     Particle particle(mParticle, *m_ff);
-    particle.setRotation(RotationZ(10.0*Units::degree));
-    particle.rotate(RotationY(10.0*Units::degree));
-    particle.rotate(RotationX(10.0*Units::degree));
-    particle.setPosition(kvector_t(0.0, 0.0, -middle_layer_thickness/2.0 ));
+    particle.setRotation(RotationZ(10.0 * Units::degree));
+    particle.rotate(RotationY(10.0 * Units::degree));
+    particle.rotate(RotationX(10.0 * Units::degree));
+    particle.setPosition(kvector_t(0.0, 0.0, -middle_layer_thickness / 2.0));
 
     ParticleLayout layout;
     layout.addParticle(particle);
@@ -67,7 +66,7 @@ MultiLayer* LayersWithAbsorptionBuilder::buildSample() const
 
 MultiLayer* LayersWithAbsorptionBuilder::createSample(size_t index)
 {
-    if(index >= size())
+    if (index >= size())
         throw std::runtime_error("ParticleInTheAirBuilder::createSample() -> Error. "
                                  "Sample index is out of range.");
 
@@ -89,4 +88,3 @@ FormFactorComponents& LayersWithAbsorptionBuilder::ff_components()
     static FormFactorComponents result = FormFactorComponents();
     return result;
 }
-
diff --git a/Core/StandardSamples/LayersWithAbsorptionBuilder.h b/Core/StandardSamples/LayersWithAbsorptionBuilder.h
index 0dc2703cd8a..516a1bb928a 100644
--- a/Core/StandardSamples/LayersWithAbsorptionBuilder.h
+++ b/Core/StandardSamples/LayersWithAbsorptionBuilder.h
@@ -35,7 +35,7 @@ public:
     ~LayersWithAbsorptionBuilder();
     virtual MultiLayer* buildSample() const;
 
-    MultiLayer* createSample(size_t index=0);
+    MultiLayer* createSample(size_t index = 0);
     size_t size();
 
 private:
diff --git a/Core/StandardSamples/MagneticLayersBuilder.cpp b/Core/StandardSamples/MagneticLayersBuilder.cpp
index b43dd68a08c..e4af00449b5 100644
--- a/Core/StandardSamples/MagneticLayersBuilder.cpp
+++ b/Core/StandardSamples/MagneticLayersBuilder.cpp
@@ -13,22 +13,22 @@
 // ************************************************************************** //
 
 #include "MagneticLayersBuilder.h"
-#include "MaterialFactoryFuncs.h"
 #include "BornAgainNamespace.h"
 #include "FormFactorFullSphere.h"
 #include "Layer.h"
+#include "MaterialFactoryFuncs.h"
 #include "MultiLayer.h"
 #include "Particle.h"
 #include "ParticleLayout.h"
 #include "RealParameter.h"
 #include "Units.h"
 
-
 MagneticSubstrateZeroFieldBuilder::MagneticSubstrateZeroFieldBuilder()
-    : m_sphere_radius(5*Units::nanometer)
-{}
+    : m_sphere_radius(5 * Units::nanometer)
+{
+}
 
-MultiLayer*MagneticSubstrateZeroFieldBuilder::buildSample() const
+MultiLayer* MagneticSubstrateZeroFieldBuilder::buildSample() const
 {
     MultiLayer* multi_layer = new MultiLayer();
 
@@ -39,7 +39,7 @@ MultiLayer*MagneticSubstrateZeroFieldBuilder::buildSample() const
     Material particle_material = HomogeneousMaterial("MagParticle", 6e-4, 2e-8, particle_field);
 
     ParticleLayout particle_layout;
-    kvector_t position(0.0, 0.0, -10.0*Units::nanometer);
+    kvector_t position(0.0, 0.0, -10.0 * Units::nanometer);
     FormFactorFullSphere ff_sphere(m_sphere_radius);
     Particle particle(particle_material, ff_sphere);
     particle_layout.addParticle(particle, 1.0, position);
@@ -74,9 +74,7 @@ MultiLayer* SimpleMagneticLayerBuilder::buildSample() const
     return multi_layer;
 }
 
-MagneticLayerBuilder::MagneticLayerBuilder()
-    : m_sphere_radius(5*Units::nanometer)
-{}
+MagneticLayerBuilder::MagneticLayerBuilder() : m_sphere_radius(5 * Units::nanometer) {}
 
 MultiLayer* MagneticLayerBuilder::buildSample() const
 {
@@ -105,9 +103,7 @@ MultiLayer* MagneticLayerBuilder::buildSample() const
     return multi_layer;
 }
 
-MagneticRotationBuilder::MagneticRotationBuilder()
-    : m_sphere_radius(5*Units::nanometer)
-{}
+MagneticRotationBuilder::MagneticRotationBuilder() : m_sphere_radius(5 * Units::nanometer) {}
 
 MultiLayer* MagneticRotationBuilder::buildSample() const
 {
@@ -120,10 +116,10 @@ MultiLayer* MagneticRotationBuilder::buildSample() const
     Material particle_material = HomogeneousMaterial("MagParticle", 6e-4, 2e-8, particle_field);
 
     ParticleLayout particle_layout;
-    kvector_t position(0.0, 0.0, -10.0*Units::nanometer);
+    kvector_t position(0.0, 0.0, -10.0 * Units::nanometer);
     FormFactorFullSphere ff_sphere(m_sphere_radius);
     Particle particle(particle_material, ff_sphere);
-    RotationZ rot_z(90*Units::deg);
+    RotationZ rot_z(90 * Units::deg);
     particle_layout.addParticle(particle, 1.0, position, rot_z);
 
     Layer air_layer(air_material);
diff --git a/Core/StandardSamples/MagneticParticlesBuilder.cpp b/Core/StandardSamples/MagneticParticlesBuilder.cpp
index 8a0abbff969..3122780cded 100644
--- a/Core/StandardSamples/MagneticParticlesBuilder.cpp
+++ b/Core/StandardSamples/MagneticParticlesBuilder.cpp
@@ -13,13 +13,13 @@
 // ************************************************************************** //
 
 #include "MagneticParticlesBuilder.h"
-#include "MaterialFactoryFuncs.h"
 #include "BornAgainNamespace.h"
 #include "FormFactorCylinder.h"
 #include "FormFactorFullSphere.h"
 #include "Layer.h"
 #include "LayerInterface.h"
 #include "LayerRoughness.h"
+#include "MaterialFactoryFuncs.h"
 #include "MultiLayer.h"
 #include "Particle.h"
 #include "ParticleLayout.h"
@@ -30,9 +30,9 @@
 // Magnetic cylinders and zero magnetic field
 // ----------------------------------------------------------------------------
 MagneticParticleZeroFieldBuilder::MagneticParticleZeroFieldBuilder()
-    :  m_cylinder_radius(5*Units::nanometer)
-    ,  m_cylinder_height(5*Units::nanometer)
-{}
+    : m_cylinder_radius(5 * Units::nanometer), m_cylinder_height(5 * Units::nanometer)
+{
+}
 
 MultiLayer* MagneticParticleZeroFieldBuilder::buildSample() const
 {
@@ -62,9 +62,9 @@ MultiLayer* MagneticParticleZeroFieldBuilder::buildSample() const
 // Magnetic cylinders and non-zero magnetization
 // ----------------------------------------------------------------------------
 MagneticCylindersBuilder::MagneticCylindersBuilder()
-    :  m_cylinder_radius(5*Units::nanometer)
-    ,  m_cylinder_height(5*Units::nanometer)
-{}
+    : m_cylinder_radius(5 * Units::nanometer), m_cylinder_height(5 * Units::nanometer)
+{
+}
 
 MultiLayer* MagneticCylindersBuilder::buildSample() const
 {
@@ -93,9 +93,7 @@ MultiLayer* MagneticCylindersBuilder::buildSample() const
 // ----------------------------------------------------------------------------
 // Magnetic spheres inside substrate
 // ----------------------------------------------------------------------------
-MagneticSpheresBuilder::MagneticSpheresBuilder()
-    : m_sphere_radius(5*Units::nanometer)
-{}
+MagneticSpheresBuilder::MagneticSpheresBuilder() : m_sphere_radius(5 * Units::nanometer) {}
 
 MultiLayer* MagneticSpheresBuilder::buildSample() const
 {
@@ -107,7 +105,7 @@ MultiLayer* MagneticSpheresBuilder::buildSample() const
 
     FormFactorFullSphere ff_sphere(m_sphere_radius);
     Particle particle(particle_material, ff_sphere);
-    kvector_t position(0.0, 0.0, -2.0*m_sphere_radius);
+    kvector_t position(0.0, 0.0, -2.0 * m_sphere_radius);
 
     ParticleLayout particle_layout;
     particle_layout.addParticle(particle, 1.0, position);
diff --git a/Core/StandardSamples/MesoCrystalBuilder.cpp b/Core/StandardSamples/MesoCrystalBuilder.cpp
index 0e7309fbc64..3beaceca78b 100644
--- a/Core/StandardSamples/MesoCrystalBuilder.cpp
+++ b/Core/StandardSamples/MesoCrystalBuilder.cpp
@@ -13,7 +13,6 @@
 // ************************************************************************** //
 
 #include "MesoCrystalBuilder.h"
-#include "MaterialFactoryFuncs.h"
 #include "BornAgainNamespace.h"
 #include "Crystal.h"
 #include "FormFactorCylinder.h"
@@ -22,17 +21,17 @@
 #include "Layer.h"
 #include "LayerInterface.h"
 #include "LayerRoughness.h"
+#include "MaterialFactoryFuncs.h"
+#include "MathConstants.h"
 #include "MesoCrystal.h"
 #include "MultiLayer.h"
 #include "Particle.h"
 #include "ParticleComposition.h"
 #include "ParticleLayout.h"
-#include "MathConstants.h"
 #include "RealParameter.h"
 #include "Units.h"
 
-MesoCrystalBuilder::MesoCrystalBuilder()
-{}
+MesoCrystalBuilder::MesoCrystalBuilder() {}
 
 MultiLayer* MesoCrystalBuilder::buildSample() const
 {
diff --git a/Core/StandardSamples/MesoCrystalBuilder.h b/Core/StandardSamples/MesoCrystalBuilder.h
index 964a9f4caa8..2fc8903fc30 100644
--- a/Core/StandardSamples/MesoCrystalBuilder.h
+++ b/Core/StandardSamples/MesoCrystalBuilder.h
@@ -15,8 +15,8 @@
 #ifndef MESOCRYSTALBUILDER_H
 #define MESOCRYSTALBUILDER_H
 
-#include "IMultiLayerBuilder.h"
 #include "Complex.h"
+#include "IMultiLayerBuilder.h"
 
 class IFormFactor;
 class ISample;
diff --git a/Core/StandardSamples/MultiLayerWithNCRoughnessBuilder.cpp b/Core/StandardSamples/MultiLayerWithNCRoughnessBuilder.cpp
index 0693f2992bf..4629f93073e 100644
--- a/Core/StandardSamples/MultiLayerWithNCRoughnessBuilder.cpp
+++ b/Core/StandardSamples/MultiLayerWithNCRoughnessBuilder.cpp
@@ -13,16 +13,15 @@
 // ************************************************************************** //
 
 #include "MultiLayerWithNCRoughnessBuilder.h"
-#include "MaterialFactoryFuncs.h"
+#include "BornAgainNamespace.h"
 #include "Layer.h"
 #include "LayerRoughness.h"
+#include "MaterialFactoryFuncs.h"
 #include "MultiLayer.h"
 #include "RealParameter.h"
 #include "Units.h"
-#include "BornAgainNamespace.h"
 
-MultiLayerWithNCRoughnessBuilder::MultiLayerWithNCRoughnessBuilder()
-{}
+MultiLayerWithNCRoughnessBuilder::MultiLayerWithNCRoughnessBuilder() {}
 
 MultiLayer* MultiLayerWithNCRoughnessBuilder::buildSample() const
 {
diff --git a/Core/StandardSamples/MultiLayerWithRoughnessBuilder.cpp b/Core/StandardSamples/MultiLayerWithRoughnessBuilder.cpp
index d56854f86dc..e9f960fb388 100644
--- a/Core/StandardSamples/MultiLayerWithRoughnessBuilder.cpp
+++ b/Core/StandardSamples/MultiLayerWithRoughnessBuilder.cpp
@@ -13,22 +13,20 @@
 // ************************************************************************** //
 
 #include "MultiLayerWithRoughnessBuilder.h"
-#include "MaterialFactoryFuncs.h"
+#include "BornAgainNamespace.h"
 #include "Layer.h"
 #include "LayerRoughness.h"
+#include "MaterialFactoryFuncs.h"
 #include "MultiLayer.h"
 #include "RealParameter.h"
 #include "Units.h"
-#include "BornAgainNamespace.h"
 
 MultiLayerWithRoughnessBuilder::MultiLayerWithRoughnessBuilder()
-    : m_thicknessA(2.5*Units::nanometer)
-    , m_thicknessB(5.0*Units::nanometer)
-    , m_sigma(1.0*Units::nanometer)
-    , m_hurst(0.3)
-    , m_lateralCorrLength(5.0*Units::nanometer)
-    , m_crossCorrLength(10.0*Units::nanometer)
-{}
+    : m_thicknessA(2.5 * Units::nanometer), m_thicknessB(5.0 * Units::nanometer),
+      m_sigma(1.0 * Units::nanometer), m_hurst(0.3), m_lateralCorrLength(5.0 * Units::nanometer),
+      m_crossCorrLength(10.0 * Units::nanometer)
+{
+}
 
 MultiLayer* MultiLayerWithRoughnessBuilder::buildSample() const
 {
@@ -46,7 +44,7 @@ MultiLayer* MultiLayerWithRoughnessBuilder::buildSample() const
     LayerRoughness roughness(m_sigma, m_hurst, m_lateralCorrLength);
 
     multi_layer->addLayer(air_layer);
-    for (int i = 0; i<5; ++i) {
+    for (int i = 0; i < 5; ++i) {
         multi_layer->addLayerWithTopRoughness(partA_layer, roughness);
         multi_layer->addLayerWithTopRoughness(partB_layer, roughness);
     }
diff --git a/Core/StandardSamples/MultipleLayoutBuilder.cpp b/Core/StandardSamples/MultipleLayoutBuilder.cpp
index 1ed2c55f321..e92194cd527 100644
--- a/Core/StandardSamples/MultipleLayoutBuilder.cpp
+++ b/Core/StandardSamples/MultipleLayoutBuilder.cpp
@@ -13,11 +13,11 @@
 // ************************************************************************** //
 
 #include "MultipleLayoutBuilder.h"
-#include "MaterialFactoryFuncs.h"
 #include "BornAgainNamespace.h"
 #include "FormFactorCylinder.h"
 #include "FormFactorPrism3.h"
 #include "Layer.h"
+#include "MaterialFactoryFuncs.h"
 #include "MultiLayer.h"
 #include "Particle.h"
 #include "ParticleLayout.h"
@@ -25,12 +25,11 @@
 #include "Units.h"
 
 MultipleLayoutBuilder::MultipleLayoutBuilder()
-    : m_cylinder_height(5*Units::nanometer)
-    , m_cylinder_radius(5*Units::nanometer)
-    , m_prism_height(5*Units::nanometer)
-    , m_prism_length(10*Units::nanometer)
-    , m_cylinder_weight(0.5)
-{}
+    : m_cylinder_height(5 * Units::nanometer), m_cylinder_radius(5 * Units::nanometer),
+      m_prism_height(5 * Units::nanometer), m_prism_length(10 * Units::nanometer),
+      m_cylinder_weight(0.5)
+{
+}
 
 MultiLayer* MultipleLayoutBuilder::buildSample() const
 {
@@ -53,7 +52,7 @@ MultiLayer* MultipleLayoutBuilder::buildSample() const
     Particle prism3(particle_material, ff_prism3);
 
     particle_layout_1.addParticle(cylinder, m_cylinder_weight);
-    particle_layout_2.addParticle(prism3, 1.0-m_cylinder_weight);
+    particle_layout_2.addParticle(prism3, 1.0 - m_cylinder_weight);
 
     air_layer.addLayout(particle_layout_1);
     air_layer.addLayout(particle_layout_2);
diff --git a/Core/StandardSamples/ParaCrystalBuilder.cpp b/Core/StandardSamples/ParaCrystalBuilder.cpp
index 763ca4bff9a..1729e16c224 100644
--- a/Core/StandardSamples/ParaCrystalBuilder.cpp
+++ b/Core/StandardSamples/ParaCrystalBuilder.cpp
@@ -13,26 +13,25 @@
 // ************************************************************************** //
 
 #include "ParaCrystalBuilder.h"
-#include "MaterialFactoryFuncs.h"
 #include "BornAgainNamespace.h"
 #include "FormFactorCylinder.h"
 #include "InterferenceFunction2DParaCrystal.h"
 #include "InterferenceFunctionRadialParaCrystal.h"
 #include "Layer.h"
+#include "MaterialFactoryFuncs.h"
 #include "MultiLayer.h"
 #include "Particle.h"
 #include "ParticleLayout.h"
 #include "RealParameter.h"
-#include "Units.h"
 #include "SampleComponents.h"
+#include "Units.h"
 
 RadialParaCrystalBuilder::RadialParaCrystalBuilder()
-    : m_corr_peak_distance(20.0*Units::nanometer)
-    , m_corr_width(7*Units::nanometer)
-    , m_corr_length(1e3*Units::nanometer)
-    , m_cylinder_height(5*Units::nanometer)
-    , m_cylinder_radius(5*Units::nanometer)
-{}
+    : m_corr_peak_distance(20.0 * Units::nanometer), m_corr_width(7 * Units::nanometer),
+      m_corr_length(1e3 * Units::nanometer), m_cylinder_height(5 * Units::nanometer),
+      m_cylinder_radius(5 * Units::nanometer)
+{
+}
 
 MultiLayer* RadialParaCrystalBuilder::buildSample() const
 {
@@ -68,9 +67,10 @@ MultiLayer* RadialParaCrystalBuilder::buildSample() const
 // -----------------------------------------------------------------------------
 
 Basic2DParaCrystalBuilder::Basic2DParaCrystalBuilder()
-    : m_pdf1(new FTDistribution2DCauchy(0.1*Units::nanometer, 0.2*Units::nanometer))
-    , m_pdf2(new FTDistribution2DCauchy(0.3*Units::nanometer, 0.4*Units::nanometer))
-{}
+    : m_pdf1(new FTDistribution2DCauchy(0.1 * Units::nanometer, 0.2 * Units::nanometer)),
+      m_pdf2(new FTDistribution2DCauchy(0.3 * Units::nanometer, 0.4 * Units::nanometer))
+{
+}
 
 Basic2DParaCrystalBuilder::~Basic2DParaCrystalBuilder() {}
 
@@ -89,12 +89,11 @@ MultiLayer* Basic2DParaCrystalBuilder::buildSample() const
         10.0 * Units::nanometer, 20.0 * Units::nanometer, 30.0 * Units::degree,
         45.0 * Units::degree, 1000.0 * Units::nanometer);
 
-    interference_function.setDomainSizes(20.0*Units::micrometer,
-            40.0*Units::micrometer);
+    interference_function.setDomainSizes(20.0 * Units::micrometer, 40.0 * Units::micrometer);
 
     interference_function.setProbabilityDistributions(*m_pdf1, *m_pdf2);
 
-    FormFactorCylinder ff_cylinder(5.0*Units::nanometer, 5.0*Units::nanometer);
+    FormFactorCylinder ff_cylinder(5.0 * Units::nanometer, 5.0 * Units::nanometer);
 
     Particle particle(particle_material, ff_cylinder);
     ParticleLayout particle_layout(particle);
@@ -110,7 +109,7 @@ MultiLayer* Basic2DParaCrystalBuilder::buildSample() const
 
 MultiLayer* Basic2DParaCrystalBuilder::createSample(size_t index)
 {
-    if(index >= size())
+    if (index >= size())
         throw std::runtime_error("Basic2DParaCrystalBuilder::createSample() -> Error. "
                                  "Sample index is out of range.");
 
@@ -133,20 +132,16 @@ FTDistribution2DComponents& Basic2DParaCrystalBuilder::pdf_components()
     return result;
 }
 
-
-
 // -----------------------------------------------------------------------------
 // HexParaCrystalBuilder
 // -----------------------------------------------------------------------------
 
 HexParaCrystalBuilder::HexParaCrystalBuilder()
-    : m_peak_distance(20.0*Units::nanometer)
-    , m_corr_length(0.0)
-    , m_domain_size_1(20.0*Units::micrometer)
-    , m_domain_size_2(20.0*Units::micrometer)
-    , m_cylinder_height(5*Units::nanometer)
-    , m_cylinder_radius(5*Units::nanometer)
-{}
+    : m_peak_distance(20.0 * Units::nanometer), m_corr_length(0.0),
+      m_domain_size_1(20.0 * Units::micrometer), m_domain_size_2(20.0 * Units::micrometer),
+      m_cylinder_height(5 * Units::nanometer), m_cylinder_radius(5 * Units::nanometer)
+{
+}
 
 MultiLayer* HexParaCrystalBuilder::buildSample() const
 {
@@ -162,11 +157,11 @@ MultiLayer* HexParaCrystalBuilder::buildSample() const
     std::unique_ptr<InterferenceFunction2DParaCrystal> P_interference_function{
         InterferenceFunction2DParaCrystal::createHexagonal(m_peak_distance, m_corr_length,
                                                            m_domain_size_1, m_domain_size_2)};
-    FTDistribution2DCauchy pdf(1.0*Units::nanometer, 1.0*Units::nanometer);
+    FTDistribution2DCauchy pdf(1.0 * Units::nanometer, 1.0 * Units::nanometer);
     P_interference_function->setProbabilityDistributions(pdf, pdf);
 
     FormFactorCylinder ff_cylinder(m_cylinder_radius, m_cylinder_height);
-    Particle cylinder(particle_material,ff_cylinder);
+    Particle cylinder(particle_material, ff_cylinder);
 
     ParticleLayout particle_layout(cylinder);
     particle_layout.setInterferenceFunction(*P_interference_function);
@@ -198,13 +193,12 @@ MultiLayer* RectParaCrystalBuilder::buildSample() const
         InterferenceFunction2DParaCrystal::createSquare(10 * Units::nanometer,
                                                         0 * Units::nanometer)};
 
-    P_interference_function->setDomainSizes(20.0*Units::micrometer,
-            20.0*Units::micrometer);
-    FTDistribution2DCauchy pdf1(0.5*Units::nanometer, 2.0*Units::nanometer);
-    FTDistribution2DCauchy pdf2(0.5*Units::nanometer, 2.0*Units::nanometer);
+    P_interference_function->setDomainSizes(20.0 * Units::micrometer, 20.0 * Units::micrometer);
+    FTDistribution2DCauchy pdf1(0.5 * Units::nanometer, 2.0 * Units::nanometer);
+    FTDistribution2DCauchy pdf2(0.5 * Units::nanometer, 2.0 * Units::nanometer);
     P_interference_function->setProbabilityDistributions(pdf1, pdf2);
 
-    FormFactorCylinder ff_cylinder(5.0*Units::nanometer, 5.0*Units::nanometer);
+    FormFactorCylinder ff_cylinder(5.0 * Units::nanometer, 5.0 * Units::nanometer);
 
     Particle particle(particle_material, ff_cylinder);
     ParticleLayout particle_layout(particle);
diff --git a/Core/StandardSamples/ParaCrystalBuilder.h b/Core/StandardSamples/ParaCrystalBuilder.h
index ddcf35122fd..862250ea5eb 100644
--- a/Core/StandardSamples/ParaCrystalBuilder.h
+++ b/Core/StandardSamples/ParaCrystalBuilder.h
@@ -50,7 +50,7 @@ public:
     virtual ~Basic2DParaCrystalBuilder();
     virtual MultiLayer* buildSample() const;
 
-    MultiLayer* createSample(size_t index=0);
+    MultiLayer* createSample(size_t index = 0);
     size_t size();
 
 private:
@@ -83,7 +83,7 @@ private:
 class BA_CORE_API_ RectParaCrystalBuilder : public IMultiLayerBuilder
 {
 public:
-    RectParaCrystalBuilder(){}
+    RectParaCrystalBuilder() {}
     virtual MultiLayer* buildSample() const;
 };
 
diff --git a/Core/StandardSamples/ParticleCompositionBuilder.cpp b/Core/StandardSamples/ParticleCompositionBuilder.cpp
index 5e9bf135e1d..595f91cdd57 100644
--- a/Core/StandardSamples/ParticleCompositionBuilder.cpp
+++ b/Core/StandardSamples/ParticleCompositionBuilder.cpp
@@ -13,10 +13,10 @@
 // ************************************************************************** //
 
 #include "ParticleCompositionBuilder.h"
-#include "MaterialFactoryFuncs.h"
 #include "FormFactorFullSphere.h"
 #include "InterferenceFunction2DLattice.h"
 #include "Layer.h"
+#include "MaterialFactoryFuncs.h"
 #include "MultiLayer.h"
 #include "Particle.h"
 #include "ParticleComposition.h"
@@ -37,13 +37,13 @@ MultiLayer* ParticleCompositionBuilder::buildSample() const
     Layer air_layer(air_material);
     Layer substrate_layer(substrate_material);
 
-    double radius(10.0*Units::nanometer);
+    double radius(10.0 * Units::nanometer);
     FormFactorFullSphere sphere_ff(radius);
     Particle sphere(particle_material, sphere_ff);
     ParticleLayout particle_layout;
 
     kvector_t pos0(0.0, 0.0, 0.0);
-    kvector_t pos1(radius, radius/std::sqrt(3.0), std::sqrt(8.0/3.0)*radius);
+    kvector_t pos1(radius, radius / std::sqrt(3.0), std::sqrt(8.0 / 3.0) * radius);
     std::vector<kvector_t> positions;
     positions.push_back(pos0);
     positions.push_back(pos1);
@@ -55,7 +55,7 @@ MultiLayer* ParticleCompositionBuilder::buildSample() const
 
     std::unique_ptr<InterferenceFunction2DLattice> P_interference{
         InterferenceFunction2DLattice::createHexagonal(radius * 2.0)};
-    FTDecayFunction2DCauchy pdf(10*Units::nanometer, 10*Units::nanometer);
+    FTDecayFunction2DCauchy pdf(10 * Units::nanometer, 10 * Units::nanometer);
     P_interference->setDecayFunction(pdf);
 
     particle_layout.setInterferenceFunction(*P_interference);
diff --git a/Core/StandardSamples/ParticleCompositionBuilder.h b/Core/StandardSamples/ParticleCompositionBuilder.h
index 5c653a6a1fc..244e6ae420a 100644
--- a/Core/StandardSamples/ParticleCompositionBuilder.h
+++ b/Core/StandardSamples/ParticleCompositionBuilder.h
@@ -23,7 +23,7 @@
 class BA_CORE_API_ ParticleCompositionBuilder : public IMultiLayerBuilder
 {
 public:
-    ParticleCompositionBuilder(){}
+    ParticleCompositionBuilder() {}
     MultiLayer* buildSample() const;
 };
 
diff --git a/Core/StandardSamples/ParticleDistributionsBuilder.cpp b/Core/StandardSamples/ParticleDistributionsBuilder.cpp
index a9ac28c8ac3..762429f13a6 100644
--- a/Core/StandardSamples/ParticleDistributionsBuilder.cpp
+++ b/Core/StandardSamples/ParticleDistributionsBuilder.cpp
@@ -13,28 +13,28 @@
 // ************************************************************************** //
 
 #include "ParticleDistributionsBuilder.h"
-#include "MaterialFactoryFuncs.h"
 #include "BornAgainNamespace.h"
 #include "Distributions.h"
+#include "FormFactorBox.h"
+#include "FormFactorCone.h"
 #include "FormFactorCylinder.h"
+#include "FormFactorFullSphere.h"
+#include "FormFactorPyramid.h"
 #include "Layer.h"
+#include "MaterialFactoryFuncs.h"
 #include "MultiLayer.h"
 #include "ParameterPattern.h"
+#include "ParameterSample.h"
 #include "Particle.h"
 #include "ParticleDistribution.h"
 #include "ParticleLayout.h"
 #include "RealParameter.h"
-#include "FormFactorPyramid.h"
-#include "FormFactorFullSphere.h"
-#include "FormFactorCone.h"
 #include "Units.h"
-#include "ParameterSample.h"
-#include "FormFactorBox.h"
 
 CylindersWithSizeDistributionBuilder::CylindersWithSizeDistributionBuilder()
-    : m_height(5*Units::nanometer)
-    , m_radius(5*Units::nanometer)
-{}
+    : m_height(5 * Units::nanometer), m_radius(5 * Units::nanometer)
+{
+}
 
 MultiLayer* CylindersWithSizeDistributionBuilder::buildSample() const
 {
@@ -47,13 +47,13 @@ MultiLayer* CylindersWithSizeDistributionBuilder::buildSample() const
 
     ParticleLayout particle_layout;
     // preparing prototype of nano particle
-    double sigma = 0.2*m_radius;
-    FormFactorCylinder p_ff_cylinder( m_radius, m_height);
+    double sigma = 0.2 * m_radius;
+    FormFactorCylinder p_ff_cylinder(m_radius, m_height);
     Particle nano_particle(particle_material, p_ff_cylinder);
     // radius of nanoparticles will be sampled with gaussian probability
     int n_samples(100);
     // to get radius_min = average - 2.0*FWHM:
-    double n_sigma = 2.0*2.0*std::sqrt(2.0*std::log(2.0));
+    double n_sigma = 2.0 * 2.0 * std::sqrt(2.0 * std::log(2.0));
     DistributionGaussian gauss(m_radius, sigma);
     ParameterPattern pattern;
     pattern.add(BornAgain::ParticleType).add(BornAgain::FFCylinderType).add(BornAgain::Radius);
@@ -74,13 +74,11 @@ MultiLayer* CylindersWithSizeDistributionBuilder::buildSample() const
 // ----------------------------------------------------------------------------
 
 TwoTypesCylindersDistributionBuilder::TwoTypesCylindersDistributionBuilder()
-    : m_radius1(5*Units::nanometer)
-    , m_radius2(10*Units::nanometer)
-    , m_height1(5*Units::nanometer)
-    , m_height2(10*Units::nanometer)
-    , m_sigma1_ratio(0.2)
-    , m_sigma2_ratio(0.02)
-{}
+    : m_radius1(5 * Units::nanometer), m_radius2(10 * Units::nanometer),
+      m_height1(5 * Units::nanometer), m_height2(10 * Units::nanometer), m_sigma1_ratio(0.2),
+      m_sigma2_ratio(0.02)
+{
+}
 
 MultiLayer* TwoTypesCylindersDistributionBuilder::buildSample() const
 {
@@ -95,15 +93,15 @@ MultiLayer* TwoTypesCylindersDistributionBuilder::buildSample() const
 
     // preparing nano particles prototypes for seeding layer's particle_layout
     FormFactorCylinder p_ff_cylinder1(m_radius1, m_height1);
-    Particle cylinder1(particle_material, p_ff_cylinder1 );
+    Particle cylinder1(particle_material, p_ff_cylinder1);
 
     FormFactorCylinder p_ff_cylinder2(m_radius2, m_height2);
-    Particle cylinder2(particle_material, p_ff_cylinder2 );
+    Particle cylinder2(particle_material, p_ff_cylinder2);
 
     // radius of nanoparticles will be sampled with gaussian probability
-    int nbins=150;
-    double sigma1 = m_radius1*m_sigma1_ratio;
-    double sigma2 = m_radius2*m_sigma2_ratio;
+    int nbins = 150;
+    double sigma1 = m_radius1 * m_sigma1_ratio;
+    double sigma2 = m_radius2 * m_sigma2_ratio;
     // to have xmin=average-3*sigma
     double n_sigma = 3.0;
     DistributionGaussian gauss1(m_radius1, sigma1);
@@ -132,11 +130,10 @@ MultiLayer* TwoTypesCylindersDistributionBuilder::buildSample() const
 // ----------------------------------------------------------------------------
 
 RotatedPyramidsDistributionBuilder::RotatedPyramidsDistributionBuilder()
-    : m_length(10*Units::nanometer)
-    , m_height(5*Units::nanometer)
-    , m_alpha(Units::deg2rad(54.73 ))
-    , m_zangle(45.*Units::degree)
-{}
+    : m_length(10 * Units::nanometer), m_height(5 * Units::nanometer),
+      m_alpha(Units::deg2rad(54.73)), m_zangle(45. * Units::degree)
+{
+}
 
 MultiLayer* RotatedPyramidsDistributionBuilder::buildSample() const
 {
@@ -150,7 +147,7 @@ MultiLayer* RotatedPyramidsDistributionBuilder::buildSample() const
     pyramid.setRotation(RotationZ(m_zangle));
 
     // particle collection
-    DistributionGate gate(35.0*Units::deg, 55.0*Units::deg);
+    DistributionGate gate(35.0 * Units::deg, 55.0 * Units::deg);
     ParameterDistribution parameter_distr("/Particle/ZRotation/Angle", gate, 10, 2.0);
 
     ParticleDistribution collection(pyramid, parameter_distr);
@@ -180,11 +177,11 @@ MultiLayer* SpheresWithLimitsDistributionBuilder::buildSample() const
     Material particle_material = HomogeneousMaterial("Particle", 6e-4, 2e-8);
 
     // particle
-    FormFactorFullSphere ff(3.0*Units::nm);
+    FormFactorFullSphere ff(3.0 * Units::nm);
     Particle sphere(particle_material, ff);
 
     // particle collection
-    DistributionGaussian gauss(3.0*Units::nm, 1.0*Units::nm);
+    DistributionGaussian gauss(3.0 * Units::nm, 1.0 * Units::nm);
     ParameterDistribution parameter_distr("/Particle/FullSphere/Radius", gauss, 10, 20.0,
                                           RealLimits::limited(2.0, 4.0));
 
@@ -215,13 +212,14 @@ MultiLayer* ConesWithLimitsDistributionBuilder::buildSample() const
     Material particle_material = HomogeneousMaterial("Particle", 6e-4, 2e-8);
 
     // particle
-    FormFactorCone ff(10.0*Units::nm, 13.0*Units::nm, 60.0*Units::deg);
+    FormFactorCone ff(10.0 * Units::nm, 13.0 * Units::nm, 60.0 * Units::deg);
     Particle cone(particle_material, ff);
 
     // particle collection
-    DistributionGaussian gauss(60.0*Units::deg, 6.0*Units::deg);
-    ParameterDistribution parameter_distr("/Particle/Cone/Alpha", gauss, 5, 20.0,
-                                          RealLimits::limited(55.0*Units::deg, 65.0*Units::deg));
+    DistributionGaussian gauss(60.0 * Units::deg, 6.0 * Units::deg);
+    ParameterDistribution parameter_distr(
+        "/Particle/Cone/Alpha", gauss, 5, 20.0,
+        RealLimits::limited(55.0 * Units::deg, 65.0 * Units::deg));
 
     ParticleDistribution collection(cone, parameter_distr);
 
@@ -248,13 +246,13 @@ MultiLayer* LinkedBoxDistributionBuilder::buildSample() const
     Material particle_material = HomogeneousMaterial("Particle", 6e-4, 2e-8);
 
     // particle
-    FormFactorBox ff(40.0*Units::nm, 30.0*Units::nm, 10.0*Units::nm);
+    FormFactorBox ff(40.0 * Units::nm, 30.0 * Units::nm, 10.0 * Units::nm);
     Particle box(particle_material, ff);
 
     // particle collection
-    DistributionGate gate(10.0*Units::nm, 70.0*Units::nm);
+    DistributionGate gate(10.0 * Units::nm, 70.0 * Units::nm);
     ParameterDistribution parameter_distr("/Particle/Box/Length", gate, 3, 0.0,
-                                          RealLimits::limited(1.0*Units::nm, 200.0*Units::nm));
+                                          RealLimits::limited(1.0 * Units::nm, 200.0 * Units::nm));
     parameter_distr.linkParameter("/Particle/Box/Width").linkParameter("/Particle/Box/Height");
 
     ParticleDistribution collection(box, parameter_distr);
diff --git a/Core/StandardSamples/ParticleDistributionsBuilder.h b/Core/StandardSamples/ParticleDistributionsBuilder.h
index e8b5b4be50e..8bb64314313 100644
--- a/Core/StandardSamples/ParticleDistributionsBuilder.h
+++ b/Core/StandardSamples/ParticleDistributionsBuilder.h
@@ -31,7 +31,6 @@ private:
     double m_radius;
 };
 
-
 //! Builds mixture of cylinder particles with different size distribution (IsGISAXS example #2)
 //! @ingroup standard_samples
 
@@ -72,7 +71,7 @@ private:
 class SpheresWithLimitsDistributionBuilder : public IMultiLayerBuilder
 {
 public:
-    SpheresWithLimitsDistributionBuilder(){}
+    SpheresWithLimitsDistributionBuilder() {}
     MultiLayer* buildSample() const;
 };
 
@@ -82,7 +81,7 @@ public:
 class ConesWithLimitsDistributionBuilder : public IMultiLayerBuilder
 {
 public:
-    ConesWithLimitsDistributionBuilder(){}
+    ConesWithLimitsDistributionBuilder() {}
     MultiLayer* buildSample() const;
 };
 
@@ -96,5 +95,4 @@ public:
     MultiLayer* buildSample() const;
 };
 
-
 #endif // PARTICLEDISTRIBUTIONSBUILDER_H
diff --git a/Core/StandardSamples/ParticleInTheAirBuilder.cpp b/Core/StandardSamples/ParticleInTheAirBuilder.cpp
index 4ffe71338d2..635642a0c85 100644
--- a/Core/StandardSamples/ParticleInTheAirBuilder.cpp
+++ b/Core/StandardSamples/ParticleInTheAirBuilder.cpp
@@ -13,20 +13,21 @@
 // ************************************************************************** //
 
 #include "ParticleInTheAirBuilder.h"
-#include "MaterialFactoryFuncs.h"
 #include "Exceptions.h"
+#include "FormFactors.h"
 #include "Layer.h"
+#include "MaterialFactoryFuncs.h"
 #include "MultiLayer.h"
 #include "Particle.h"
 #include "ParticleLayout.h"
 #include "RealParameter.h"
-#include "FormFactors.h"
 #include "SampleComponents.h"
 #include "Units.h"
 
 ParticleInTheAirBuilder::ParticleInTheAirBuilder()
-    : m_ff(new FormFactorFullSphere(5.0*Units::nanometer))
-{}
+    : m_ff(new FormFactorFullSphere(5.0 * Units::nanometer))
+{
+}
 
 ParticleInTheAirBuilder::~ParticleInTheAirBuilder() = default;
 
@@ -50,7 +51,7 @@ MultiLayer* ParticleInTheAirBuilder::buildSample() const
 
 MultiLayer* ParticleInTheAirBuilder::createSample(size_t index)
 {
-    if(index >= size())
+    if (index >= size())
         throw std::runtime_error("ParticleInTheAirBuilder::createSample() -> Error. "
                                  "Sample index is out of range.");
 
diff --git a/Core/StandardSamples/ParticleInTheAirBuilder.h b/Core/StandardSamples/ParticleInTheAirBuilder.h
index e09789af5b7..decd0904576 100644
--- a/Core/StandardSamples/ParticleInTheAirBuilder.h
+++ b/Core/StandardSamples/ParticleInTheAirBuilder.h
@@ -33,7 +33,7 @@ public:
     virtual ~ParticleInTheAirBuilder();
     virtual MultiLayer* buildSample() const;
 
-    MultiLayer* createSample(size_t index=0);
+    MultiLayer* createSample(size_t index = 0);
     size_t size();
 
 protected:
diff --git a/Core/StandardSamples/PercusYevickBuilder.cpp b/Core/StandardSamples/PercusYevickBuilder.cpp
index 7232c2d013a..73b1c88752a 100644
--- a/Core/StandardSamples/PercusYevickBuilder.cpp
+++ b/Core/StandardSamples/PercusYevickBuilder.cpp
@@ -23,13 +23,12 @@
 #include "Units.h"
 
 HardDiskBuilder::HardDiskBuilder()
-    : m_cylinder_height(5*Units::nanometer)
-    , m_cylinder_radius(5*Units::nanometer)
-    , m_disk_radius(5*Units::nanometer)
-    , m_density(0.006)
-{}
+    : m_cylinder_height(5 * Units::nanometer), m_cylinder_radius(5 * Units::nanometer),
+      m_disk_radius(5 * Units::nanometer), m_density(0.006)
+{
+}
 
-MultiLayer *HardDiskBuilder::buildSample() const
+MultiLayer* HardDiskBuilder::buildSample() const
 {
     MultiLayer* multi_layer = new MultiLayer();
 
diff --git a/Core/StandardSamples/PlainMultiLayerBySLDBuilder.cpp b/Core/StandardSamples/PlainMultiLayerBySLDBuilder.cpp
index 0357b939b4b..9da0a45cfd5 100644
--- a/Core/StandardSamples/PlainMultiLayerBySLDBuilder.cpp
+++ b/Core/StandardSamples/PlainMultiLayerBySLDBuilder.cpp
@@ -13,18 +13,16 @@
 // ************************************************************************** //
 
 #include "PlainMultiLayerBySLDBuilder.h"
-#include "MaterialFactoryFuncs.h"
 #include "Layer.h"
+#include "MaterialFactoryFuncs.h"
 #include "MultiLayer.h"
 #include "Units.h"
 
 PlainMultiLayerBySLDBuilder::PlainMultiLayerBySLDBuilder(int n_layers)
-    : m_number_of_layers(n_layers)
-    , m_si { 2.0704e-06, 2.3726e-11}
-    , m_ti {-1.9493e-06, 9.6013e-10}
-    , m_ni { 9.4245e-06, 1.1423e-09}
-    , m_thick_ti(3.0) // nm
-    , m_thick_ni(7.0) //nm
+    : m_number_of_layers(n_layers), m_si{2.0704e-06, 2.3726e-11}, m_ti{-1.9493e-06, 9.6013e-10},
+      m_ni{9.4245e-06, 1.1423e-09}, m_thick_ti(3.0) // nm
+      ,
+      m_thick_ni(7.0) // nm
 {
     registerParameter("ti_thickness", &m_thick_ti);
 }
diff --git a/Core/StandardSamples/ResonatorBuilder.cpp b/Core/StandardSamples/ResonatorBuilder.cpp
index 63f5ac36cb1..e655301f439 100644
--- a/Core/StandardSamples/ResonatorBuilder.cpp
+++ b/Core/StandardSamples/ResonatorBuilder.cpp
@@ -20,9 +20,7 @@
 #include "Units.h"
 #include <memory>
 
-ResonatorBuilder::ResonatorBuilder()
-    : IMultiLayerBuilder()
-    , m_l_ti(13.0 * Units::nm)
+ResonatorBuilder::ResonatorBuilder() : IMultiLayerBuilder(), m_l_ti(13.0 * Units::nm)
 {
     registerParameter("ti_thickness", &m_l_ti);
 }
diff --git a/Core/StandardSamples/ResonatorBuilder.h b/Core/StandardSamples/ResonatorBuilder.h
index 60918557f04..ea632eeb10d 100644
--- a/Core/StandardSamples/ResonatorBuilder.h
+++ b/Core/StandardSamples/ResonatorBuilder.h
@@ -30,4 +30,4 @@ private:
     double m_l_ti; // titanium layer thickness
 };
 
-#endif  // RESONATORBUILDER_H
+#endif // RESONATORBUILDER_H
diff --git a/Core/StandardSamples/RipplesBuilder.cpp b/Core/StandardSamples/RipplesBuilder.cpp
index 97845cd3d78..d4436f3f086 100644
--- a/Core/StandardSamples/RipplesBuilder.cpp
+++ b/Core/StandardSamples/RipplesBuilder.cpp
@@ -13,20 +13,19 @@
 // ************************************************************************** //
 
 #include "RipplesBuilder.h"
-#include "MaterialFactoryFuncs.h"
 #include "BornAgainNamespace.h"
 #include "FormFactorRipple1.h"
 #include "FormFactorRipple2.h"
 #include "InterferenceFunctionRadialParaCrystal.h"
 #include "Layer.h"
+#include "MaterialFactoryFuncs.h"
 #include "MultiLayer.h"
 #include "Particle.h"
 #include "ParticleLayout.h"
 #include "RealParameter.h"
 #include "Units.h"
 
-CosineRippleBuilder::CosineRippleBuilder()
-{}
+CosineRippleBuilder::CosineRippleBuilder() {}
 
 MultiLayer* CosineRippleBuilder::buildSample() const
 {
@@ -41,7 +40,7 @@ MultiLayer* CosineRippleBuilder::buildSample() const
     Particle ripple(particle_material, ff_ripple1);
 
     ParticleLayout particle_layout;
-    particle_layout.addParticle(ripple,1.0);
+    particle_layout.addParticle(ripple, 1.0);
     InterferenceFunctionRadialParaCrystal interference_function(20.0, 1e7);
     FTDistribution1DGauss pdf(4.0);
     interference_function.setProbabilityDistribution(pdf);
@@ -59,8 +58,7 @@ MultiLayer* CosineRippleBuilder::buildSample() const
 
 // ----------------------------------------------------------------------------
 
-TriangularRippleBuilder::TriangularRippleBuilder()
-    : m_d(0.0*Units::nanometer)
+TriangularRippleBuilder::TriangularRippleBuilder() : m_d(0.0 * Units::nanometer)
 {
     init_parameters();
 }
@@ -75,10 +73,10 @@ MultiLayer* TriangularRippleBuilder::buildSample() const
 
     Layer air_layer(air_material);
     FormFactorRipple2 ff_ripple2(100.0, 20.0, 4.0, m_d);
-    Particle ripple(particle_material, ff_ripple2 );
+    Particle ripple(particle_material, ff_ripple2);
 
     ParticleLayout particle_layout;
-    particle_layout.addParticle(ripple,1.0);
+    particle_layout.addParticle(ripple, 1.0);
     InterferenceFunctionRadialParaCrystal interference_function(20.0, 1e7);
     FTDistribution1DGauss pdf(4.0);
     interference_function.setProbabilityDistribution(pdf);
diff --git a/Core/StandardSamples/RipplesBuilder.h b/Core/StandardSamples/RipplesBuilder.h
index 74bb78a1ba6..d87ff27fd40 100644
--- a/Core/StandardSamples/RipplesBuilder.h
+++ b/Core/StandardSamples/RipplesBuilder.h
@@ -27,7 +27,6 @@ public:
     MultiLayer* buildSample() const;
 };
 
-
 //! Builds sample: triangular ripple within the 1D-paracrystal model (from PRB 85, 235415, 2012).
 //! @ingroup standard_samples
 
diff --git a/Core/StandardSamples/RotatedPyramidsBuilder.cpp b/Core/StandardSamples/RotatedPyramidsBuilder.cpp
index 1f926fb9c0c..ccc75ffc286 100644
--- a/Core/StandardSamples/RotatedPyramidsBuilder.cpp
+++ b/Core/StandardSamples/RotatedPyramidsBuilder.cpp
@@ -13,10 +13,10 @@
 // ************************************************************************** //
 
 #include "RotatedPyramidsBuilder.h"
-#include "MaterialFactoryFuncs.h"
 #include "BornAgainNamespace.h"
 #include "FormFactorPyramid.h"
 #include "Layer.h"
+#include "MaterialFactoryFuncs.h"
 #include "MultiLayer.h"
 #include "Particle.h"
 #include "ParticleLayout.h"
@@ -24,11 +24,10 @@
 #include "Units.h"
 
 RotatedPyramidsBuilder::RotatedPyramidsBuilder()
-    : m_length(10*Units::nanometer)
-    , m_height(5*Units::nanometer)
-    , m_alpha(Units::deg2rad(54.73 ))
-    , m_zangle(45.*Units::degree)
-{}
+    : m_length(10 * Units::nanometer), m_height(5 * Units::nanometer),
+      m_alpha(Units::deg2rad(54.73)), m_zangle(45. * Units::degree)
+{
+}
 
 MultiLayer* RotatedPyramidsBuilder::buildSample() const
 {
@@ -48,7 +47,7 @@ MultiLayer* RotatedPyramidsBuilder::buildSample() const
     RotationZ z_rotation(m_zangle);
 
     ParticleLayout particle_layout;
-    particle_layout.addParticle(pyramid, 1.0, kvector_t(0,0,0), z_rotation);
+    particle_layout.addParticle(pyramid, 1.0, kvector_t(0, 0, 0), z_rotation);
 
     air_layer.addLayout(particle_layout);
 
diff --git a/Core/StandardSamples/SampleBuilderFactory.cpp b/Core/StandardSamples/SampleBuilderFactory.cpp
index 9b96bec24c0..c1e4612c511 100644
--- a/Core/StandardSamples/SampleBuilderFactory.cpp
+++ b/Core/StandardSamples/SampleBuilderFactory.cpp
@@ -26,8 +26,8 @@
 #include "MagneticLayersBuilder.h"
 #include "MagneticParticlesBuilder.h"
 #include "MesoCrystalBuilder.h"
-#include "MultiLayerWithRoughnessBuilder.h"
 #include "MultiLayerWithNCRoughnessBuilder.h"
+#include "MultiLayerWithRoughnessBuilder.h"
 #include "MultipleLayoutBuilder.h"
 #include "ParaCrystalBuilder.h"
 #include "ParticleCompositionBuilder.h"
@@ -155,7 +155,7 @@ SampleBuilderFactory::SampleBuilderFactory()
 
     registerItem("MultiLayerWithNCRoughnessBuilder", create_new<MultiLayerWithNCRoughnessBuilder>,
                  "Layer with correlated roughness");
-    
+
     registerItem("TwoLayerRoughnessBuilder", create_new<TwoLayerRoughnessBuilder>,
                  "Two layers with rough interface");
 
diff --git a/Core/StandardSamples/SampleComponents.cpp b/Core/StandardSamples/SampleComponents.cpp
index fc33aad6029..977bc64b076 100644
--- a/Core/StandardSamples/SampleComponents.cpp
+++ b/Core/StandardSamples/SampleComponents.cpp
@@ -33,68 +33,49 @@ FormFactorComponents::FormFactorComponents()
 // ************************************************************************** //
 {
     add(BornAgain::FFAnisoPyramidType,
-        new FormFactorAnisoPyramid(10.0, 20.0, 5.0, Units::deg2rad(54.73 )));
+        new FormFactorAnisoPyramid(10.0, 20.0, 5.0, Units::deg2rad(54.73)));
 
-    add(BornAgain::FFBoxType,
-        new FormFactorBox(10.0, 20.0, 5.0));
+    add(BornAgain::FFBoxType, new FormFactorBox(10.0, 20.0, 5.0));
 
-    add(BornAgain::FFConeType,
-        new FormFactorCone(5.0, 6.0, Units::deg2rad(54.73 )));
+    add(BornAgain::FFConeType, new FormFactorCone(5.0, 6.0, Units::deg2rad(54.73)));
 
     add(BornAgain::FFCone6Type,
-        new FormFactorCone6(2./sqrt(3.)*5.0, 5.0, Units::deg2rad(54.73)));
+        new FormFactorCone6(2. / sqrt(3.) * 5.0, 5.0, Units::deg2rad(54.73)));
 
     add(BornAgain::FFCuboctahedronType,
-        new FormFactorCuboctahedron(10.0, 5.0, 1.0, Units::deg2rad(54.73 )));
+        new FormFactorCuboctahedron(10.0, 5.0, 1.0, Units::deg2rad(54.73)));
 
-    add(BornAgain::FFCylinderType,
-        new FormFactorCylinder(5.0, 10.0));
+    add(BornAgain::FFCylinderType, new FormFactorCylinder(5.0, 10.0));
 
-    add(BornAgain::FFDodecahedronType,
-        new FormFactorDodecahedron(5.0));
+    add(BornAgain::FFDodecahedronType, new FormFactorDodecahedron(5.0));
 
-    add(BornAgain::FFDotType,
-        new FormFactorDot());
+    add(BornAgain::FFDotType, new FormFactorDot());
 
-    add(BornAgain::FFEllipsoidalCylinderType,
-        new FormFactorEllipsoidalCylinder(5.0, 10.0, 15.0));
+    add(BornAgain::FFEllipsoidalCylinderType, new FormFactorEllipsoidalCylinder(5.0, 10.0, 15.0));
 
-    add(BornAgain::FFFullSphereType,
-        new FormFactorFullSphere(5.0));
+    add(BornAgain::FFFullSphereType, new FormFactorFullSphere(5.0));
 
-    add(BornAgain::FFFullSpheroidType,
-        new FormFactorFullSpheroid(5.0, 10.0));
+    add(BornAgain::FFFullSpheroidType, new FormFactorFullSpheroid(5.0, 10.0));
 
-    add(BornAgain::FFHemiEllipsoidType,
-        new FormFactorHemiEllipsoid(5.0, 10.0, 15.0));
+    add(BornAgain::FFHemiEllipsoidType, new FormFactorHemiEllipsoid(5.0, 10.0, 15.0));
 
-    add(BornAgain::FFIcosahedronType,
-        new FormFactorIcosahedron(10.0));
+    add(BornAgain::FFIcosahedronType, new FormFactorIcosahedron(10.0));
 
-    add(BornAgain::FFPrism3Type,
-        new FormFactorPrism3(10.0, 5.0));
+    add(BornAgain::FFPrism3Type, new FormFactorPrism3(10.0, 5.0));
 
-    add(BornAgain::FFPrism6Type,
-        new FormFactorPrism6(2./sqrt(3.)*5.0, 5.0));
+    add(BornAgain::FFPrism6Type, new FormFactorPrism6(2. / sqrt(3.) * 5.0, 5.0));
 
-    add(BornAgain::FFPyramidType,
-        new FormFactorPyramid(10.0, 5.0, Units::deg2rad(54.73 )));
+    add(BornAgain::FFPyramidType, new FormFactorPyramid(10.0, 5.0, Units::deg2rad(54.73)));
 
-    add(BornAgain::FFRipple1Type,
-        new FormFactorRipple1(100.0, 20.0, 4.0));
+    add(BornAgain::FFRipple1Type, new FormFactorRipple1(100.0, 20.0, 4.0));
 
-    add(BornAgain::FFRipple2Type,
-        new FormFactorRipple2(100.0, 20.0, 4.0, 0.0));
+    add(BornAgain::FFRipple2Type, new FormFactorRipple2(100.0, 20.0, 4.0, 0.0));
 
-    add(BornAgain::FFTetrahedronType,
-        new FormFactorTetrahedron(10.0, 4.0, Units::deg2rad(54.73 )));
+    add(BornAgain::FFTetrahedronType, new FormFactorTetrahedron(10.0, 4.0, Units::deg2rad(54.73)));
 
-    add(BornAgain::FFTruncatedCubeType,
-        new FormFactorTruncatedCube(15.0, 6.0));
+    add(BornAgain::FFTruncatedCubeType, new FormFactorTruncatedCube(15.0, 6.0));
 
-    add(BornAgain::FFTruncatedSphereType,
-        new FormFactorTruncatedSphere(5.0, 7.0));
+    add(BornAgain::FFTruncatedSphereType, new FormFactorTruncatedSphere(5.0, 7.0));
 
-    add(BornAgain::FFTruncatedSpheroidType,
-        new FormFactorTruncatedSpheroid(5.0, 7.0, 1.0));
+    add(BornAgain::FFTruncatedSpheroidType, new FormFactorTruncatedSpheroid(5.0, 7.0, 1.0));
 }
diff --git a/Core/StandardSamples/SampleComponents.h b/Core/StandardSamples/SampleComponents.h
index dcbb19a77f7..eafb02d5f3c 100644
--- a/Core/StandardSamples/SampleComponents.h
+++ b/Core/StandardSamples/SampleComponents.h
@@ -15,8 +15,8 @@
 #ifndef SAMPLECOMPONENTS_H
 #define SAMPLECOMPONENTS_H
 
-#include "IRegistry.h"
 #include "FTDistributions2D.h"
+#include "IRegistry.h"
 
 //! @class FTDistribution2DComponents
 //! @brief Predefined Fourier transformed distributions for functional tests.
diff --git a/Core/StandardSamples/SimulationFactory.cpp b/Core/StandardSamples/SimulationFactory.cpp
index d239ea60357..698fc2118ef 100644
--- a/Core/StandardSamples/SimulationFactory.cpp
+++ b/Core/StandardSamples/SimulationFactory.cpp
@@ -15,95 +15,75 @@
 #include "SimulationFactory.h"
 #include "DepthProbeSimulation.h"
 #include "GISASSimulation.h"
-#include "SpecularSimulation.h"
+#include "OffSpecSimulation.h"
 #include "RealParameter.h"
+#include "SpecularSimulation.h"
 #include "StandardSimulations.h"
-#include "OffSpecSimulation.h"
 
 SimulationFactory::SimulationFactory()
 {
-    registerItem("BasicGISAS",
-                 StandardSimulations::BasicGISAS,
+    registerItem("BasicGISAS", StandardSimulations::BasicGISAS,
                  "Basic GISAS simulation with the detector phi[0,2], theta[0,2]");
 
-    registerItem("BasicGISAS00",
-                 StandardSimulations::BasicGISAS00,
+    registerItem("BasicGISAS00", StandardSimulations::BasicGISAS00,
                  "Basic GISAS for polarization studies");
 
-    registerItem("BasicPolarizedGISAS",
-                 StandardSimulations::BasicPolarizedGISAS,
+    registerItem("BasicPolarizedGISAS", StandardSimulations::BasicPolarizedGISAS,
                  "Basic GISAS for spin flip channel");
 
-    registerItem("MiniGISAS",
-                 StandardSimulations::MiniGISAS,
+    registerItem("MiniGISAS", StandardSimulations::MiniGISAS,
                  "GISAS simulation with small 25x25 detector and phi[-2,2], theta[0,2]");
 
-    registerItem("MiniGISAS_v2",
-                 StandardSimulations::MiniGISAS_v2,
+    registerItem("MiniGISAS_v2", StandardSimulations::MiniGISAS_v2,
                  "GISAS simulation with small 25x25 detector and phi[-1,1], theta[0,]");
 
-    registerItem("MiniGISASBeamDivergence",
-                 StandardSimulations::MiniGISASBeamDivergence,
+    registerItem("MiniGISASBeamDivergence", StandardSimulations::MiniGISASBeamDivergence,
                  "GISAS simulation with small detector and beam divergence");
 
-    registerItem("MiniGISASDetectorResolution",
-                 StandardSimulations::MiniGISASDetectorResolution,
+    registerItem("MiniGISASDetectorResolution", StandardSimulations::MiniGISASDetectorResolution,
                  "GISAS simulation with small detector and detector resolution");
 
-    registerItem("MiniGISASSpecular",
-                 StandardSimulations::MiniGISASSpecularPeak,
+    registerItem("MiniGISASSpecular", StandardSimulations::MiniGISASSpecularPeak,
                  "GISAS simulation including specular peak");
 
-    registerItem("GISASWithMasks",
-                 StandardSimulations::GISASWithMasks,
+    registerItem("GISASWithMasks", StandardSimulations::GISASWithMasks,
                  "GISAS simulation with small detector and various masks");
 
-    registerItem("MaxiGISAS",
-                 StandardSimulations::MaxiGISAS,
+    registerItem("MaxiGISAS", StandardSimulations::MaxiGISAS,
                  "GISAS simulation with large detector to test performance");
 
-    registerItem("MaxiGISAS00",
-                 StandardSimulations::MaxiGISAS00,
+    registerItem("MaxiGISAS00", StandardSimulations::MaxiGISAS00,
                  "GISAS simulation with large detector to test performance");
 
-    registerItem("IsGISAXSSimulation1",
-                 StandardSimulations::IsGISAXSSimulation1,
+    registerItem("IsGISAXSSimulation1", StandardSimulations::IsGISAXSSimulation1,
                  "Typical IsGISAXS simulation with the detector theta[-1,1], phi[0,2]");
 
-    registerItem("IsGISAXSSimulation2",
-                 StandardSimulations::IsGISAXSSimulation2,
+    registerItem("IsGISAXSSimulation2", StandardSimulations::IsGISAXSSimulation2,
                  "Typical IsGISAXS simulation with the detector theta[0,1], phi[0,2]");
 
     // polarization
 
-    registerItem("MiniGISASPolarizationPP",
-                 StandardSimulations::MiniGISASPolarizationPP,
+    registerItem("MiniGISASPolarizationPP", StandardSimulations::MiniGISASPolarizationPP,
                  "GISAS simulation measuring plus-plus polarization");
 
-    registerItem("MiniGISASPolarizationPM",
-                 StandardSimulations::MiniGISASPolarizationPM,
+    registerItem("MiniGISASPolarizationPM", StandardSimulations::MiniGISASPolarizationPM,
                  "GISAS simulation measuring spin flip (+-) channel");
 
-    registerItem("MiniGISASPolarizationMP",
-                 StandardSimulations::MiniGISASPolarizationMP,
+    registerItem("MiniGISASPolarizationMP", StandardSimulations::MiniGISASPolarizationMP,
                  "GISAS simulation measuring spin flip (-+) channel");
 
-    registerItem("MiniGISASPolarizationMM",
-                 StandardSimulations::MiniGISASPolarizationMM,
+    registerItem("MiniGISASPolarizationMM", StandardSimulations::MiniGISASPolarizationMM,
                  "GISAS simulation measuring minus-minus polarization");
 
     // rectangular detectors
 
-    registerItem("RectDetectorGeneric",
-                 StandardSimulations::RectDetectorGeneric,
+    registerItem("RectDetectorGeneric", StandardSimulations::RectDetectorGeneric,
                  "Rectangular detector with generic alignment");
 
-    registerItem("RectDetectorPerpToSample",
-                 StandardSimulations::RectDetectorPerpToSample,
+    registerItem("RectDetectorPerpToSample", StandardSimulations::RectDetectorPerpToSample,
                  "Rectangular detector with generic alignment");
 
-    registerItem("RectDetectorPerpToDirectBeam",
-                 StandardSimulations::RectDetectorPerpToDirectBeam,
+    registerItem("RectDetectorPerpToDirectBeam", StandardSimulations::RectDetectorPerpToDirectBeam,
                  "Rectangular detector with generic alignment");
 
     registerItem("RectDetectorPerpToReflectedBeam",
@@ -114,35 +94,29 @@ SimulationFactory::SimulationFactory()
                  StandardSimulations::RectDetectorPerpToReflectedBeamDpos,
                  "Rectangular detector with generic alignment");
 
-    registerItem("ExtraLongWavelengthGISAS",
-                 StandardSimulations::ExtraLongWavelengthGISAS,
+    registerItem("ExtraLongWavelengthGISAS", StandardSimulations::ExtraLongWavelengthGISAS,
                  "GISAS with rectangular detector and extra long wavelentgh");
 
     // Monte-Carlo
-    registerItem("MiniGISASMonteCarlo",
-                 StandardSimulations::MiniGISASMonteCarlo,
+    registerItem("MiniGISASMonteCarlo", StandardSimulations::MiniGISASMonteCarlo,
                  "GISAS simulation with small 25x25 detector and phi[-2,2], theta[0,2], "
                  "in Monte-Carlo mode");
 
     // region of interest
 
-    registerItem("SphericalDetWithRoi",
-                 StandardSimulations::SphericalDetWithRoi,
+    registerItem("SphericalDetWithRoi", StandardSimulations::SphericalDetWithRoi,
                  "Spherical detector with ROI and mask");
-    registerItem("RectDetWithRoi",
-                 StandardSimulations::RectDetWithRoi,
+    registerItem("RectDetWithRoi", StandardSimulations::RectDetWithRoi,
                  "Rectangular detector with ROI and mask");
 
     // background
 
-    registerItem("ConstantBackground",
-                 StandardSimulations::ConstantBackgroundGISAS,
+    registerItem("ConstantBackground", StandardSimulations::ConstantBackgroundGISAS,
                  "Simulation with a constant background value");
 
     // specular simulations
 
-    registerItem("BasicSpecular",
-                 StandardSimulations::BasicSpecular,
+    registerItem("BasicSpecular", StandardSimulations::BasicSpecular,
                  "Basic specular simulation with [0, 5] deg incident angle range and "
                  "1.54 angstroms wavelength.");
 
@@ -186,12 +160,10 @@ SimulationFactory::SimulationFactory()
 
     // depth probe simulations
 
-    registerItem("BasicDepthProbe",
-                 StandardSimulations::BasicDepthProbe,
+    registerItem("BasicDepthProbe", StandardSimulations::BasicDepthProbe,
                  "Basic 20x20 depth probe simulation with [0, 1] deg angle and [-100, 100] z span");
 
-    registerItem("MiniGISASFit",
-                 StandardSimulations::MiniGISASFit,
+    registerItem("MiniGISASFit", StandardSimulations::MiniGISASFit,
                  "GISAS simulation with small 25x25 detector and phi[-2,2], theta[0,2]. "
                  "Beam intensity is set");
 }
diff --git a/Core/StandardSamples/SimulationFactory.h b/Core/StandardSamples/SimulationFactory.h
index 0a7cdf3db2a..e289c14c2a7 100644
--- a/Core/StandardSamples/SimulationFactory.h
+++ b/Core/StandardSamples/SimulationFactory.h
@@ -15,8 +15,8 @@
 #ifndef SIMULATIONFACTORY_H
 #define SIMULATIONFACTORY_H
 
-#include "IFactory.h"
 #include "GISASSimulation.h"
+#include "IFactory.h"
 #include <string>
 
 //! Registry to create standard pre-defined simulations.
diff --git a/Core/StandardSamples/SizeDistributionModelsBuilder.cpp b/Core/StandardSamples/SizeDistributionModelsBuilder.cpp
index 72045a04cd4..8491318e85b 100644
--- a/Core/StandardSamples/SizeDistributionModelsBuilder.cpp
+++ b/Core/StandardSamples/SizeDistributionModelsBuilder.cpp
@@ -13,12 +13,12 @@
 // ************************************************************************** //
 
 #include "SizeDistributionModelsBuilder.h"
-#include "MaterialFactoryFuncs.h"
 #include "BornAgainNamespace.h"
 #include "Distributions.h"
 #include "FormFactorCylinder.h"
 #include "InterferenceFunctionRadialParaCrystal.h"
 #include "Layer.h"
+#include "MaterialFactoryFuncs.h"
 #include "MultiLayer.h"
 #include "ParameterPattern.h"
 #include "Particle.h"
@@ -29,43 +29,43 @@
 
 MultiLayer* SizeDistributionDAModelBuilder::buildSample() const
 {
-        MultiLayer* multi_layer = new MultiLayer();
-
-        Material m_ambience = HomogeneousMaterial("Air", 0.0, 0.0);
-        Material m_substrate = HomogeneousMaterial("Substrate", 6e-6, 2e-8);
-        Material m_particle = HomogeneousMaterial("Particle", 6e-4, 2e-8);
-
-        // cylindrical particle 1
-        double radius1(5*Units::nanometer);
-        double height1 = radius1;
-        FormFactorCylinder cylinder_ff1(radius1, height1);
-        Particle cylinder1(m_particle, cylinder_ff1);
-
-        // cylindrical particle 2
-        double radius2(8*Units::nanometer);
-        double height2(radius2);
-        FormFactorCylinder cylinder_ff2(radius2, height2);
-        Particle cylinder2(m_particle, cylinder_ff2);
-
-        // interference function
-        InterferenceFunctionRadialParaCrystal interference(
-            18.0 * Units::nanometer, 1e3 * Units::nanometer);
-        FTDistribution1DGauss pdf(3*Units::nanometer);
-        interference.setProbabilityDistribution(pdf);
-
-        // assembling the sample
-        ParticleLayout particle_layout;
-        particle_layout.addParticle(cylinder1, 0.8);
-        particle_layout.addParticle(cylinder2, 0.2);
-        particle_layout.setInterferenceFunction(interference);
-
-        Layer air_layer(m_ambience);
-        air_layer.addLayout(particle_layout);
-        Layer substrate_layer(m_substrate);
-
-        multi_layer->addLayer(air_layer);
-        multi_layer->addLayer(substrate_layer);
-        return multi_layer;
+    MultiLayer* multi_layer = new MultiLayer();
+
+    Material m_ambience = HomogeneousMaterial("Air", 0.0, 0.0);
+    Material m_substrate = HomogeneousMaterial("Substrate", 6e-6, 2e-8);
+    Material m_particle = HomogeneousMaterial("Particle", 6e-4, 2e-8);
+
+    // cylindrical particle 1
+    double radius1(5 * Units::nanometer);
+    double height1 = radius1;
+    FormFactorCylinder cylinder_ff1(radius1, height1);
+    Particle cylinder1(m_particle, cylinder_ff1);
+
+    // cylindrical particle 2
+    double radius2(8 * Units::nanometer);
+    double height2(radius2);
+    FormFactorCylinder cylinder_ff2(radius2, height2);
+    Particle cylinder2(m_particle, cylinder_ff2);
+
+    // interference function
+    InterferenceFunctionRadialParaCrystal interference(18.0 * Units::nanometer,
+                                                       1e3 * Units::nanometer);
+    FTDistribution1DGauss pdf(3 * Units::nanometer);
+    interference.setProbabilityDistribution(pdf);
+
+    // assembling the sample
+    ParticleLayout particle_layout;
+    particle_layout.addParticle(cylinder1, 0.8);
+    particle_layout.addParticle(cylinder2, 0.2);
+    particle_layout.setInterferenceFunction(interference);
+
+    Layer air_layer(m_ambience);
+    air_layer.addLayout(particle_layout);
+    Layer substrate_layer(m_substrate);
+
+    multi_layer->addLayer(air_layer);
+    multi_layer->addLayer(substrate_layer);
+    return multi_layer;
 }
 
 // ----------------------------------------------------------------------------
@@ -79,26 +79,26 @@ MultiLayer* SizeDistributionLMAModelBuilder::buildSample() const
     Material m_particle = HomogeneousMaterial("Particle", 6e-4, 2e-8);
 
     // cylindrical particle 1
-    double radius1(5*Units::nanometer);
+    double radius1(5 * Units::nanometer);
     double height1 = radius1;
     FormFactorCylinder cylinder_ff1(radius1, height1);
     Particle cylinder1(m_particle, cylinder_ff1);
 
     // cylindrical particle 2
-    double radius2(8*Units::nanometer);
+    double radius2(8 * Units::nanometer);
     double height2(radius2);
     FormFactorCylinder cylinder_ff2(radius2, height2);
     Particle cylinder2(m_particle, cylinder_ff2);
 
     // interference function1
-    InterferenceFunctionRadialParaCrystal interference1(
-        16.8*Units::nanometer, 1e3*Units::nanometer);
+    InterferenceFunctionRadialParaCrystal interference1(16.8 * Units::nanometer,
+                                                        1e3 * Units::nanometer);
     FTDistribution1DGauss pdf(3 * Units::nanometer);
     interference1.setProbabilityDistribution(pdf);
 
     // interference function2
-    InterferenceFunctionRadialParaCrystal interference2(
-        22.8*Units::nanometer, 1e3*Units::nanometer);
+    InterferenceFunctionRadialParaCrystal interference2(22.8 * Units::nanometer,
+                                                        1e3 * Units::nanometer);
     interference2.setProbabilityDistribution(pdf);
 
     // assembling the sample
@@ -125,28 +125,28 @@ MultiLayer* SizeDistributionLMAModelBuilder::buildSample() const
 
 MultiLayer* SizeDistributionSSCAModelBuilder::buildSample() const
 {
-    MultiLayer *multi_layer = new MultiLayer();
+    MultiLayer* multi_layer = new MultiLayer();
 
     Material m_ambience = HomogeneousMaterial("Air", 0.0, 0.0);
     Material m_substrate = HomogeneousMaterial("Substrate", 6e-6, 2e-8);
     Material m_particle = HomogeneousMaterial("Particle", 6e-4, 2e-8);
 
     // cylindrical particle 1
-    double radius1(5*Units::nanometer);
+    double radius1(5 * Units::nanometer);
     double height1 = radius1;
     FormFactorCylinder cylinder_ff1(radius1, height1);
     Particle cylinder1(m_particle, cylinder_ff1);
 
     // cylindrical particle 2
-    double radius2(8*Units::nanometer);
+    double radius2(8 * Units::nanometer);
     double height2(radius2);
     FormFactorCylinder cylinder_ff2(radius2, height2);
     Particle cylinder2(m_particle, cylinder_ff2);
 
     // interference function
-    InterferenceFunctionRadialParaCrystal interference(
-        18.0*Units::nanometer, 1e3*Units::nanometer);
-    FTDistribution1DGauss pdf(3*Units::nanometer);
+    InterferenceFunctionRadialParaCrystal interference(18.0 * Units::nanometer,
+                                                       1e3 * Units::nanometer);
+    FTDistribution1DGauss pdf(3 * Units::nanometer);
     interference.setProbabilityDistribution(pdf);
     interference.setKappa(1.0);
 
@@ -177,24 +177,26 @@ MultiLayer* CylindersInSSCABuilder::buildSample() const
 
     Layer air_layer(air_material);
 
-    InterferenceFunctionRadialParaCrystal interference_function(
-        15.0 * Units::nanometer, 1e3 * Units::nanometer);
-    FTDistribution1DGauss pdf(5*Units::nanometer);
+    InterferenceFunctionRadialParaCrystal interference_function(15.0 * Units::nanometer,
+                                                                1e3 * Units::nanometer);
+    FTDistribution1DGauss pdf(5 * Units::nanometer);
     interference_function.setProbabilityDistribution(pdf);
     interference_function.setKappa(4.02698);
     ParticleLayout particle_layout;
 
-    FormFactorCylinder ff_cylinder(5.0*Units::nanometer, 5.0*Units::nanometer);
+    FormFactorCylinder ff_cylinder(5.0 * Units::nanometer, 5.0 * Units::nanometer);
     Particle particle_prototype(particle_material, ff_cylinder);
 
-    DistributionGaussian gauss(5.0*Units::nanometer, 1.25*Units::nanometer);
+    DistributionGaussian gauss(5.0 * Units::nanometer, 1.25 * Units::nanometer);
     ParameterPattern pattern_radius;
-    pattern_radius.
-        add(BornAgain::ParticleType).add(BornAgain::FFCylinderType).add(BornAgain::Radius);
+    pattern_radius.add(BornAgain::ParticleType)
+        .add(BornAgain::FFCylinderType)
+        .add(BornAgain::Radius);
     ParameterDistribution par_distr(pattern_radius.toStdString(), gauss, 30, 3.0);
     ParameterPattern pattern_height;
-    pattern_height.
-        add(BornAgain::ParticleType).add(BornAgain::FFCylinderType).add(BornAgain::Height);
+    pattern_height.add(BornAgain::ParticleType)
+        .add(BornAgain::FFCylinderType)
+        .add(BornAgain::Height);
     par_distr.linkParameter(pattern_height.toStdString());
     ParticleDistribution particle_collection(particle_prototype, par_distr);
     particle_layout.addParticle(particle_collection);
diff --git a/Core/StandardSamples/SizeDistributionModelsBuilder.h b/Core/StandardSamples/SizeDistributionModelsBuilder.h
index 938f99c91d9..04b8acd3247 100644
--- a/Core/StandardSamples/SizeDistributionModelsBuilder.h
+++ b/Core/StandardSamples/SizeDistributionModelsBuilder.h
@@ -24,7 +24,7 @@
 class BA_CORE_API_ SizeDistributionDAModelBuilder : public IMultiLayerBuilder
 {
 public:
-    SizeDistributionDAModelBuilder(){}
+    SizeDistributionDAModelBuilder() {}
     MultiLayer* buildSample() const;
 };
 
@@ -35,7 +35,7 @@ public:
 class BA_CORE_API_ SizeDistributionLMAModelBuilder : public IMultiLayerBuilder
 {
 public:
-    SizeDistributionLMAModelBuilder(){}
+    SizeDistributionLMAModelBuilder() {}
     MultiLayer* buildSample() const;
 };
 
@@ -46,7 +46,7 @@ public:
 class BA_CORE_API_ SizeDistributionSSCAModelBuilder : public IMultiLayerBuilder
 {
 public:
-    SizeDistributionSSCAModelBuilder(){}
+    SizeDistributionSSCAModelBuilder() {}
     MultiLayer* buildSample() const;
 };
 
@@ -56,7 +56,7 @@ public:
 class BA_CORE_API_ CylindersInSSCABuilder : public IMultiLayerBuilder
 {
 public:
-    CylindersInSSCABuilder(){}
+    CylindersInSSCABuilder() {}
     MultiLayer* buildSample() const;
 };
 
diff --git a/Core/StandardSamples/SlicedCylindersBuilder.cpp b/Core/StandardSamples/SlicedCylindersBuilder.cpp
index abf0de665a3..59d1b67ce50 100644
--- a/Core/StandardSamples/SlicedCylindersBuilder.cpp
+++ b/Core/StandardSamples/SlicedCylindersBuilder.cpp
@@ -22,19 +22,20 @@
 #include "ParticleLayout.h"
 #include "Units.h"
 
-namespace {
+namespace
+{
 //! Returns SLD input (in inverse square Angstroms) for MaterialBySLD from _delta_ and _beta_,
 //! i.e. the input for HomogeneousMaterial.
 complex_t getSLDFromN(double wavelength, double delta, double beta);
 complex_t averageSLD(complex_t sld_p, complex_t sld_l, double eff_vol);
-}
+} // namespace
 
 SlicedCylindersBuilder::SlicedCylindersBuilder()
-    : m_height(5*Units::nanometer)
-    , m_radius(5*Units::nanometer)
-    , m_wavelength(0.154) // nm
-    , m_n_slices(3)
-{}
+    : m_height(5 * Units::nanometer), m_radius(5 * Units::nanometer), m_wavelength(0.154) // nm
+      ,
+      m_n_slices(3)
+{
+}
 
 MultiLayer* SlicedCylindersBuilder::buildSample() const
 {
@@ -61,9 +62,7 @@ MultiLayer* SlicedCylindersBuilder::buildSample() const
     return multi_layer;
 }
 
-SLDSlicedCylindersBuilder::SLDSlicedCylindersBuilder()
-    : SlicedCylindersBuilder()
-{}
+SLDSlicedCylindersBuilder::SLDSlicedCylindersBuilder() : SlicedCylindersBuilder() {}
 
 MultiLayer* SLDSlicedCylindersBuilder::buildSample() const
 {
@@ -93,9 +92,9 @@ MultiLayer* SLDSlicedCylindersBuilder::buildSample() const
 }
 
 AveragedSlicedCylindersBuilder::AveragedSlicedCylindersBuilder()
-    : SlicedCylindersBuilder()
-    , m_par_surf_density(ParticleLayout().totalParticleSurfaceDensity())
-{}
+    : SlicedCylindersBuilder(), m_par_surf_density(ParticleLayout().totalParticleSurfaceDensity())
+{
+}
 
 MultiLayer* AveragedSlicedCylindersBuilder::buildSample() const
 {
@@ -123,10 +122,11 @@ MultiLayer* AveragedSlicedCylindersBuilder::buildSample() const
     return multi_layer;
 }
 
-namespace {
+namespace
+{
 complex_t getSLDFromN(double wavelength, double delta, double beta)
 {
-    complex_t result {2 * delta - delta * delta + beta * beta, 2 * beta - 2 * delta * beta};
+    complex_t result{2 * delta - delta * delta + beta * beta, 2 * beta - 2 * delta * beta};
     return result * M_PI / (wavelength * wavelength) * (Units::angstrom * Units::angstrom);
 }
 
@@ -134,4 +134,4 @@ complex_t averageSLD(complex_t sld_p, complex_t sld_l, double eff_vol)
 {
     return sld_l + eff_vol * (sld_p - sld_l);
 }
-}
+} // namespace
diff --git a/Core/StandardSamples/SlicedParticleBuilder.cpp b/Core/StandardSamples/SlicedParticleBuilder.cpp
index e12dd884234..c8912b6df61 100644
--- a/Core/StandardSamples/SlicedParticleBuilder.cpp
+++ b/Core/StandardSamples/SlicedParticleBuilder.cpp
@@ -13,13 +13,13 @@
 // ************************************************************************** //
 
 #include "SlicedParticleBuilder.h"
-#include "MaterialFactoryFuncs.h"
-#include "MultiLayer.h"
-#include "Layer.h"
 #include "FormFactorFullSphere.h"
 #include "FormFactorTruncatedSphere.h"
-#include "ParticleComposition.h"
+#include "Layer.h"
+#include "MaterialFactoryFuncs.h"
+#include "MultiLayer.h"
 #include "Particle.h"
+#include "ParticleComposition.h"
 #include "ParticleLayout.h"
 #include "Transform3D.h"
 #include "Units.h"
@@ -37,9 +37,11 @@ MultiLayer* SlicedCompositionBuilder::buildSample() const
     const double bottom_cup_height = 4.0;
     const double composition_shift = bottom_cup_height;
 
-    Particle topCup(topCupMaterial, FormFactorTruncatedSphere(sphere_radius, sphere_radius*2 - bottom_cup_height));
-    Particle bottomCup(bottomCupMaterial, FormFactorTruncatedSphere(sphere_radius, bottom_cup_height));
-    bottomCup.setRotation(RotationX(180*Units::deg));
+    Particle topCup(topCupMaterial, FormFactorTruncatedSphere(
+                                        sphere_radius, sphere_radius * 2 - bottom_cup_height));
+    Particle bottomCup(bottomCupMaterial,
+                       FormFactorTruncatedSphere(sphere_radius, bottom_cup_height));
+    bottomCup.setRotation(RotationX(180 * Units::deg));
 
     ParticleComposition composition;
     composition.addParticle(topCup, kvector_t(0.0, 0.0, bottom_cup_height));
@@ -58,5 +60,4 @@ MultiLayer* SlicedCompositionBuilder::buildSample() const
     p_multi_layer->addLayer(substrate_layer);
 
     return p_multi_layer;
-
 }
diff --git a/Core/StandardSamples/SlicedParticleBuilder.h b/Core/StandardSamples/SlicedParticleBuilder.h
index 4d38c6aef5f..9b603c91cf2 100644
--- a/Core/StandardSamples/SlicedParticleBuilder.h
+++ b/Core/StandardSamples/SlicedParticleBuilder.h
@@ -23,7 +23,7 @@
 class BA_CORE_API_ SlicedCompositionBuilder : public IMultiLayerBuilder
 {
 public:
-    SlicedCompositionBuilder(){}
+    SlicedCompositionBuilder() {}
     MultiLayer* buildSample() const;
 };
 
diff --git a/Core/StandardSamples/StandardSimulations.cpp b/Core/StandardSamples/StandardSimulations.cpp
index 2deef005190..515f652eb33 100644
--- a/Core/StandardSamples/StandardSimulations.cpp
+++ b/Core/StandardSamples/StandardSimulations.cpp
@@ -25,6 +25,7 @@
 #include "GISASSimulation.h"
 #include "IsGISAXSDetector.h"
 #include "Line.h"
+#include "OffSpecSimulation.h"
 #include "ParameterPattern.h"
 #include "Polygon.h"
 #include "QSpecScan.h"
@@ -36,23 +37,23 @@
 #include "SampleBuilderFactory.h"
 #include "ScanResolution.h"
 #include "SpecularSimulation.h"
-#include "OffSpecSimulation.h"
 #include "Units.h"
 #include <memory>
 
-namespace {
-    const size_t rdet_nbinsx(40), rdet_nbinsy(30);
-    const double rdet_width(20.0), rdet_height(18.0), rdet_distance(1000.0);
-}
+namespace
+{
+const size_t rdet_nbinsx(40), rdet_nbinsy(30);
+const double rdet_width(20.0), rdet_height(18.0), rdet_distance(1000.0);
+} // namespace
 
 //! Basic GISAS simulation with the detector phi[0,2], theta[0,2].
 
 GISASSimulation* StandardSimulations::BasicGISAS()
 {
     GISASSimulation* result = new GISASSimulation();
-    result->setDetectorParameters(100, 0.0*Units::degree, 2.0*Units::degree,
-                                  100, 0.0*Units::degree, 2.0*Units::degree);
-    result->setBeamParameters(1.0*Units::angstrom, 0.2*Units::degree, 0.0*Units::degree);
+    result->setDetectorParameters(100, 0.0 * Units::degree, 2.0 * Units::degree, 100,
+                                  0.0 * Units::degree, 2.0 * Units::degree);
+    result->setBeamParameters(1.0 * Units::angstrom, 0.2 * Units::degree, 0.0 * Units::degree);
     return result;
 }
 
@@ -69,7 +70,7 @@ GISASSimulation* StandardSimulations::BasicGISAS00()
 
 //! Basic GISAS simulation for spin flip channel.
 
-GISASSimulation*StandardSimulations::BasicPolarizedGISAS()
+GISASSimulation* StandardSimulations::BasicPolarizedGISAS()
 {
     GISASSimulation* result = BasicGISAS();
     kvector_t zplus(0.0, 0.0, 1.0);
@@ -83,9 +84,9 @@ GISASSimulation*StandardSimulations::BasicPolarizedGISAS()
 GISASSimulation* StandardSimulations::MiniGISAS()
 {
     GISASSimulation* 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);
+    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);
     return result;
 }
 
@@ -94,9 +95,9 @@ GISASSimulation* StandardSimulations::MiniGISAS()
 GISASSimulation* StandardSimulations::MiniGISAS_v2()
 {
     GISASSimulation* result = new GISASSimulation();
-    result->setDetectorParameters(25, -1.0*Units::degree, 1.0*Units::degree,
-                                  25, 0.0*Units::degree, 1.0*Units::degree);
-    result->setBeamParameters(1.0*Units::angstrom, 0.2*Units::degree, 0.0*Units::degree);
+    result->setDetectorParameters(25, -1.0 * Units::degree, 1.0 * Units::degree, 25,
+                                  0.0 * Units::degree, 1.0 * Units::degree);
+    result->setBeamParameters(1.0 * Units::angstrom, 0.2 * Units::degree, 0.0 * Units::degree);
     return result;
 }
 
@@ -106,9 +107,9 @@ GISASSimulation* StandardSimulations::MiniGISASBeamDivergence()
 {
     GISASSimulation* result = MiniGISAS();
 
-    DistributionLogNormal wavelength_distr(1.0*Units::angstrom, 0.1);
-    DistributionGaussian alpha_distr(0.2*Units::degree, 0.1*Units::degree);
-    DistributionGate phi_distr(-0.1*Units::degree, 0.1*Units::degree);
+    DistributionLogNormal wavelength_distr(1.0 * Units::angstrom, 0.1);
+    DistributionGaussian alpha_distr(0.2 * Units::degree, 0.1 * Units::degree);
+    DistributionGate phi_distr(-0.1 * Units::degree, 0.1 * Units::degree);
 
     ParameterPattern pattern1;
     pattern1.beginsWith("*").add(BornAgain::BeamType).add(BornAgain::Wavelength);
@@ -128,30 +129,31 @@ GISASSimulation* StandardSimulations::MiniGISASBeamDivergence()
 GISASSimulation* StandardSimulations::GISASWithMasks()
 {
     GISASSimulation* result = new GISASSimulation();
-    result->setDetectorParameters(50, -1.0*Units::degree, 1.0*Units::degree,
-                                     50, 0.0*Units::degree, 2.0*Units::degree);
-    result->setBeamParameters(1.0*Units::angstrom, 0.2*Units::degree, 0.0*Units::degree);
+    result->setDetectorParameters(50, -1.0 * Units::degree, 1.0 * Units::degree, 50,
+                                  0.0 * Units::degree, 2.0 * Units::degree);
+    result->setBeamParameters(1.0 * Units::angstrom, 0.2 * Units::degree, 0.0 * Units::degree);
     result->setBeamIntensity(1e+7);
 
     result->maskAll();
     // pacman
     const double deg = Units::degree;
-    result->addMask(Ellipse(0.0*deg, 1.0*deg, 0.5*deg, 0.5*deg), false);
-    result->addMask(Ellipse(0.11*deg, 1.25*deg, 0.05*deg, 0.05*deg), true);
+    result->addMask(Ellipse(0.0 * deg, 1.0 * deg, 0.5 * deg, 0.5 * deg), false);
+    result->addMask(Ellipse(0.11 * deg, 1.25 * deg, 0.05 * deg, 0.05 * deg), true);
 
-    std::vector<std::vector<double> >  points = {
-        {0.0*deg, 1.0*deg}, {0.5*deg, 1.2*deg}, {0.5*deg, 0.8*deg}, {0.0*deg, 1.0*deg}
-    };
+    std::vector<std::vector<double>> points = {{0.0 * deg, 1.0 * deg},
+                                               {0.5 * deg, 1.2 * deg},
+                                               {0.5 * deg, 0.8 * deg},
+                                               {0.0 * deg, 1.0 * deg}};
     result->addMask(Polygon(points), true);
 
-    result->addMask(Rectangle(0.45*deg, 0.95*deg, 0.55*deg, 1.05*deg), false);
-    result->addMask(Rectangle(0.61*deg, 0.95*deg, 0.71*deg, 1.05*deg), false);
-    result->addMask(Rectangle(0.75*deg, 0.95*deg, 0.85*deg, 1.05*deg), false);
+    result->addMask(Rectangle(0.45 * deg, 0.95 * deg, 0.55 * deg, 1.05 * deg), false);
+    result->addMask(Rectangle(0.61 * deg, 0.95 * deg, 0.71 * deg, 1.05 * deg), false);
+    result->addMask(Rectangle(0.75 * deg, 0.95 * deg, 0.85 * deg, 1.05 * deg), false);
 
     // more masks
-    result->addMask(Ellipse(-0.5*deg, 1.5*deg, 0.3*deg, 0.1*deg, 45.*deg), false);
-    result->addMask(VerticalLine(-0.6*deg), true);
-    result->addMask(HorizontalLine(0.3*deg), false);
+    result->addMask(Ellipse(-0.5 * deg, 1.5 * deg, 0.3 * deg, 0.1 * deg, 45. * deg), false);
+    result->addMask(VerticalLine(-0.6 * deg), true);
+    result->addMask(HorizontalLine(0.3 * deg), false);
 
     return result;
 }
@@ -166,7 +168,7 @@ GISASSimulation* StandardSimulations::MiniGISASDetectorResolution()
     return result;
 }
 
-GISASSimulation*StandardSimulations::MiniGISASPolarizationPP()
+GISASSimulation* StandardSimulations::MiniGISASPolarizationPP()
 {
     GISASSimulation* result = MiniGISAS();
 
@@ -178,7 +180,7 @@ GISASSimulation*StandardSimulations::MiniGISASPolarizationPP()
     return result;
 }
 
-GISASSimulation*StandardSimulations::MiniGISASPolarizationPM()
+GISASSimulation* StandardSimulations::MiniGISASPolarizationPM()
 {
     GISASSimulation* result = MiniGISAS();
 
@@ -190,7 +192,7 @@ GISASSimulation*StandardSimulations::MiniGISASPolarizationPM()
     return result;
 }
 
-GISASSimulation*StandardSimulations::MiniGISASPolarizationMP()
+GISASSimulation* StandardSimulations::MiniGISASPolarizationMP()
 {
     GISASSimulation* result = MiniGISAS();
 
@@ -202,7 +204,7 @@ GISASSimulation*StandardSimulations::MiniGISASPolarizationMP()
     return result;
 }
 
-GISASSimulation*StandardSimulations::MiniGISASPolarizationMM()
+GISASSimulation* StandardSimulations::MiniGISASPolarizationMM()
 {
     GISASSimulation* result = MiniGISAS();
 
@@ -219,9 +221,9 @@ GISASSimulation*StandardSimulations::MiniGISASPolarizationMM()
 GISASSimulation* StandardSimulations::MiniGISASSpecularPeak()
 {
     GISASSimulation* 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);
+    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);
     result->getOptions().setIncludeSpecular(true);
     return result;
 }
@@ -231,9 +233,9 @@ GISASSimulation* StandardSimulations::MiniGISASSpecularPeak()
 GISASSimulation* StandardSimulations::MaxiGISAS()
 {
     GISASSimulation* result = new GISASSimulation();
-    result->setDetectorParameters(256, -2.0*Units::degree, 2.0*Units::degree,
-                                  256, 0.0*Units::degree, 2.0*Units::degree);
-    result->setBeamParameters(1.0*Units::angstrom, 0.2*Units::degree, 0.0*Units::degree);
+    result->setDetectorParameters(256, -2.0 * Units::degree, 2.0 * Units::degree, 256,
+                                  0.0 * Units::degree, 2.0 * Units::degree);
+    result->setBeamParameters(1.0 * Units::angstrom, 0.2 * Units::degree, 0.0 * Units::degree);
     return result;
 }
 
@@ -254,10 +256,10 @@ GISASSimulation* StandardSimulations::IsGISAXSSimulation1()
 {
     GISASSimulation* result = new GISASSimulation();
     IsGISAXSDetector detector;
-    detector.setDetectorParameters(100,-1.0*Units::degree, 1.0*Units::degree,
-                                   100, 0.0*Units::degree, 2.0*Units::degree);
+    detector.setDetectorParameters(100, -1.0 * Units::degree, 1.0 * Units::degree, 100,
+                                   0.0 * Units::degree, 2.0 * Units::degree);
     result->setDetector(detector);
-    result->setBeamParameters(1.0*Units::angstrom, 0.2*Units::degree, 0.0*Units::degree);
+    result->setBeamParameters(1.0 * Units::angstrom, 0.2 * Units::degree, 0.0 * Units::degree);
     return result;
 }
 
@@ -267,10 +269,10 @@ GISASSimulation* StandardSimulations::IsGISAXSSimulation2()
 {
     GISASSimulation* result = new GISASSimulation();
     IsGISAXSDetector detector;
-    detector.setDetectorParameters(100, 0.0*Units::degree, 2.0*Units::degree,
-                                   100, 0.0*Units::degree, 2.0*Units::degree);
+    detector.setDetectorParameters(100, 0.0 * Units::degree, 2.0 * Units::degree, 100,
+                                   0.0 * Units::degree, 2.0 * Units::degree);
     result->setDetector(detector);
-    result->setBeamParameters(1.0*Units::angstrom, 0.2*Units::degree, 0.0*Units::degree);
+    result->setBeamParameters(1.0 * Units::angstrom, 0.2 * Units::degree, 0.0 * Units::degree);
     return result;
 }
 
@@ -279,11 +281,11 @@ GISASSimulation* StandardSimulations::IsGISAXSSimulation2()
 GISASSimulation* StandardSimulations::RectDetectorGeneric()
 {
     GISASSimulation* result = new GISASSimulation();
-    result->setBeamParameters(1.0*Units::angstrom, 0.2*Units::degree, 0.0*Units::degree);
+    result->setBeamParameters(1.0 * Units::angstrom, 0.2 * Units::degree, 0.0 * Units::degree);
 
     RectangularDetector detector(rdet_nbinsx, rdet_width, rdet_nbinsy, rdet_height);
-    detector.setPosition(kvector_t(rdet_distance, 10.0, 5.0), rdet_width/2.,
-                         1.0, kvector_t(0.1, -1.0, 0.2));
+    detector.setPosition(kvector_t(rdet_distance, 10.0, 5.0), rdet_width / 2., 1.0,
+                         kvector_t(0.1, -1.0, 0.2));
 
     result->setDetector(detector);
     return result;
@@ -294,10 +296,10 @@ GISASSimulation* StandardSimulations::RectDetectorGeneric()
 GISASSimulation* StandardSimulations::RectDetectorPerpToSample()
 {
     GISASSimulation* result = new GISASSimulation();
-    result->setBeamParameters(1.0*Units::angstrom, 0.2*Units::degree, 0.0*Units::degree);
+    result->setBeamParameters(1.0 * Units::angstrom, 0.2 * Units::degree, 0.0 * Units::degree);
 
     RectangularDetector detector(rdet_nbinsx, rdet_width, rdet_nbinsy, rdet_height);
-    detector.setPerpendicularToSampleX(rdet_distance, rdet_width/2., 1.0);
+    detector.setPerpendicularToSampleX(rdet_distance, rdet_width / 2., 1.0);
 
     result->setDetector(detector);
     return result;
@@ -308,10 +310,10 @@ GISASSimulation* StandardSimulations::RectDetectorPerpToSample()
 GISASSimulation* StandardSimulations::RectDetectorPerpToDirectBeam()
 {
     GISASSimulation* result = new GISASSimulation();
-    result->setBeamParameters(1.0*Units::angstrom, 0.2*Units::degree, 0.0*Units::degree);
+    result->setBeamParameters(1.0 * Units::angstrom, 0.2 * Units::degree, 0.0 * Units::degree);
 
     RectangularDetector detector(rdet_nbinsx, rdet_width, rdet_nbinsy, rdet_height);
-    detector.setPerpendicularToDirectBeam(rdet_distance, rdet_width/2., 1.0);
+    detector.setPerpendicularToDirectBeam(rdet_distance, rdet_width / 2., 1.0);
 
     result->setDetector(detector);
     return result;
@@ -322,10 +324,10 @@ GISASSimulation* StandardSimulations::RectDetectorPerpToDirectBeam()
 GISASSimulation* StandardSimulations::RectDetectorPerpToReflectedBeam()
 {
     GISASSimulation* result = new GISASSimulation();
-    result->setBeamParameters(1.0*Units::angstrom, 0.2*Units::degree, 0.0*Units::degree);
+    result->setBeamParameters(1.0 * Units::angstrom, 0.2 * Units::degree, 0.0 * Units::degree);
 
     RectangularDetector detector(rdet_nbinsx, rdet_width, rdet_nbinsy, rdet_height);
-    detector.setPerpendicularToReflectedBeam(rdet_distance, rdet_width/2., 1.0);
+    detector.setPerpendicularToReflectedBeam(rdet_distance, rdet_width / 2., 1.0);
 
     result->setDetector(detector);
     return result;
@@ -337,11 +339,11 @@ GISASSimulation* StandardSimulations::RectDetectorPerpToReflectedBeam()
 GISASSimulation* StandardSimulations::RectDetectorPerpToReflectedBeamDpos()
 {
     GISASSimulation* result = new GISASSimulation();
-    result->setBeamParameters(1.0*Units::angstrom, 0.2*Units::degree, 0.0*Units::degree);
+    result->setBeamParameters(1.0 * Units::angstrom, 0.2 * Units::degree, 0.0 * Units::degree);
 
     RectangularDetector detector(rdet_nbinsx, rdet_width, rdet_nbinsy, rdet_height);
     detector.setPerpendicularToReflectedBeam(rdet_distance);
-    detector.setDirectBeamPosition(rdet_width/2., 1.0);
+    detector.setDirectBeamPosition(rdet_width / 2., 1.0);
 
     result->setDetector(detector);
     return result;
@@ -358,18 +360,17 @@ GISASSimulation* StandardSimulations::MiniGISASMonteCarlo()
 
 //! GISAS simulation with spherical detector, region of interest and mask.
 
-GISASSimulation *StandardSimulations::SphericalDetWithRoi() {
-  GISASSimulation *result = new GISASSimulation();
-  result->setDetectorParameters(40, -2.0 * Units::degree, 2.0 * Units::degree,
-                                30, 0.0 * Units::degree, 3.0 * Units::degree);
-  result->setBeamParameters(1.0 * Units::angstrom, 0.2 * Units::degree,
-                            0.0 * Units::degree);
-  result->addMask(Rectangle(-0.5 * Units::degree, 0.3 * Units::degree,
-                                      -0.2 * Units::degree,
-                                      0.6 * Units::degree));
-  result->setRegionOfInterest(-1.5 * Units::degree, 0.25 * Units::degree,
-                              1.5 * Units::degree, 1.75 * Units::degree);
-  return result;
+GISASSimulation* StandardSimulations::SphericalDetWithRoi()
+{
+    GISASSimulation* result = new GISASSimulation();
+    result->setDetectorParameters(40, -2.0 * Units::degree, 2.0 * Units::degree, 30,
+                                  0.0 * Units::degree, 3.0 * Units::degree);
+    result->setBeamParameters(1.0 * Units::angstrom, 0.2 * Units::degree, 0.0 * Units::degree);
+    result->addMask(Rectangle(-0.5 * Units::degree, 0.3 * Units::degree, -0.2 * Units::degree,
+                              0.6 * Units::degree));
+    result->setRegionOfInterest(-1.5 * Units::degree, 0.25 * Units::degree, 1.5 * Units::degree,
+                                1.75 * Units::degree);
+    return result;
 }
 
 //! GISAS simulation with rectangular detector, region of interest and mask.
@@ -499,7 +500,7 @@ SpecularSimulation* StandardSimulations::SpecularDivergentBeam()
     return result.release();
 }
 
-SpecularSimulation *StandardSimulations::TOFRWithRelativeResolution()
+SpecularSimulation* StandardSimulations::TOFRWithRelativeResolution()
 {
     FixedBinAxis qs("axis", 500, 0.0, 1.0);
     QSpecScan q_scan(qs);
@@ -511,7 +512,7 @@ SpecularSimulation *StandardSimulations::TOFRWithRelativeResolution()
     return result.release();
 }
 
-SpecularSimulation *StandardSimulations::TOFRWithPointwiseResolution()
+SpecularSimulation* StandardSimulations::TOFRWithPointwiseResolution()
 {
     FixedBinAxis qs("axis", 500, 0.0, 1.0);
     QSpecScan q_scan(qs);
@@ -570,11 +571,11 @@ OffSpecSimulation* StandardSimulations::MiniOffSpec()
     std::unique_ptr<OffSpecSimulation> result(new OffSpecSimulation());
 
     const int n_alpha(19);
-    const double alpha_min(0.0*Units::deg);
-    const double alpha_max(4.0*Units::deg);
+    const double alpha_min(0.0 * Units::deg);
+    const double alpha_max(4.0 * Units::deg);
     const int n_phi(9);
-    const double phi_min(-0.1*Units::deg);
-    const double phi_max(0.1*Units::deg);
+    const double phi_min(-0.1 * Units::deg);
+    const double phi_max(0.1 * Units::deg);
 
     result->setDetectorParameters(n_phi, phi_min, phi_max, n_alpha, alpha_min, alpha_max);
 
@@ -583,7 +584,7 @@ OffSpecSimulation* StandardSimulations::MiniOffSpec()
     const double alpha_i_max(alpha_max);
 
     FixedBinAxis alpha_i_axis("alpha_i", n_scan_points, alpha_i_min, alpha_i_max);
-    result->setBeamParameters(5.0*Units::angstrom, alpha_i_axis, 0.0);
+    result->setBeamParameters(5.0 * Units::angstrom, alpha_i_axis, 0.0);
 
     result->setBeamIntensity(1e9);
     result->getOptions().setIncludeSpecular(true);
@@ -614,9 +615,9 @@ DepthProbeSimulation* StandardSimulations::BasicDepthProbe()
 GISASSimulation* StandardSimulations::MiniGISASFit()
 {
     GISASSimulation* 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);
+    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);
     result->setBeamIntensity(1e6);
     return result;
 }
diff --git a/Core/StandardSamples/StandardSimulations.h b/Core/StandardSamples/StandardSimulations.h
index 0ab4a4fa764..43bfacc62d3 100644
--- a/Core/StandardSamples/StandardSimulations.h
+++ b/Core/StandardSamples/StandardSimulations.h
@@ -24,7 +24,8 @@ class OffSpecSimulation;
 
 //! Standard pre-defined simulations.
 
-namespace StandardSimulations {
+namespace StandardSimulations
+{
 
 // CoreSuite tests:
 BA_CORE_API_ GISASSimulation* BasicGISAS();
diff --git a/Core/StandardSamples/ThickAbsorptiveSampleBuilder.cpp b/Core/StandardSamples/ThickAbsorptiveSampleBuilder.cpp
index 05057613d43..126a6b0b7fd 100644
--- a/Core/StandardSamples/ThickAbsorptiveSampleBuilder.cpp
+++ b/Core/StandardSamples/ThickAbsorptiveSampleBuilder.cpp
@@ -19,9 +19,7 @@
 #include "MultiLayer.h"
 #include "Units.h"
 
-ThickAbsorptiveSampleBuilder::ThickAbsorptiveSampleBuilder()
-    : IMultiLayerBuilder ()
-{}
+ThickAbsorptiveSampleBuilder::ThickAbsorptiveSampleBuilder() : IMultiLayerBuilder() {}
 
 MultiLayer* ThickAbsorptiveSampleBuilder::buildSample() const
 {
diff --git a/Core/StandardSamples/TransformationsBuilder.cpp b/Core/StandardSamples/TransformationsBuilder.cpp
index 78e9a436a99..e5246a079df 100644
--- a/Core/StandardSamples/TransformationsBuilder.cpp
+++ b/Core/StandardSamples/TransformationsBuilder.cpp
@@ -13,9 +13,9 @@
 // ************************************************************************** //
 
 #include "TransformationsBuilder.h"
-#include "MaterialFactoryFuncs.h"
 #include "FormFactorBox.h"
 #include "Layer.h"
+#include "MaterialFactoryFuncs.h"
 #include "MultiLayer.h"
 #include "Particle.h"
 #include "ParticleLayout.h"
@@ -36,9 +36,9 @@ MultiLayer* TransformBoxBuilder::buildSample() const
     double height(10);
 
     Particle box(mParticle, FormFactorBox(length, width, height));
-    box.setRotation(RotationZ(90.*Units::degree));
-    box.rotate(RotationY(90.*Units::degree));
-    box.setPosition(kvector_t(0, 0, -layer_thickness/2.));
+    box.setRotation(RotationZ(90. * Units::degree));
+    box.rotate(RotationY(90. * Units::degree));
+    box.setPosition(kvector_t(0, 0, -layer_thickness / 2.));
 
     ParticleLayout layout;
     layout.addParticle(box);
diff --git a/Core/StandardSamples/TransformationsBuilder.h b/Core/StandardSamples/TransformationsBuilder.h
index 122b1a2ae2c..815c30f753d 100644
--- a/Core/StandardSamples/TransformationsBuilder.h
+++ b/Core/StandardSamples/TransformationsBuilder.h
@@ -23,7 +23,7 @@
 class BA_CORE_API_ TransformBoxBuilder : public IMultiLayerBuilder
 {
 public:
-    TransformBoxBuilder(){}
+    TransformBoxBuilder() {}
     MultiLayer* buildSample() const;
 };
 
diff --git a/Core/StandardSamples/TwoDimLatticeBuilder.cpp b/Core/StandardSamples/TwoDimLatticeBuilder.cpp
index b6152e33c31..7ef7b7d79bd 100644
--- a/Core/StandardSamples/TwoDimLatticeBuilder.cpp
+++ b/Core/StandardSamples/TwoDimLatticeBuilder.cpp
@@ -13,12 +13,12 @@
 // ************************************************************************** //
 
 #include "TwoDimLatticeBuilder.h"
-#include "MaterialFactoryFuncs.h"
 #include "FormFactorCylinder.h"
 #include "InterferenceFunction2DLattice.h"
 #include "InterferenceFunction2DSuperLattice.h"
 #include "InterferenceFunctionFinite2DLattice.h"
 #include "Layer.h"
+#include "MaterialFactoryFuncs.h"
 #include "MultiLayer.h"
 #include "Particle.h"
 #include "ParticleComposition.h"
@@ -26,7 +26,7 @@
 #include "RealParameter.h"
 #include "Units.h"
 
-MultiLayer *Basic2DLatticeBuilder::buildSample() const
+MultiLayer* Basic2DLatticeBuilder::buildSample() const
 {
     MultiLayer* multi_layer = new MultiLayer();
 
@@ -38,16 +38,16 @@ MultiLayer *Basic2DLatticeBuilder::buildSample() const
     Layer substrate_layer(substrate_material);
 
     std::unique_ptr<InterferenceFunction2DLattice> P_interference_function(
-                new InterferenceFunction2DLattice(5.0*Units::nanometer, 10.0*Units::nanometer,
-                                                  30.0*Units::deg, 10.0*Units::deg));
+        new InterferenceFunction2DLattice(5.0 * Units::nanometer, 10.0 * Units::nanometer,
+                                          30.0 * Units::deg, 10.0 * Units::deg));
 
-    FTDecayFunction2DCauchy pdf(300.0*Units::nanometer/2.0/M_PI,
-                                100.0*Units::nanometer/2.0/M_PI);
+    FTDecayFunction2DCauchy pdf(300.0 * Units::nanometer / 2.0 / M_PI,
+                                100.0 * Units::nanometer / 2.0 / M_PI);
     P_interference_function->setDecayFunction(pdf);
 
     // particles
     ParticleLayout particle_layout;
-    FormFactorCylinder ff_cyl(5.0*Units::nanometer, 5.0*Units::nanometer);
+    FormFactorCylinder ff_cyl(5.0 * Units::nanometer, 5.0 * Units::nanometer);
     Particle particle(particle_material, ff_cyl);
     particle_layout.addParticle(particle, 1.0);
 
@@ -61,7 +61,6 @@ MultiLayer *Basic2DLatticeBuilder::buildSample() const
     return multi_layer;
 }
 
-
 // -----------------------------------------------------------------------------
 // lattice #1:
 // -----------------------------------------------------------------------------
@@ -77,14 +76,14 @@ MultiLayer* SquareLatticeBuilder::buildSample() const
     Layer substrate_layer(substrate_material);
 
     std::unique_ptr<InterferenceFunction2DLattice> P_interference_function{
-        InterferenceFunction2DLattice::createSquare(10.0 * Units::nanometer) };
-    FTDecayFunction2DCauchy pdf(300.0*Units::nanometer/2.0/M_PI,
-                                100.0*Units::nanometer/2.0/M_PI);
+        InterferenceFunction2DLattice::createSquare(10.0 * Units::nanometer)};
+    FTDecayFunction2DCauchy pdf(300.0 * Units::nanometer / 2.0 / M_PI,
+                                100.0 * Units::nanometer / 2.0 / M_PI);
     P_interference_function->setDecayFunction(pdf);
 
     // particles
     ParticleLayout particle_layout;
-    FormFactorCylinder ff_cyl(5.0*Units::nanometer, 5.0*Units::nanometer);
+    FormFactorCylinder ff_cyl(5.0 * Units::nanometer, 5.0 * Units::nanometer);
     Particle particle(particle_material, ff_cyl);
     particle_layout.addParticle(particle, 1.0);
 
@@ -98,7 +97,6 @@ MultiLayer* SquareLatticeBuilder::buildSample() const
     return multi_layer;
 }
 
-
 // -----------------------------------------------------------------------------
 // lattice #2: centered
 // -----------------------------------------------------------------------------
@@ -113,17 +111,17 @@ MultiLayer* CenteredSquareLatticeBuilder::buildSample() const
     Layer air_layer(air_material);
     Layer substrate_layer(substrate_material);
 
-    InterferenceFunction2DLattice interference_function(10.0*Units::nanometer,
-            10.0*Units::nanometer, M_PI/2.0);
-    FTDecayFunction2DCauchy pdf(300.0*Units::nanometer/2.0/M_PI,
-                                100.0*Units::nanometer/2.0/M_PI);
+    InterferenceFunction2DLattice interference_function(10.0 * Units::nanometer,
+                                                        10.0 * Units::nanometer, M_PI / 2.0);
+    FTDecayFunction2DCauchy pdf(300.0 * Units::nanometer / 2.0 / M_PI,
+                                100.0 * Units::nanometer / 2.0 / M_PI);
     interference_function.setDecayFunction(pdf);
 
-    FormFactorCylinder ff_cyl(5.0*Units::nanometer, 5.0*Units::nanometer);
+    FormFactorCylinder ff_cyl(5.0 * Units::nanometer, 5.0 * Units::nanometer);
     Particle cylinder(particle_material, ff_cyl);
-    std::vector<kvector_t > positions;
+    std::vector<kvector_t> positions;
     kvector_t position_1(0.0, 0.0, 0.0);
-    kvector_t position_2(5.0*Units::nanometer, -5.0*Units::nanometer, 0.0);
+    kvector_t position_2(5.0 * Units::nanometer, -5.0 * Units::nanometer, 0.0);
     positions.push_back(position_1);
     positions.push_back(position_2);
     ParticleComposition basis;
@@ -140,7 +138,6 @@ MultiLayer* CenteredSquareLatticeBuilder::buildSample() const
     return multi_layer;
 }
 
-
 // -----------------------------------------------------------------------------
 // lattice #3: rotated
 // -----------------------------------------------------------------------------
@@ -157,14 +154,14 @@ MultiLayer* RotatedSquareLatticeBuilder::buildSample() const
 
     std::unique_ptr<InterferenceFunction2DLattice> P_interference_function{
         InterferenceFunction2DLattice::createSquare(10.0 * Units::nanometer, 30.0 * Units::degree)};
-    FTDecayFunction2DCauchy pdf(300.0*Units::nanometer/2.0/M_PI,
-                               100.0*Units::nanometer/2.0/M_PI);
-    pdf.setGamma(30.0*Units::degree);
+    FTDecayFunction2DCauchy pdf(300.0 * Units::nanometer / 2.0 / M_PI,
+                                100.0 * Units::nanometer / 2.0 / M_PI);
+    pdf.setGamma(30.0 * Units::degree);
     P_interference_function->setDecayFunction(pdf);
 
     ParticleLayout particle_layout;
     // particle
-    FormFactorCylinder ff_cyl(5.0*Units::nanometer, 5.0*Units::nanometer);
+    FormFactorCylinder ff_cyl(5.0 * Units::nanometer, 5.0 * Units::nanometer);
     kvector_t position(0.0, 0.0, 0.0);
     Particle p(particle_material, ff_cyl);
     p.setPosition(position);
@@ -194,13 +191,12 @@ MultiLayer* FiniteSquareLatticeBuilder::buildSample() const
     Layer substrate_layer(substrate_material);
 
     std::unique_ptr<InterferenceFunctionFinite2DLattice> P_interference_function{
-        InterferenceFunctionFinite2DLattice::createSquare(10.0*Units::nanometer, 0.0,
-                                                          40, 40) };
+        InterferenceFunctionFinite2DLattice::createSquare(10.0 * Units::nanometer, 0.0, 40, 40)};
     P_interference_function->setPositionVariance(1.0);
 
     // particles
     ParticleLayout particle_layout;
-    FormFactorCylinder ff_cyl(5.0*Units::nanometer, 5.0*Units::nanometer);
+    FormFactorCylinder ff_cyl(5.0 * Units::nanometer, 5.0 * Units::nanometer);
     Particle particle(particle_material, ff_cyl);
     particle_layout.addParticle(particle, 1.0);
 
@@ -228,22 +224,20 @@ MultiLayer* SuperLatticeBuilder::buildSample() const
     Layer substrate_layer(substrate_material);
 
     std::unique_ptr<InterferenceFunction2DSuperLattice> P_interference_function{
-        InterferenceFunction2DSuperLattice::createSquare(200.0*Units::nanometer, 0.0,
-                                                         40, 40) };
+        InterferenceFunction2DSuperLattice::createSquare(200.0 * Units::nanometer, 0.0, 40, 40)};
     std::unique_ptr<InterferenceFunctionFinite2DLattice> P_substructure{
-        InterferenceFunctionFinite2DLattice::createSquare(10.0*Units::nanometer, 0.0,
-                                                          10, 10) };
+        InterferenceFunctionFinite2DLattice::createSquare(10.0 * Units::nanometer, 0.0, 10, 10)};
     P_interference_function->setSubstructureIFF(*P_substructure);
     P_interference_function->setPositionVariance(1.0);
 
     // particles
     ParticleLayout particle_layout;
-    FormFactorCylinder ff_cyl(5.0*Units::nanometer, 10.0*Units::nanometer);
+    FormFactorCylinder ff_cyl(5.0 * Units::nanometer, 10.0 * Units::nanometer);
     Particle particle(air_material, ff_cyl);
-    particle_layout.addParticle(particle, 1.0, kvector_t(0.0, 0.0, -10.0*Units::nanometer));
+    particle_layout.addParticle(particle, 1.0, kvector_t(0.0, 0.0, -10.0 * Units::nanometer));
 
     particle_layout.setInterferenceFunction(*P_interference_function);
-    particle_layout.setTotalParticleSurfaceDensity(100.0/4e4);
+    particle_layout.setTotalParticleSurfaceDensity(100.0 / 4e4);
 
     substrate_layer.addLayout(particle_layout);
 
diff --git a/Core/StandardSamples/TwoDimLatticeBuilder.h b/Core/StandardSamples/TwoDimLatticeBuilder.h
index 0bc92b8f52b..406e4558077 100644
--- a/Core/StandardSamples/TwoDimLatticeBuilder.h
+++ b/Core/StandardSamples/TwoDimLatticeBuilder.h
@@ -23,40 +23,37 @@
 class BA_CORE_API_ Basic2DLatticeBuilder : public IMultiLayerBuilder
 {
 public:
-    Basic2DLatticeBuilder(){}
+    Basic2DLatticeBuilder() {}
     MultiLayer* buildSample() const;
 };
 
-
 //! Builds sample: 2D lattice with different disorder (IsGISAXS example #6).
 //! @ingroup standard_samples
 
 class BA_CORE_API_ SquareLatticeBuilder : public IMultiLayerBuilder
 {
 public:
-    SquareLatticeBuilder(){}
+    SquareLatticeBuilder() {}
     MultiLayer* buildSample() const;
 };
 
-
 //! Builds sample: 2D lattice with different disorder (IsGISAXS example #6).
 //! @ingroup standard_samples
 
 class BA_CORE_API_ CenteredSquareLatticeBuilder : public IMultiLayerBuilder
 {
 public:
-    CenteredSquareLatticeBuilder(){}
+    CenteredSquareLatticeBuilder() {}
     MultiLayer* buildSample() const;
 };
 
-
 //! Builds sample: 2D lattice with different disorder (IsGISAXS example #6).
 //! @ingroup standard_samples
 
 class BA_CORE_API_ RotatedSquareLatticeBuilder : public IMultiLayerBuilder
 {
 public:
-    RotatedSquareLatticeBuilder(){}
+    RotatedSquareLatticeBuilder() {}
     MultiLayer* buildSample() const;
 };
 
@@ -66,7 +63,7 @@ public:
 class BA_CORE_API_ FiniteSquareLatticeBuilder : public IMultiLayerBuilder
 {
 public:
-    FiniteSquareLatticeBuilder(){}
+    FiniteSquareLatticeBuilder() {}
     MultiLayer* buildSample() const;
 };
 
@@ -76,7 +73,7 @@ public:
 class BA_CORE_API_ SuperLatticeBuilder : public IMultiLayerBuilder
 {
 public:
-    SuperLatticeBuilder(){}
+    SuperLatticeBuilder() {}
     MultiLayer* buildSample() const;
 };
 
diff --git a/Core/StandardSamples/TwoLayerRoughnessBuilder.cpp b/Core/StandardSamples/TwoLayerRoughnessBuilder.cpp
index c5d15f94ccd..8293abe6643 100644
--- a/Core/StandardSamples/TwoLayerRoughnessBuilder.cpp
+++ b/Core/StandardSamples/TwoLayerRoughnessBuilder.cpp
@@ -13,19 +13,18 @@
 // ************************************************************************** //
 
 #include "TwoLayerRoughnessBuilder.h"
-#include "MaterialFactoryFuncs.h"
+#include "BornAgainNamespace.h"
 #include "Layer.h"
 #include "LayerRoughness.h"
+#include "MaterialFactoryFuncs.h"
 #include "MultiLayer.h"
 #include "RealParameter.h"
 #include "Units.h"
-#include "BornAgainNamespace.h"
 
 TwoLayerRoughnessBuilder::TwoLayerRoughnessBuilder()
-    : m_sigma(1.0*Units::nanometer)
-    , m_hurst(0.3)
-    , m_lateralCorrLength(5.0*Units::nanometer)
-{}
+    : m_sigma(1.0 * Units::nanometer), m_hurst(0.3), m_lateralCorrLength(5.0 * Units::nanometer)
+{
+}
 
 MultiLayer* TwoLayerRoughnessBuilder::buildSample() const
 {
diff --git a/Core/Tools/FileSystemUtils.cpp b/Core/Tools/FileSystemUtils.cpp
index b160580d8e3..6c164478eaa 100644
--- a/Core/Tools/FileSystemUtils.cpp
+++ b/Core/Tools/FileSystemUtils.cpp
@@ -15,11 +15,11 @@
 #include "FileSystemUtils.h"
 #include "Exceptions.h"
 #include <boost/filesystem.hpp>
-#include <regex>
 #include <cassert>
-#include <stdexcept>
 #include <codecvt>
 #include <locale>
+#include <regex>
+#include <stdexcept>
 
 std::string FileSystemUtils::extension(const std::string& path)
 {
@@ -29,8 +29,8 @@ std::string FileSystemUtils::extension(const std::string& path)
 std::string FileSystemUtils::extensions(const std::string& path)
 {
     auto name = FileSystemUtils::filename(path);
-    auto npos =name.find_first_of('.');
-    return npos != std::string::npos ? name.substr(npos, name.size()-npos) : std::string();
+    auto npos = name.find_first_of('.');
+    return npos != std::string::npos ? name.substr(npos, name.size() - npos) : std::string();
 }
 
 bool FileSystemUtils::createDirectory(const std::string& dir_name)
@@ -102,11 +102,10 @@ std::string FileSystemUtils::stem(const std::string& path)
 std::string FileSystemUtils::stem_ext(const std::string& path)
 {
     auto name = FileSystemUtils::filename(path);
-    auto npos =name.find_first_of('.');
+    auto npos = name.find_first_of('.');
     return npos != std::string::npos ? name.substr(0, npos) : std::string();
 }
 
-
 std::wstring FileSystemUtils::convert_utf8_to_utf16(const std::string& str)
 {
     std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
diff --git a/Core/Tools/FileSystemUtils.h b/Core/Tools/FileSystemUtils.h
index ba238e4c599..f79cb1ce938 100644
--- a/Core/Tools/FileSystemUtils.h
+++ b/Core/Tools/FileSystemUtils.h
@@ -21,7 +21,8 @@
 
 //! Utility functions to deal with file system.
 
-namespace FileSystemUtils {
+namespace FileSystemUtils
+{
 
 //! Returns extension of given filename.
 //! "/home/user/filename.int" -> ".int", "/home/user/filename.int.gz" -> ".gz"
diff --git a/Core/Tools/IntegratorComplex.h b/Core/Tools/IntegratorComplex.h
index 553a0037d78..ce5b605769d 100644
--- a/Core/Tools/IntegratorComplex.h
+++ b/Core/Tools/IntegratorComplex.h
@@ -17,11 +17,8 @@
 
 #include "IntegratorReal.h"
 
-
 //! Alias template for member function with signature complex_t f(double)
-template <class T>
-using complex_integrand = complex_t (T::*)(double) const;
-
+template <class T> using complex_integrand = complex_t (T::*)(double) const;
 
 //! Template class to integrate complex class member functions.
 //!
@@ -37,7 +34,7 @@ template <class T> class IntegratorComplex
 {
 public:
     //! to integrate p_member_function, which must belong to p_object
-    IntegratorComplex(const T *p_object, complex_integrand<T> p_member_function);
+    IntegratorComplex(const T* p_object, complex_integrand<T> p_member_function);
     ~IntegratorComplex() {}
 
     //! perform the actual integration over the range [lmin, lmax]
@@ -46,23 +43,20 @@ public:
 private:
     double real(double value) const;
     double imag(double value) const;
-    const T *mp_object_pointer;
+    const T* mp_object_pointer;
     complex_integrand<T> mp_member_function;
     P_integrator_real<IntegratorComplex<T>> mP_real_integrator;
     P_integrator_real<IntegratorComplex<T>> mP_imag_integrator;
 };
 
-
 //! Alias template for handle to a real integrator
-template <class T>
-using P_integrator_complex = std::unique_ptr<IntegratorComplex<T>>;
-
+template <class T> using P_integrator_complex = std::unique_ptr<IntegratorComplex<T>>;
 
 //! Template function to create an integrator object.
 //! @ingroup tools_internal
 
 template <class T>
-P_integrator_complex<T> make_integrator_complex(const T *object, complex_integrand<T> mem_function)
+P_integrator_complex<T> make_integrator_complex(const T* object, complex_integrand<T> mem_function)
 {
     P_integrator_complex<T> P_integrator(new IntegratorComplex<T>(object, mem_function));
     return P_integrator;
@@ -72,29 +66,27 @@ P_integrator_complex<T> make_integrator_complex(const T *object, complex_integra
 // Implementation
 // ************************************************************************** //
 
-template<class T> IntegratorComplex<T>::IntegratorComplex(
-        const T *p_object, complex_integrand<T> p_member_function)
-    : mp_object_pointer { p_object }
-    , mp_member_function { p_member_function }
+template <class T>
+IntegratorComplex<T>::IntegratorComplex(const T* p_object, complex_integrand<T> p_member_function)
+    : mp_object_pointer{p_object}, mp_member_function{p_member_function}
 {
     mP_real_integrator = make_integrator_real(this, &IntegratorComplex<T>::real);
     mP_imag_integrator = make_integrator_real(this, &IntegratorComplex<T>::imag);
 }
 
-template<class T> complex_t IntegratorComplex<T>::integrate(
-        double lmin, double lmax)
+template <class T> complex_t IntegratorComplex<T>::integrate(double lmin, double lmax)
 {
-   double real = mP_real_integrator->integrate(lmin, lmax);
-   double imag = mP_imag_integrator->integrate(lmin, lmax);
-   return complex_t(real, imag);
+    double real = mP_real_integrator->integrate(lmin, lmax);
+    double imag = mP_imag_integrator->integrate(lmin, lmax);
+    return complex_t(real, imag);
 }
 
-template<class T> double IntegratorComplex<T>::real(double value) const
+template <class T> double IntegratorComplex<T>::real(double value) const
 {
     return (mp_object_pointer->*mp_member_function)(value).real();
 }
 
-template<class T> double IntegratorComplex<T>::imag(double value) const
+template <class T> double IntegratorComplex<T>::imag(double value) const
 {
     return (mp_object_pointer->*mp_member_function)(value).imag();
 }
diff --git a/Core/Tools/IntegratorMCMiser.h b/Core/Tools/IntegratorMCMiser.h
index 8cbe6bf9594..96a744291e8 100644
--- a/Core/Tools/IntegratorMCMiser.h
+++ b/Core/Tools/IntegratorMCMiser.h
@@ -19,9 +19,7 @@
 #include <memory>
 
 //! Alias template for member function with signature double f(double)
-template <class T>
-using miser_integrand = double (T::*)(double *, size_t, void*) const;
-
+template <class T> using miser_integrand = double (T::*)(double*, size_t, void*) const;
 
 //! Template class to use Monte Carlo MISER integration of class member functions.
 //!
@@ -38,44 +36,42 @@ template <class T> class IntegratorMCMiser
 public:
     //! structure holding the object and possible extra parameters
     struct CallBackHolder {
-        const T *m_object_pointer;
+        const T* m_object_pointer;
         miser_integrand<T> m_member_function;
-        void *m_data;
+        void* m_data;
     };
 
     //! to integrate p_member_function, which must belong to p_object
-    IntegratorMCMiser(const T *p_object, miser_integrand<T> p_member_function, size_t dim);
+    IntegratorMCMiser(const T* p_object, miser_integrand<T> p_member_function, size_t dim);
     ~IntegratorMCMiser();
 
     //! perform the actual integration over the ranges [min_array, max_array]
-    double integrate(double *min_array, double *max_array, void* params,
-                     size_t nbr_points);
+    double integrate(double* min_array, double* max_array, void* params, size_t nbr_points);
 
 private:
     //! static function that can be passed to gsl integrator
-    static double StaticCallBack(double *d_array, size_t dim, void *v) {
-        CallBackHolder *p_cb = static_cast<CallBackHolder *>(v);
+    static double StaticCallBack(double* d_array, size_t dim, void* v)
+    {
+        CallBackHolder* p_cb = static_cast<CallBackHolder*>(v);
         auto mf = static_cast<miser_integrand<T>>(p_cb->m_member_function);
         return (p_cb->m_object_pointer->*mf)(d_array, dim, p_cb->m_data);
     }
-    const T *mp_object;
+    const T* mp_object;
     miser_integrand<T> m_member_function;
     size_t m_dim; //!< dimension of the integration
-    gsl_monte_miser_state *m_gsl_workspace;
-    gsl_rng *m_random_gen;
+    gsl_monte_miser_state* m_gsl_workspace;
+    gsl_rng* m_random_gen;
 };
 
-
 //! Alias template for handle to a miser integrator
-template <class T>
-using P_integrator_miser = std::unique_ptr<IntegratorMCMiser<T>>;
-
+template <class T> using P_integrator_miser = std::unique_ptr<IntegratorMCMiser<T>>;
 
 //! Template function to create an integrator object
 //! @ingroup tools_internal
 
-template <class T> P_integrator_miser<T>
-make_integrator_miser(const T *object, miser_integrand<T> mem_function, size_t dim)
+template <class T>
+P_integrator_miser<T> make_integrator_miser(const T* object, miser_integrand<T> mem_function,
+                                            size_t dim)
 {
     P_integrator_miser<T> P_integrator(new IntegratorMCMiser<T>(object, mem_function, dim));
     return P_integrator;
@@ -85,31 +81,31 @@ make_integrator_miser(const T *object, miser_integrand<T> mem_function, size_t d
 // Implementation
 // ************************************************************************** //
 
-template<class T> IntegratorMCMiser<T>::IntegratorMCMiser(
-        const T *p_object, miser_integrand<T> p_member_function, size_t dim)
-    : mp_object(p_object)
-    , m_member_function(p_member_function)
-    , m_dim(dim)
-    , m_gsl_workspace { nullptr }
+template <class T>
+IntegratorMCMiser<T>::IntegratorMCMiser(const T* p_object, miser_integrand<T> p_member_function,
+                                        size_t dim)
+    : mp_object(p_object), m_member_function(p_member_function),
+      m_dim(dim), m_gsl_workspace{nullptr}
 {
     m_gsl_workspace = gsl_monte_miser_alloc(m_dim);
 
-    const gsl_rng_type * random_type;
+    const gsl_rng_type* random_type;
     gsl_rng_env_setup();
     random_type = gsl_rng_default;
     m_random_gen = gsl_rng_alloc(random_type);
 }
 
-template<class T> IntegratorMCMiser<T>::~IntegratorMCMiser()
+template <class T> IntegratorMCMiser<T>::~IntegratorMCMiser()
 {
     gsl_monte_miser_free(m_gsl_workspace);
     gsl_rng_free(m_random_gen);
 }
 
-template<class T> double IntegratorMCMiser<T>::integrate(
-        double *min_array, double *max_array, void* params, size_t nbr_points)
+template <class T>
+double IntegratorMCMiser<T>::integrate(double* min_array, double* max_array, void* params,
+                                       size_t nbr_points)
 {
-    CallBackHolder cb = { mp_object, m_member_function, params };
+    CallBackHolder cb = {mp_object, m_member_function, params};
 
     gsl_monte_function f;
     f.f = StaticCallBack;
@@ -117,8 +113,8 @@ template<class T> double IntegratorMCMiser<T>::integrate(
     f.params = &cb;
 
     double result, error;
-    gsl_monte_miser_integrate(&f, min_array, max_array, m_dim, nbr_points,
-                                    m_random_gen, m_gsl_workspace, &result, &error);
+    gsl_monte_miser_integrate(&f, min_array, max_array, m_dim, nbr_points, m_random_gen,
+                              m_gsl_workspace, &result, &error);
     return result;
 }
 
diff --git a/Core/Tools/IntegratorReal.h b/Core/Tools/IntegratorReal.h
index 747ba572945..180bcfc9759 100644
--- a/Core/Tools/IntegratorReal.h
+++ b/Core/Tools/IntegratorReal.h
@@ -19,9 +19,7 @@
 #include <memory>
 
 //! Alias template for member function with signature double f(double)
-template <class T>
-using real_integrand = double (T::*)(double) const;
-
+template <class T> using real_integrand = double (T::*)(double) const;
 
 //! Template class to integrate class member functions.
 //!
@@ -37,12 +35,12 @@ template <class T> class IntegratorReal
 public:
     //! structure holding the object and possible extra parameters
     struct CallBackHolder {
-        const T *m_object_pointer;
+        const T* m_object_pointer;
         real_integrand<T> m_member_function;
     };
 
     //! to integrate p_member_function, which must belong to p_object
-    IntegratorReal(const T *p_object, real_integrand<T> p_member_function);
+    IntegratorReal(const T* p_object, real_integrand<T> p_member_function);
     ~IntegratorReal();
 
     //! perform the actual integration over the range [lmin, lmax]
@@ -50,26 +48,24 @@ public:
 
 private:
     //! static function that can be passed to gsl integrator
-    static double StaticCallBack(double d, void *v) {
-        CallBackHolder *p_cb = static_cast<CallBackHolder *>(v);
+    static double StaticCallBack(double d, void* v)
+    {
+        CallBackHolder* p_cb = static_cast<CallBackHolder*>(v);
         auto mf = static_cast<real_integrand<T>>(p_cb->m_member_function);
         return (p_cb->m_object_pointer->*mf)(d);
     }
     CallBackHolder m_cb;
-    gsl_integration_workspace *mp_gsl_workspace;
+    gsl_integration_workspace* mp_gsl_workspace;
 };
 
-
 //! Alias template for handle to a real integrator
-template <class T>
-using P_integrator_real = std::unique_ptr<IntegratorReal<T>>;
-
+template <class T> using P_integrator_real = std::unique_ptr<IntegratorReal<T>>;
 
 //! Template function to create an integrator object.
 //! @ingroup tools_internal
 
 template <class T>
-P_integrator_real<T> make_integrator_real(const T *object, real_integrand<T> mem_function)
+P_integrator_real<T> make_integrator_real(const T* object, real_integrand<T> mem_function)
 {
     P_integrator_real<T> P_integrator(new IntegratorReal<T>(object, mem_function));
     return P_integrator;
@@ -79,27 +75,27 @@ P_integrator_real<T> make_integrator_real(const T *object, real_integrand<T> mem
 // Implementation
 // ************************************************************************** //
 
-template<class T> IntegratorReal<T>::IntegratorReal(
-    const T *p_object, real_integrand<T> p_member_function)
-    : mp_gsl_workspace { nullptr }
+template <class T>
+IntegratorReal<T>::IntegratorReal(const T* p_object, real_integrand<T> p_member_function)
+    : mp_gsl_workspace{nullptr}
 {
-    m_cb = CallBackHolder{ p_object, p_member_function };
+    m_cb = CallBackHolder{p_object, p_member_function};
     mp_gsl_workspace = gsl_integration_workspace_alloc(200);
 }
 
-template<class T> IntegratorReal<T>::~IntegratorReal()
+template <class T> IntegratorReal<T>::~IntegratorReal()
 {
     gsl_integration_workspace_free(mp_gsl_workspace);
 }
 
-template<class T> double IntegratorReal<T>::integrate(double lmin, double lmax)
+template <class T> double IntegratorReal<T>::integrate(double lmin, double lmax)
 {
     gsl_function f;
     f.function = StaticCallBack;
-    f.params =&m_cb;
+    f.params = &m_cb;
 
     double result, error;
-    gsl_integration_qag(&f, lmin, lmax, 1e-10, 1e-8, 50, 1,  mp_gsl_workspace, &result, &error);
+    gsl_integration_qag(&f, lmin, lmax, 1e-10, 1e-8, 50, 1, mp_gsl_workspace, &result, &error);
 
     return result;
 }
diff --git a/Core/Tools/MathFunctions.cpp b/Core/Tools/MathFunctions.cpp
index bb30faba444..fe378402abc 100644
--- a/Core/Tools/MathFunctions.cpp
+++ b/Core/Tools/MathFunctions.cpp
@@ -14,13 +14,13 @@
 
 #include "MathFunctions.h"
 #include "MathConstants.h"
+#include <chrono>
+#include <cstring>
+#include <fftw3.h>
 #include <gsl/gsl_sf_bessel.h>
 #include <gsl/gsl_sf_erf.h>
 #include <gsl/gsl_sf_expint.h>
 #include <gsl/gsl_sf_trig.h>
-#include <fftw3.h>
-#include <chrono>
-#include <cstring>
 #include <limits>
 #include <random>
 #include <stdexcept> // need overlooked by g++ 5.4
@@ -48,46 +48,46 @@ double MathFunctions::IntegratedGaussian(double x, double average, double std_de
 
 double MathFunctions::cot(double x)
 {
-    return tan(M_PI_2-x);
+    return tan(M_PI_2 - x);
 }
 
-double MathFunctions::Si(double x)  // int_0^x du Sin(u)/u
+double MathFunctions::Si(double x) // int_0^x du Sin(u)/u
 {
     return gsl_sf_Si(x);
 }
 
-double MathFunctions::sinc(double x)  // Sin(x)/x
+double MathFunctions::sinc(double x) // Sin(x)/x
 {
-    return gsl_sf_sinc(x/M_PI);
+    return gsl_sf_sinc(x / M_PI);
 }
 
-complex_t MathFunctions::sinc(const complex_t z)  // Sin(x)/x
+complex_t MathFunctions::sinc(const complex_t z) // Sin(x)/x
 {
     // This is an exception from the rule that we must not test floating-point numbers for equality.
     // For small non-zero arguments, sin(z) returns quite accurately z or z-z^3/6.
     // There is no loss of precision in computing sin(z)/z.
     // Therefore there is no need for an expensive test like abs(z)<eps.
-    if( z==complex_t(0.,0.) )
+    if (z == complex_t(0., 0.))
         return 1.0;
-    return std::sin(z)/z;
+    return std::sin(z) / z;
 }
 
-complex_t MathFunctions::tanhc(const complex_t z)  // tanh(x)/x
+complex_t MathFunctions::tanhc(const complex_t z) // tanh(x)/x
 {
-    if(std::abs(z)<std::numeric_limits<double>::epsilon())
+    if (std::abs(z) < std::numeric_limits<double>::epsilon())
         return 1.0;
-    return std::tanh(z)/z;
+    return std::tanh(z) / z;
 }
 
 double MathFunctions::Laue(const double x, size_t N)
 {
-    static const double SQRT6DOUBLE_EPS = std::sqrt(6.0*std::numeric_limits<double>::epsilon());
+    static const double SQRT6DOUBLE_EPS = std::sqrt(6.0 * std::numeric_limits<double>::epsilon());
     auto nd = static_cast<double>(N);
-    if(std::abs(nd*x) < SQRT6DOUBLE_EPS)
+    if (std::abs(nd * x) < SQRT6DOUBLE_EPS)
         return nd;
-    double num = std::sin(nd*x);
+    double num = std::sin(nd * x);
     double den = std::sin(x);
-    return num/den;
+    return num / den;
 }
 
 double MathFunctions::erf(double arg)
@@ -106,11 +106,11 @@ double MathFunctions::erf(double arg)
 namespace MathFunctions
 {
 //! Computes complex Bessel function J0(z), using power series and asymptotic expansion
-    BA_CORE_API_ complex_t Bessel_J0_PowSer(const complex_t z);
+BA_CORE_API_ complex_t Bessel_J0_PowSer(const complex_t z);
 
-    //! Computes complex Bessel function J0(z), using power series and asymptotic expansion
-    BA_CORE_API_ complex_t Bessel_J1_PowSer(const complex_t z);
-}
+//! Computes complex Bessel function J0(z), using power series and asymptotic expansion
+BA_CORE_API_ complex_t Bessel_J1_PowSer(const complex_t z);
+} // namespace MathFunctions
 
 double MathFunctions::Bessel_J0(double x)
 {
@@ -124,7 +124,7 @@ double MathFunctions::Bessel_J1(double x)
 
 double MathFunctions::Bessel_J1c(double x)
 {
-    return x==0 ? 0.5 : gsl_sf_bessel_J1(x)/x;
+    return x == 0 ? 0.5 : gsl_sf_bessel_J1(x) / x;
 }
 
 double MathFunctions::Bessel_I0(double x)
@@ -134,25 +134,25 @@ double MathFunctions::Bessel_I0(double x)
 
 complex_t MathFunctions::Bessel_J0(const complex_t z)
 {
-    if (std::imag(z)==0)
+    if (std::imag(z) == 0)
         return gsl_sf_bessel_J0(std::real(z));
     return Bessel_J0_PowSer(z);
 }
 
 complex_t MathFunctions::Bessel_J1(const complex_t z)
 {
-    if (std::imag(z)==0)
+    if (std::imag(z) == 0)
         return gsl_sf_bessel_J1(std::real(z));
     return Bessel_J1_PowSer(z);
 }
 
 complex_t MathFunctions::Bessel_J1c(const complex_t z)
 {
-    if (std::imag(z)==0) {
+    if (std::imag(z) == 0) {
         double xv = std::real(z);
-        return xv==0 ? 0.5 : gsl_sf_bessel_J1(xv)/xv;
+        return xv == 0 ? 0.5 : gsl_sf_bessel_J1(xv) / xv;
     }
-    return z==0. ? 0.5 : MathFunctions::Bessel_J1_PowSer(z)/z;
+    return z == 0. ? 0.5 : MathFunctions::Bessel_J1_PowSer(z) / z;
 }
 
 //! Computes the complex Bessel function J0(z), using power series and asymptotic expansion.
@@ -166,16 +166,16 @@ complex_t MathFunctions::Bessel_J0_PowSer(const complex_t z)
     static const complex_t cone(1.0, 0.0);
     static const complex_t czero(0.0, 0.0);
     static const double eps = 1e-15;
-    static double a[] = { -7.03125e-2,           0.112152099609375,     -0.5725014209747314,
-                          6.074042001273483,     -1.100171402692467e2,  3.038090510922384e3,
-                          -1.188384262567832e5,  6.252951493434797e6,   -4.259392165047669e8,
-                          3.646840080706556e10,  -3.833534661393944e12, 4.854014686852901e14,
-                          -7.286857349377656e16, 1.279721941975975e19 };
-    static double b[] = { 7.32421875e-2,         -0.2271080017089844,  1.727727502584457,
-                          -2.438052969955606e1,  5.513358961220206e2,  -1.825775547429318e4,
-                          8.328593040162893e5,   -5.006958953198893e7, 3.836255180230433e9,
-                          -3.649010818849833e11, 4.218971570284096e13, -5.827244631566907e15,
-                          9.476288099260110e17,  -1.792162323051699e20 };
+    static double a[] = {-7.03125e-2,           0.112152099609375,     -0.5725014209747314,
+                         6.074042001273483,     -1.100171402692467e2,  3.038090510922384e3,
+                         -1.188384262567832e5,  6.252951493434797e6,   -4.259392165047669e8,
+                         3.646840080706556e10,  -3.833534661393944e12, 4.854014686852901e14,
+                         -7.286857349377656e16, 1.279721941975975e19};
+    static double b[] = {7.32421875e-2,         -0.2271080017089844,  1.727727502584457,
+                         -2.438052969955606e1,  5.513358961220206e2,  -1.825775547429318e4,
+                         8.328593040162893e5,   -5.006958953198893e7, 3.836255180230433e9,
+                         -3.649010818849833e11, 4.218971570284096e13, -5.827244631566907e15,
+                         9.476288099260110e17,  -1.792162323051699e20};
 
     double a0 = std::abs(z);
     complex_t z1 = z;
@@ -206,14 +206,14 @@ complex_t MathFunctions::Bessel_J0_PowSer(const complex_t z)
         complex_t ct1 = z1 - M_PI_4;
         complex_t cp0 = 1.0;
         complex_t cq0 = -0.125;
-        const complex_t z1m2 = 1. / (z1*z1); // faster than std::pow(z1, -2.0) ??
+        const complex_t z1m2 = 1. / (z1 * z1); // faster than std::pow(z1, -2.0) ??
         complex_t ptmp = z1m2;
         for (size_t k = 0; k < kz; ++k) {
             cp0 += a[k] * ptmp;
             cq0 += b[k] * ptmp;
             ptmp *= z1m2;
         }
-        cj0 = std::sqrt(M_2_PI / z1) * (cp0 * std::cos(ct1) - cq0/z1 * std::sin(ct1));
+        cj0 = std::sqrt(M_2_PI / z1) * (cp0 * std::cos(ct1) - cq0 / z1 * std::sin(ct1));
     }
     return cj0;
 }
@@ -227,16 +227,25 @@ complex_t MathFunctions::Bessel_J1_PowSer(const complex_t z)
     complex_t cj1;
     static const double eps = 1e-15;
 
-    static double a1[] = { 0.1171875,             -0.1441955566406250,  0.6765925884246826,
-                           -6.883914268109947,    1.215978918765359e2,  -3.302272294480852e3,
-                           1.276412726461746e5,   -6.656367718817688e6, 4.502786003050393e8,
-                           -3.833857520742790e10, 4.011838599133198e12, -5.060568503314727e14,
-                           7.572616461117958e16,  -1.326257285320556e19 };
-    static double b1[] = { -0.1025390625,         0.2775764465332031,    -1.993531733751297,
-                           2.724882731126854e1,   -6.038440767050702e2,  1.971837591223663e4,
-                           -8.902978767070678e5,  5.310411010968522e7,   -4.043620325107754e9,
-                           3.827011346598605e11,  -4.406481417852278e13, 6.065091351222699e15,
-                           -9.833883876590679e17, 1.855045211579828e20 };
+    static double a1[] = {0.1171875,
+                          -0.1441955566406250,
+                          0.6765925884246826,
+                          -6.883914268109947,
+                          1.215978918765359e2,
+                          -3.302272294480852e3,
+                          1.276412726461746e5,
+                          -6.656367718817688e6,
+                          4.502786003050393e8,
+                          -3.833857520742790e10,
+                          4.011838599133198e12,
+                          -5.060568503314727e14,
+                          7.572616461117958e16,
+                          -1.326257285320556e19};
+    static double b1[] = {-0.1025390625,         0.2775764465332031,    -1.993531733751297,
+                          2.724882731126854e1,   -6.038440767050702e2,  1.971837591223663e4,
+                          -8.902978767070678e5,  5.310411010968522e7,   -4.043620325107754e9,
+                          3.827011346598605e11,  -4.406481417852278e13, 6.065091351222699e15,
+                          -9.833883876590679e17, 1.855045211579828e20};
 
     double a0 = std::abs(z);
     if (a0 == 0.0)
@@ -267,16 +276,16 @@ complex_t MathFunctions::Bessel_J1_PowSer(const complex_t z)
         else
             kz = 12; //   "      "     "  14
         complex_t cp1 = 1.0;
-        complex_t cq1 = 0.375; // division by z1 postponed to final sum
-        const complex_t z1m2 = 1. / (z1*z1); // faster than std::pow(z1, -2.0) ??
-        complex_t ptmp = z1m2; // powers will be computed recursively
+        complex_t cq1 = 0.375;                 // division by z1 postponed to final sum
+        const complex_t z1m2 = 1. / (z1 * z1); // faster than std::pow(z1, -2.0) ??
+        complex_t ptmp = z1m2;                 // powers will be computed recursively
         for (size_t k = 0; k < kz; ++k) {
             cp1 += a1[k] * ptmp;
             cq1 += b1[k] * ptmp; // division by z1 postponed to final sum
             ptmp *= z1m2;
         }
         const complex_t ct2 = z1 - 0.75 * M_PI;
-        cj1 = std::sqrt(M_2_PI / z1) * (cp1 * std::cos(ct2) - cq1/z1 * std::sin(ct2));
+        cj1 = std::sqrt(M_2_PI / z1) * (cp1 * std::cos(ct2) - cq1 / z1 * std::sin(ct2));
     }
     if (std::real(z) < 0.0)
         cj1 = -cj1;
@@ -290,15 +299,14 @@ complex_t MathFunctions::Bessel_J1_PowSer(const complex_t z)
 //! @brief simple (and unoptimized) wrapper function
 //!   for the discrete fast Fourier transformation library (fftw3)
 
-std::vector<complex_t>
-MathFunctions::FastFourierTransform(const std::vector<complex_t> &data,
-                                    MathFunctions::EFFTDirection ftCase)
+std::vector<complex_t> MathFunctions::FastFourierTransform(const std::vector<complex_t>& data,
+                                                           MathFunctions::EFFTDirection ftCase)
 {
     double scale(1.);
     size_t npx = data.size();
 
-    fftw_complex *ftData = (fftw_complex *)fftw_malloc(sizeof(fftw_complex) * npx);
-    fftw_complex *ftResult = (fftw_complex *)fftw_malloc(sizeof(fftw_complex) * npx);
+    fftw_complex* ftData = (fftw_complex*)fftw_malloc(sizeof(fftw_complex) * npx);
+    fftw_complex* ftResult = (fftw_complex*)fftw_malloc(sizeof(fftw_complex) * npx);
     memset(ftData, 0, sizeof(fftw_complex) * npx);
     memset(ftResult, 0, sizeof(fftw_complex) * npx);
 
@@ -340,8 +348,8 @@ MathFunctions::FastFourierTransform(const std::vector<complex_t> &data,
 //!   for the discrete fast Fourier transformation library (fftw3);
 //!   transforms real to complex
 
-std::vector<complex_t> MathFunctions::FastFourierTransform(
-    const std::vector<double> &data, MathFunctions::EFFTDirection ftCase)
+std::vector<complex_t> MathFunctions::FastFourierTransform(const std::vector<double>& data,
+                                                           MathFunctions::EFFTDirection ftCase)
 {
     std::vector<complex_t> cdata;
     cdata.resize(data.size());
@@ -352,29 +360,27 @@ std::vector<complex_t> MathFunctions::FastFourierTransform(
 
 //! convolution of two real vectors of equal size
 
-std::vector<complex_t>
-MathFunctions::ConvolveFFT(const std::vector<double> &signal,
-                           const std::vector<double> &resfunc)
+std::vector<complex_t> MathFunctions::ConvolveFFT(const std::vector<double>& signal,
+                                                  const std::vector<double>& resfunc)
 {
     if (signal.size() != resfunc.size())
         throw std::runtime_error("MathFunctions::ConvolveFFT() -> This convolution works only for "
                                  "two vectors of equal size. Use Convolve class instead.");
-    std::vector<complex_t> fft_signal
-        = MathFunctions::FastFourierTransform(signal, MathFunctions::FORWARD_FFT);
-    std::vector<complex_t> fft_resfunc
-        = MathFunctions::FastFourierTransform(resfunc, MathFunctions::FORWARD_FFT);
+    std::vector<complex_t> fft_signal =
+        MathFunctions::FastFourierTransform(signal, MathFunctions::FORWARD_FFT);
+    std::vector<complex_t> fft_resfunc =
+        MathFunctions::FastFourierTransform(resfunc, MathFunctions::FORWARD_FFT);
 
     std::vector<complex_t> fft_prod;
     fft_prod.resize(fft_signal.size());
     for (size_t i = 0; i < fft_signal.size(); i++)
         fft_prod[i] = fft_signal[i] * fft_resfunc[i];
 
-    std::vector<complex_t> result
-        = MathFunctions::FastFourierTransform(fft_prod, MathFunctions::BACKWARD_FFT);
+    std::vector<complex_t> result =
+        MathFunctions::FastFourierTransform(fft_prod, MathFunctions::BACKWARD_FFT);
     return result;
 }
 
-
 // ************************************************************************** //
 //  Random number generators
 // ************************************************************************** //
@@ -387,7 +393,8 @@ double MathFunctions::GenerateUniformRandom()
 
 double MathFunctions::GenerateStandardNormalRandom() // using c++11 standard library
 {
-    unsigned seed = static_cast<unsigned>(std::chrono::system_clock::now().time_since_epoch().count());
+    unsigned seed =
+        static_cast<unsigned>(std::chrono::system_clock::now().time_since_epoch().count());
     std::default_random_engine generator(seed);
     std::normal_distribution<double> distribution(0.0, 1.0);
     return distribution(generator);
@@ -395,20 +402,21 @@ double MathFunctions::GenerateStandardNormalRandom() // using c++11 standard lib
 
 double MathFunctions::GenerateNormalRandom(double average, double std_dev)
 {
-    return GenerateStandardNormalRandom()*std_dev + average;
+    return GenerateStandardNormalRandom() * std_dev + average;
 }
 
 double MathFunctions::GeneratePoissonRandom(double average) // using c++11 standard library
 {
-    unsigned seed = static_cast<unsigned>(std::chrono::system_clock::now().time_since_epoch().count());
+    unsigned seed =
+        static_cast<unsigned>(std::chrono::system_clock::now().time_since_epoch().count());
     std::default_random_engine generator(seed);
     if (average <= 0.0)
         return 0.0;
-    if (average < 1000.0) {  // Use std::poisson_distribution
+    if (average < 1000.0) { // Use std::poisson_distribution
         std::poisson_distribution<int> distribution(average);
         int sample = distribution(generator);
         return (double)sample;
-    } else {                 // Use normal approximation
+    } else { // Use normal approximation
         std::normal_distribution<double> distribution(average, std::sqrt(average));
         double sample = distribution(generator);
         return std::max(0.0, sample);
diff --git a/Core/Tools/MathFunctions.h b/Core/Tools/MathFunctions.h
index c6e400c766d..61357192383 100644
--- a/Core/Tools/MathFunctions.h
+++ b/Core/Tools/MathFunctions.h
@@ -15,8 +15,8 @@
 #ifndef MATHFUNCTIONS_H
 #define MATHFUNCTIONS_H
 
-#include "WinDllMacros.h"
 #include "Complex.h"
+#include "WinDllMacros.h"
 #include <vector>
 
 //! Various mathematical functions.
@@ -28,86 +28,82 @@ namespace MathFunctions
 //  Various functions
 // ************************************************************************** //
 
-    BA_CORE_API_ double StandardNormal(double x);
-    BA_CORE_API_ double Gaussian(double x, double average, double std_dev);
-    BA_CORE_API_ double IntegratedGaussian(double x, double average, double std_dev);
+BA_CORE_API_ double StandardNormal(double x);
+BA_CORE_API_ double Gaussian(double x, double average, double std_dev);
+BA_CORE_API_ double IntegratedGaussian(double x, double average, double std_dev);
 
 //! cotangent function: \f$cot(x)\equiv1/tan(x)\f$
-    BA_CORE_API_ double cot(double x);
+BA_CORE_API_ double cot(double x);
 
 //! Sine integral function: \f$Si(x)\equiv\int_0^x du \sin(u)/u\f$
-    BA_CORE_API_ double Si(double x);
+BA_CORE_API_ double Si(double x);
 
 //! sinc function: \f$sinc(x)\equiv\sin(x)/x\f$
-    BA_CORE_API_ double sinc(double x);
+BA_CORE_API_ double sinc(double x);
 
 //! Complex sinc function: \f$sinc(x)\equiv\sin(x)/x\f$
-    BA_CORE_API_ complex_t sinc(const complex_t z);
+BA_CORE_API_ complex_t sinc(const complex_t z);
 
 //! Complex tanhc function: \f$tanhc(x)\equiv\tanh(x)/x\f$
-    BA_CORE_API_ complex_t tanhc(const complex_t z);
+BA_CORE_API_ complex_t tanhc(const complex_t z);
 
 //! Real Laue function: \f$Laue(x,N)\equiv\sin(Nx)/sin(x)\f$
-    BA_CORE_API_ double Laue(const double x, size_t N);
+BA_CORE_API_ double Laue(const double x, size_t N);
 
 //! Error function of real-valued argument
-    BA_CORE_API_ double erf(double arg);
-
+BA_CORE_API_ double erf(double arg);
 
 // ************************************************************************** //
 //  Bessel functions
 // ************************************************************************** //
 
 //! Bessel function of the first kind and order 0
-    BA_CORE_API_ double Bessel_J0(double x);
+BA_CORE_API_ double Bessel_J0(double x);
 
 //! Bessel function of the first kind and order 1
-    BA_CORE_API_ double Bessel_J1(double x);
+BA_CORE_API_ double Bessel_J1(double x);
 
 //! Bessel function  Bessel_J1(x)/x
-    BA_CORE_API_ double Bessel_J1c(double x);
+BA_CORE_API_ double Bessel_J1c(double x);
 
 //! Modified Bessel function of the first kind and order 0
-    BA_CORE_API_ double Bessel_I0(double x);
+BA_CORE_API_ double Bessel_I0(double x);
 
 //! Complex Bessel function of the first kind and order 0
-    BA_CORE_API_ complex_t Bessel_J0(const complex_t z);
+BA_CORE_API_ complex_t Bessel_J0(const complex_t z);
 
 //! Complex Bessel function of the first kind and order 1
-    BA_CORE_API_ complex_t Bessel_J1(const complex_t z);
+BA_CORE_API_ complex_t Bessel_J1(const complex_t z);
 
 //! Complex Bessel function  Bessel_J1(x)/x
-    BA_CORE_API_ complex_t Bessel_J1c(const complex_t z);
-
+BA_CORE_API_ complex_t Bessel_J1c(const complex_t z);
 
 // ************************************************************************** //
 //  Fourier transform and convolution
 // ************************************************************************** //
 
-    // TODO move elsewhere, and rm #include <vector>
-
-    enum EFFTDirection { FORWARD_FFT, BACKWARD_FFT };
+// TODO move elsewhere, and rm #include <vector>
 
-    // TODO: name these two functions differently (SWIG warning 509)
-    BA_CORE_API_ std::vector<complex_t >
-        FastFourierTransform(const std::vector<complex_t>& data, EFFTDirection tcase);
-    BA_CORE_API_ std::vector<complex_t >
-        FastFourierTransform(const std::vector<double>& data, EFFTDirection tcase);
+enum EFFTDirection { FORWARD_FFT, BACKWARD_FFT };
 
-    BA_CORE_API_ std::vector<complex_t>
-        ConvolveFFT(const std::vector<double>& signal, const std::vector<double>& resfunc);
+// TODO: name these two functions differently (SWIG warning 509)
+BA_CORE_API_ std::vector<complex_t> FastFourierTransform(const std::vector<complex_t>& data,
+                                                         EFFTDirection tcase);
+BA_CORE_API_ std::vector<complex_t> FastFourierTransform(const std::vector<double>& data,
+                                                         EFFTDirection tcase);
 
+BA_CORE_API_ std::vector<complex_t> ConvolveFFT(const std::vector<double>& signal,
+                                                const std::vector<double>& resfunc);
 
 // ************************************************************************** //
 //  Random number generators
 // ************************************************************************** //
 
-    BA_CORE_API_ double GenerateUniformRandom();
-    BA_CORE_API_ double GenerateStandardNormalRandom();
-    BA_CORE_API_ double GenerateNormalRandom(double average, double std_dev);
-    BA_CORE_API_ double GeneratePoissonRandom(double average);
+BA_CORE_API_ double GenerateUniformRandom();
+BA_CORE_API_ double GenerateStandardNormalRandom();
+BA_CORE_API_ double GenerateNormalRandom(double average, double std_dev);
+BA_CORE_API_ double GeneratePoissonRandom(double average);
 
 } // Namespace MathFunctions
 
-
 #endif // MATHFUNCTIONS_H
diff --git a/Core/Tools/Numeric.cpp b/Core/Tools/Numeric.cpp
index 2ddf53508a6..8d32688672e 100644
--- a/Core/Tools/Numeric.cpp
+++ b/Core/Tools/Numeric.cpp
@@ -19,38 +19,41 @@
 
 //! Floating-point epsilon, tolerances, almost-equal.
 
-namespace Numeric {
+namespace Numeric
+{
 
 //! Returns true if two doubles agree within epsilon*tolerance.
 bool AreAlmostEqual(double a, double b, double tolerance)
 {
     constexpr double eps = std::numeric_limits<double>::epsilon();
-    return std::abs(a-b) <= eps * std::max( tolerance*eps, std::max(1., tolerance)*std::abs(b) );
+    return std::abs(a - b)
+           <= eps * std::max(tolerance * eps, std::max(1., tolerance) * std::abs(b));
 }
 
 //! Returns the absolute value of the difference between a and b.
 double GetAbsoluteDifference(double a, double b)
 {
-    return std::abs(a-b);
+    return std::abs(a - b);
 }
 
 //! Returns the safe relative difference, which is 2(|a-b|)/(|a|+|b|) except in special cases.
 double GetRelativeDifference(double a, double b)
 {
     constexpr double eps = std::numeric_limits<double>::epsilon();
-    const double avg_abs = (std::abs(a) + std::abs(b))/2.0;
+    const double avg_abs = (std::abs(a) + std::abs(b)) / 2.0;
     // return 0.0 if relative error smaller than epsilon
-    if (std::abs(a-b) <= eps*avg_abs)
+    if (std::abs(a - b) <= eps * avg_abs)
         return 0.0;
-    return std::abs(a-b)/avg_abs;
+    return std::abs(a - b) / avg_abs;
 }
 
-//! Returns the difference of the logarithm; input values are truncated at the minimum positive value
+//! Returns the difference of the logarithm; input values are truncated at the minimum positive
+//! value
 double GetLogDifference(double a, double b)
 {
     double a_t = std::max(a, std::numeric_limits<double>::min());
     double b_t = std::max(b, std::numeric_limits<double>::min());
-    return std::abs(std::log(a_t)-std::log(b_t));
+    return std::abs(std::log(a_t) - std::log(b_t));
 }
 
-} // Numeric namespace
+} // namespace Numeric
diff --git a/Core/Tools/Numeric.h b/Core/Tools/Numeric.h
index 93d4987dbf7..a875d0123b5 100644
--- a/Core/Tools/Numeric.h
+++ b/Core/Tools/Numeric.h
@@ -20,9 +20,10 @@
 
 //! Floating-point epsilon, tolerances, almost-equal.
 
-namespace Numeric {
+namespace Numeric
+{
 
-bool BA_CORE_API_ AreAlmostEqual(double a, double b, double tolerance_factor=1.0);
+bool BA_CORE_API_ AreAlmostEqual(double a, double b, double tolerance_factor = 1.0);
 
 double BA_CORE_API_ GetAbsoluteDifference(double a, double b);
 
@@ -30,6 +31,6 @@ double BA_CORE_API_ GetRelativeDifference(double a, double b);
 
 double BA_CORE_API_ GetLogDifference(double a, double b);
 
-} // Numeric namespace
+} // namespace Numeric
 
 #endif // NUMERIC_H
diff --git a/Core/Tools/OrderedMap.h b/Core/Tools/OrderedMap.h
index bbdc3d4890b..3a2809e0621 100644
--- a/Core/Tools/OrderedMap.h
+++ b/Core/Tools/OrderedMap.h
@@ -15,11 +15,11 @@
 #ifndef ORDEREDMAP_H
 #define ORDEREDMAP_H
 
-#include <list>
-#include <unordered_map>
-#include <stdexcept>
 #include <cassert>
 #include <iostream>
+#include <list>
+#include <stdexcept>
+#include <unordered_map>
 
 //! @class OrderedMap
 //! @ingroup tools_internal
diff --git a/Core/Tools/Precomputed.h b/Core/Tools/Precomputed.h
index 20c2cf54d98..8bccd35a345 100644
--- a/Core/Tools/Precomputed.h
+++ b/Core/Tools/Precomputed.h
@@ -23,29 +23,25 @@
 //! Compile-time generated std::array of reciprocal factorials
 namespace Precomputed
 {
-template<size_t N>
-struct ReciprocalFactorial
-{
-    static constexpr double value = ReciprocalFactorial<N-1>::value/N;
+template <size_t N> struct ReciprocalFactorial {
+    static constexpr double value = ReciprocalFactorial<N - 1>::value / N;
 };
 
-template<>
-struct ReciprocalFactorial<0>
-{
+template <> struct ReciprocalFactorial<0> {
     static constexpr double value = 1.0;
 };
 
-template<template<size_t> class F, size_t... I>
+template <template <size_t> class F, size_t... I>
 constexpr std::array<double, sizeof...(I)> GenerateArrayHelper(std::index_sequence<I...>)
 {
-    return { F<I>::value... };
+    return {F<I>::value...};
 };
 
-template<size_t N, typename Indices = std::make_index_sequence<N>>
+template <size_t N, typename Indices = std::make_index_sequence<N>>
 constexpr std::array<double, N> GenerateReciprocalFactorialArray()
 {
     return GenerateArrayHelper<ReciprocalFactorial>(Indices{});
 };
-}  // namespace Precomputed
+} // namespace Precomputed
 
 #endif // PRECOMPUTED_H
diff --git a/Core/Tools/PyEmbeddedUtils.cpp b/Core/Tools/PyEmbeddedUtils.cpp
index 41e06b8ae4c..1195e6e1764 100644
--- a/Core/Tools/PyEmbeddedUtils.cpp
+++ b/Core/Tools/PyEmbeddedUtils.cpp
@@ -13,13 +13,12 @@
 // ************************************************************************** //
 
 #include "PyEmbeddedUtils.h"
+#include "MultiLayer.h"
 #include "PythonCore.h"
 #include "PythonFormatting.h"
-#include "MultiLayer.h"
 #include "SysUtils.h"
-#include <stdexcept>
 #include <iostream>
-
+#include <stdexcept>
 
 std::string PyEmbeddedUtils::toString(PyObject* obj)
 {
@@ -41,14 +40,14 @@ std::vector<std::string> PyEmbeddedUtils::toVectorString(PyObject* obj)
 
     if (PyTuple_Check(obj)) {
         for (Py_ssize_t i = 0; i < PyTuple_Size(obj); i++) {
-            PyObject *value = PyTuple_GetItem(obj, i);
-            result.push_back( toString(value) );
+            PyObject* value = PyTuple_GetItem(obj, i);
+            result.push_back(toString(value));
         }
 
     } else if (PyList_Check(obj)) {
         for (Py_ssize_t i = 0; i < PyList_Size(obj); i++) {
-            PyObject *value = PyList_GetItem(obj, i);
-            result.push_back( toString(value) );
+            PyObject* value = PyList_GetItem(obj, i);
+            result.push_back(toString(value));
         }
 
     } else {
@@ -58,7 +57,6 @@ std::vector<std::string> PyEmbeddedUtils::toVectorString(PyObject* obj)
     return result;
 }
 
-
 std::string PyEmbeddedUtils::toString(char* c)
 {
     if (c)
@@ -67,12 +65,11 @@ std::string PyEmbeddedUtils::toString(char* c)
         return std::string();
 }
 
-
 std::string PyEmbeddedUtils::toString(wchar_t* c)
 {
     if (c) {
         std::wstring wstr(c);
-        std::string result( wstr.begin(), wstr.end() );
+        std::string result(wstr.begin(), wstr.end());
         return result;
     } else {
         return std::string();
@@ -85,11 +82,10 @@ void PyEmbeddedUtils::import_bornagain(const std::string& path)
         Py_InitializeEx(0);
 
         if (!path.empty()) {
-            PyObject *sysPath = PySys_GetObject((char*)"path");
+            PyObject* sysPath = PySys_GetObject((char*)"path");
             PyList_Append(sysPath, PyString_FromString(path.c_str()));
         }
 
-
         // Stores signal handler before numpy's mess it up.
         // This is to make ctrl-c working from terminal.
 #ifndef _WIN32
@@ -106,9 +102,7 @@ void PyEmbeddedUtils::import_bornagain(const std::string& path)
 #ifndef _WIN32
         PyOS_setsig(SIGINT, sighandler);
 #endif
-
     }
-
 }
 
 std::string PyEmbeddedUtils::pythonRuntimeInfo()
@@ -124,17 +118,14 @@ std::string PyEmbeddedUtils::pythonRuntimeInfo()
     result << "PYTHONHOME: " << SysUtils::getenv("PYTHONHOME") << "\n";
 
     // Embedded Python details
-    result << "Py_GetProgramName(): "
-           << PyEmbeddedUtils::toString(Py_GetProgramName()) << "\n";
-    result << "Py_GetProgramFullPath(): "
-           << PyEmbeddedUtils::toString(Py_GetProgramFullPath()) << "\n";
-    result << "Py_GetPath(): "
-           << PyEmbeddedUtils::toString(Py_GetPath()) << "\n";
-    result << "Py_GetPythonHome(): "
-           << PyEmbeddedUtils::toString(Py_GetPythonHome()) << "\n";
+    result << "Py_GetProgramName(): " << PyEmbeddedUtils::toString(Py_GetProgramName()) << "\n";
+    result << "Py_GetProgramFullPath(): " << PyEmbeddedUtils::toString(Py_GetProgramFullPath())
+           << "\n";
+    result << "Py_GetPath(): " << PyEmbeddedUtils::toString(Py_GetPath()) << "\n";
+    result << "Py_GetPythonHome(): " << PyEmbeddedUtils::toString(Py_GetPythonHome()) << "\n";
 
     // Runtime Python's sys.path
-    PyObject *sysPath = PySys_GetObject((char*)"path");
+    PyObject* sysPath = PySys_GetObject((char*)"path");
     auto content = PyEmbeddedUtils::toVectorString(sysPath);
     result << "sys.path: ";
     for (auto s : content)
@@ -167,7 +158,8 @@ std::string PyEmbeddedUtils::pythonStackTrace()
             result << "\n";
             PyObject* pyth_func = PyObject_GetAttrString(pyth_module, "format_exception");
             if (pyth_func && PyCallable_Check(pyth_func)) {
-                PyObject* pyth_val = PyObject_CallFunctionObjArgs(pyth_func, ptype, pvalue, ptraceback, NULL);
+                PyObject* pyth_val =
+                    PyObject_CallFunctionObjArgs(pyth_func, ptype, pvalue, ptraceback, NULL);
                 if (pyth_val) {
                     pystr = PyObject_Str(pyth_val);
                     if (char* str = PyString_AsString(pystr))
diff --git a/Core/Tools/PyEmbeddedUtils.h b/Core/Tools/PyEmbeddedUtils.h
index 9e79eaaf64a..a15a8faa240 100644
--- a/Core/Tools/PyEmbeddedUtils.h
+++ b/Core/Tools/PyEmbeddedUtils.h
@@ -15,15 +15,16 @@
 #ifndef PYEMBEDDEDUTILS_H
 #define PYEMBEDDEDUTILS_H
 
-#include "WinDllMacros.h"
 #include "PyObject.h"
+#include "WinDllMacros.h"
+#include <memory>
 #include <string>
 #include <vector>
-#include <memory>
 
 class MultiLayer;
 
-namespace PyEmbeddedUtils {
+namespace PyEmbeddedUtils
+{
 
 //! Converts PyObject into string, if possible, or throws exception.
 BA_CORE_API_ std::string toString(PyObject* obj);
@@ -43,7 +44,6 @@ BA_CORE_API_ std::string pythonRuntimeInfo();
 
 //! Returns string representing python stack trace.
 BA_CORE_API_ std::string pythonStackTrace();
-}
+} // namespace PyEmbeddedUtils
 
 #endif
-
diff --git a/Core/Tools/PyImport.cpp b/Core/Tools/PyImport.cpp
index a142501dc82..a3eedbb5bd5 100644
--- a/Core/Tools/PyImport.cpp
+++ b/Core/Tools/PyImport.cpp
@@ -13,11 +13,12 @@
 // ************************************************************************** //
 
 #include "PyImport.h"
-#include "PythonCore.h"
-#include "PyEmbeddedUtils.h"
 #include "MultiLayer.h"
+#include "PyEmbeddedUtils.h"
+#include "PythonCore.h"
 
-namespace {
+namespace
+{
 
 std::string error_description(const std::string& title)
 {
@@ -28,8 +29,7 @@ std::string error_description(const std::string& title)
     return buf.str();
 }
 
-}
-
+} // namespace
 
 std::unique_ptr<MultiLayer> PyImport::createFromPython(const std::string& script,
                                                        const std::string& functionName,
@@ -37,39 +37,39 @@ std::unique_ptr<MultiLayer> PyImport::createFromPython(const std::string& script
 {
     PyEmbeddedUtils::import_bornagain(path);
 
-    PyObject* pCompiledFn = Py_CompileString( script.c_str() , "" , Py_file_input ) ;
+    PyObject* pCompiledFn = Py_CompileString(script.c_str(), "", Py_file_input);
     if (!pCompiledFn)
         throw std::runtime_error(error_description("Can't compile snippet"));
 
     // create a module
-    PyObject* pModule = PyImport_ExecCodeModule((char *)"test" , pCompiledFn ) ;
+    PyObject* pModule = PyImport_ExecCodeModule((char*)"test", pCompiledFn);
     if (!pModule) {
-        Py_DecRef( pCompiledFn ) ;
+        Py_DecRef(pCompiledFn);
         throw std::runtime_error(error_description("Can't exec module"));
     }
 
     // locate the "get_simulation" function (it's an attribute of the module)
-    PyObject* pAddFn = PyObject_GetAttrString( pModule , functionName.c_str() ) ;
+    PyObject* pAddFn = PyObject_GetAttrString(pModule, functionName.c_str());
     if (!pAddFn)
         throw std::runtime_error("Can't locate compiled function");
 
-    PyObject *instance =  PyObject_CallFunctionObjArgs(pAddFn, NULL);
+    PyObject* instance = PyObject_CallFunctionObjArgs(pAddFn, NULL);
     if (!instance) {
-        Py_DecRef( pAddFn ) ;
-        Py_DecRef( pModule ) ;
-        Py_DecRef( pCompiledFn ) ;
+        Py_DecRef(pAddFn);
+        Py_DecRef(pModule);
+        Py_DecRef(pCompiledFn);
         throw std::runtime_error(error_description("Can't call function"));
     }
 
     // clean up
-    Py_DecRef( pAddFn ) ;
-    Py_DecRef( pModule ) ;
-    Py_DecRef( pCompiledFn ) ;
+    Py_DecRef(pAddFn);
+    Py_DecRef(pModule);
+    Py_DecRef(pCompiledFn);
 
-    void *argp1 = 0;
-    swig_type_info * pTypeInfo = SWIG_TypeQuery("MultiLayer *");
+    void* argp1 = 0;
+    swig_type_info* pTypeInfo = SWIG_TypeQuery("MultiLayer *");
 
-    const int res = SWIG_ConvertPtr(instance, &argp1,pTypeInfo, 0);
+    const int res = SWIG_ConvertPtr(instance, &argp1, pTypeInfo, 0);
     if (!SWIG_IsOK(res)) {
         Py_DecRef(instance);
         throw std::runtime_error("SWIG failed to extract a MultiLayer.");
@@ -88,35 +88,35 @@ std::vector<std::string> PyImport::listOfFunctions(const std::string& script,
 {
     PyEmbeddedUtils::import_bornagain(path);
 
-    PyObject* pCompiledFn = Py_CompileString( script.c_str() , "" , Py_file_input ) ;
+    PyObject* pCompiledFn = Py_CompileString(script.c_str(), "", Py_file_input);
     if (!pCompiledFn)
         throw std::runtime_error(error_description("Can't compile snippet"));
 
     // create a module
-    PyObject* pModule = PyImport_ExecCodeModule((char *)"test" , pCompiledFn ) ;
+    PyObject* pModule = PyImport_ExecCodeModule((char*)"test", pCompiledFn);
     if (!pModule) {
-        Py_DecRef( pCompiledFn ) ;
+        Py_DecRef(pCompiledFn);
         throw std::runtime_error(error_description("Can't exec module"));
     }
 
-     PyObject *dict = PyModule_GetDict(pModule);
-     if (!dict)
-         throw std::runtime_error("Can't get dictionary from module");
+    PyObject* dict = PyModule_GetDict(pModule);
+    if (!dict)
+        throw std::runtime_error("Can't get dictionary from module");
 
-     std::vector<std::string> result;
-     PyObject *key, *value;
-     Py_ssize_t pos = 0;
-     while (PyDict_Next(dict, &pos, &key, &value)) {
-         if(PyCallable_Check(value)) {
+    std::vector<std::string> result;
+    PyObject *key, *value;
+    Py_ssize_t pos = 0;
+    while (PyDict_Next(dict, &pos, &key, &value)) {
+        if (PyCallable_Check(value)) {
             std::string func_name = PyEmbeddedUtils::toString(key);
             if (func_name.find("__") == std::string::npos)
-                 result.push_back(func_name);
-         }
-     }
+                result.push_back(func_name);
+        }
+    }
 
-     Py_DecRef( dict ) ;
-     Py_DecRef( pModule ) ;
-     Py_DecRef( pCompiledFn ) ;
+    Py_DecRef(dict);
+    Py_DecRef(pModule);
+    Py_DecRef(pCompiledFn);
 
-     return result;
+    return result;
 }
diff --git a/Core/Tools/PyImport.h b/Core/Tools/PyImport.h
index 93144c4c4b7..bc8fb970983 100644
--- a/Core/Tools/PyImport.h
+++ b/Core/Tools/PyImport.h
@@ -16,16 +16,17 @@
 #define PYIMPORT_H
 
 #include "WinDllMacros.h"
+#include <memory>
 #include <string>
 #include <vector>
-#include <memory>
 
 class MultiLayer;
 
-namespace PyImport {
+namespace PyImport
+{
 
 ////! Returns directory name
-//std::string bornagainPythonDir();
+// std::string bornagainPythonDir();
 
 //! Creates a multi layer by running python code in embedded interpreter.
 //! @param script: Python script
@@ -40,7 +41,6 @@ BA_CORE_API_ std::unique_ptr<MultiLayer> createFromPython(const std::string& scr
 //! @param path: A path to import BornAgain library. If empty, relies on PYTHONPATH
 BA_CORE_API_ std::vector<std::string> listOfFunctions(const std::string& script,
                                                       const std::string& path = std::string());
-}
+} // namespace PyImport
 
 #endif
-
diff --git a/Core/Tools/PyObject.h b/Core/Tools/PyObject.h
index 4e012aa491e..71a996ad93b 100644
--- a/Core/Tools/PyObject.h
+++ b/Core/Tools/PyObject.h
@@ -23,4 +23,3 @@ typedef _object PyObject;
 #endif
 
 #endif
-
diff --git a/Core/Tools/PythonCore.h b/Core/Tools/PythonCore.h
index 9103f90ef2f..1c8b3e45954 100644
--- a/Core/Tools/PythonCore.h
+++ b/Core/Tools/PythonCore.h
@@ -33,5 +33,3 @@
 #endif // BORNAGAIN_PYTHON
 
 #endif // PYTHONCORE_H
-
-
diff --git a/Core/Tools/SpectrumUtils.cpp b/Core/Tools/SpectrumUtils.cpp
index aa37cd465ad..1b4d4ad741a 100644
--- a/Core/Tools/SpectrumUtils.cpp
+++ b/Core/Tools/SpectrumUtils.cpp
@@ -13,13 +13,14 @@
 // ************************************************************************** //
 
 #include "SpectrumUtils.h"
-#include "tspectrum.h"
 #include "ArrayUtils.h"
+#include "tspectrum.h"
 #include <cmath>
 
-std::vector<std::pair<double, double>>
-SpectrumUtils::FindPeaks(const Histogram2D& hist, double sigma,
-                          const std::string& option, double threshold)
+std::vector<std::pair<double, double>> SpectrumUtils::FindPeaks(const Histogram2D& hist,
+                                                                double sigma,
+                                                                const std::string& option,
+                                                                double threshold)
 {
     std::unique_ptr<OutputData<double>> data(hist.createOutputData());
     std::vector<std::vector<double>> arr = ArrayUtils::createVector2D(*data);
@@ -29,7 +30,7 @@ SpectrumUtils::FindPeaks(const Histogram2D& hist, double sigma,
     // coordinates of peaks in histogram axes units
     std::vector<std::pair<double, double>> result;
 
-    for(const auto& p : peaks) {
+    for (const auto& p : peaks) {
         double row_value = p.first;
         double col_value = p.second;
 
@@ -40,10 +41,10 @@ SpectrumUtils::FindPeaks(const Histogram2D& hist, double sigma,
         Bin1D ybin = hist.getYaxis().getBin(yaxis_index);
 
         double dx = col_value - static_cast<size_t>(col_value);
-        double dy = -1.0*(row_value - static_cast<size_t>(row_value));
+        double dy = -1.0 * (row_value - static_cast<size_t>(row_value));
 
-        double x = xbin.getMidPoint()+xbin.getBinSize()*dx;
-        double y = ybin.getMidPoint()+ybin.getBinSize()*dy;
+        double x = xbin.getMidPoint() + xbin.getBinSize() * dx;
+        double y = ybin.getMidPoint() + ybin.getBinSize() * dy;
 
         result.push_back(std::make_pair(x, y));
     }
diff --git a/Core/Tools/SysUtils.cpp b/Core/Tools/SysUtils.cpp
index b2c1c8eea9b..3d89e0a1c4e 100644
--- a/Core/Tools/SysUtils.cpp
+++ b/Core/Tools/SysUtils.cpp
@@ -35,20 +35,20 @@ void SysUtils::enableFloatingPointExceptions()
 #ifdef DEBUG_FPE
 #ifndef _WIN32
     std::cout << "SysUtils::EnableFloatingPointExceptions() -> "
-        "Enabling floating point exception debugging\n";
+                 "Enabling floating point exception debugging\n";
     feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
 //    feenableexcept(-1);
 #endif // _WIN32
 #else
     std::cout << "SysUtils::EnableFloatingPointExceptions() -> "
-        "Can't enable floating point exceptions. Available in debug mode only.\n";
+                 "Can't enable floating point exceptions. Available in debug mode only.\n";
 #endif
 }
 
 std::string SysUtils::getenv(const std::string& name)
 {
-    if(char* c = std::getenv(name.c_str()))
-       return std::string(c);
+    if (char* c = std::getenv(name.c_str()))
+        return std::string(c);
     else
         return std::string();
 }
diff --git a/Core/Tools/SysUtils.h b/Core/Tools/SysUtils.h
index 70e2d455bb0..73e75602802 100644
--- a/Core/Tools/SysUtils.h
+++ b/Core/Tools/SysUtils.h
@@ -20,7 +20,8 @@
 
 //! Utility functions getCurrentDateAndTime, enableFloatingPointExceptions.
 
-namespace SysUtils {
+namespace SysUtils
+{
 
 BA_CORE_API_ std::string getCurrentDateAndTime();
 
diff --git a/Core/Tools/fp_exception_glibc_extension.c b/Core/Tools/fp_exception_glibc_extension.c
index b6c75739407..7c97d4d8c87 100644
--- a/Core/Tools/fp_exception_glibc_extension.c
+++ b/Core/Tools/fp_exception_glibc_extension.c
@@ -81,14 +81,14 @@ http://graphviz.sourcearchive.com/documentation/2.16/gvrender__pango_8c-source.h
 
 #include <fenv.h>
 
-#define DEFINED_PPC      (defined(__ppc__) || defined(__ppc64__))
-#define DEFINED_INTEL    (defined(__i386__) || defined(__x86_64__))
+#define DEFINED_PPC (defined(__ppc__) || defined(__ppc64__))
+#define DEFINED_INTEL (defined(__i386__) || defined(__x86_64__))
 
 #ifndef Q_OS_LINUX
 #if DEFINED_PPC
 
-#define FE_EXCEPT_SHIFT 22  // shift flags right to get masks
-#define FM_ALL_EXCEPT    FE_ALL_EXCEPT >> FE_EXCEPT_SHIFT
+#define FE_EXCEPT_SHIFT 22 // shift flags right to get masks
+#define FM_ALL_EXCEPT FE_ALL_EXCEPT >> FE_EXCEPT_SHIFT
 
 /* GNU C Library:
 http://www.gnu.org/software/libc/manual/html_node/Control-Functions.html
@@ -108,96 +108,91 @@ http://www.gnu.org/software/libc/manual/html_node/Control-Functions.html
    to suggest that it's the mask corresponding to bits in
    excepts that is returned.
 */
-int
-fegetexcept (void)
+int fegetexcept(void)
 {
-  static fenv_t fenv;
+    static fenv_t fenv;
 
-  return ( fegetenv (&fenv) ? -1 :
-    (
-      ( fenv&  (FM_ALL_EXCEPT) ) << FE_EXCEPT_SHIFT )
-    );
+    return (fegetenv(&fenv) ? -1 : ((fenv & (FM_ALL_EXCEPT)) << FE_EXCEPT_SHIFT));
 }
 
-int
-feenableexcept (unsigned int excepts)
+int feenableexcept(unsigned int excepts)
 {
-  static fenv_t fenv;
-  unsigned int new_excepts = (excepts&  FE_ALL_EXCEPT) >> FE_EXCEPT_SHIFT,
-               old_excepts;  // all previous masks
+    static fenv_t fenv;
+    unsigned int new_excepts = (excepts & FE_ALL_EXCEPT) >> FE_EXCEPT_SHIFT,
+                 old_excepts; // all previous masks
 
-  if ( fegetenv (&fenv) ) return -1;
-  old_excepts = (fenv&  FM_ALL_EXCEPT) << FE_EXCEPT_SHIFT;
+    if (fegetenv(&fenv))
+        return -1;
+    old_excepts = (fenv & FM_ALL_EXCEPT) << FE_EXCEPT_SHIFT;
 
-  fenv = (fenv&  ~new_excepts) | new_excepts;
-  return ( fesetenv (&fenv) ? -1 : old_excepts );
+    fenv = (fenv & ~new_excepts) | new_excepts;
+    return (fesetenv(&fenv) ? -1 : old_excepts);
 }
 
-int
-fedisableexcept (unsigned int excepts)
+int fedisableexcept(unsigned int excepts)
 {
-  static fenv_t fenv;
-  unsigned int still_on = ~( (excepts&  FE_ALL_EXCEPT) >> FE_EXCEPT_SHIFT ),
-               old_excepts;  // previous masks
+    static fenv_t fenv;
+    unsigned int still_on = ~((excepts & FE_ALL_EXCEPT) >> FE_EXCEPT_SHIFT),
+                 old_excepts; // previous masks
 
-  if ( fegetenv (&fenv) ) return -1;
-  old_excepts = (fenv&  FM_ALL_EXCEPT) << FE_EXCEPT_SHIFT;
+    if (fegetenv(&fenv))
+        return -1;
+    old_excepts = (fenv & FM_ALL_EXCEPT) << FE_EXCEPT_SHIFT;
 
-  fenv& = still_on;
-  return ( fesetenv (&fenv) ? -1 : old_excepts );
+    fenv& = still_on;
+    return (fesetenv(&fenv) ? -1 : old_excepts);
 }
 
 #elif DEFINED_INTEL
 
-int
-fegetexcept (void)
+int fegetexcept(void)
 {
-  static fenv_t fenv;
+    static fenv_t fenv;
 
-  return fegetenv (&fenv) ? -1 : (fenv.__control&  FE_ALL_EXCEPT);
+    return fegetenv(&fenv) ? -1 : (fenv.__control & FE_ALL_EXCEPT);
 }
 
-int
-feenableexcept (unsigned int excepts)
+int feenableexcept(unsigned int excepts)
 {
-  static fenv_t fenv;
-  unsigned int new_excepts = excepts&  FE_ALL_EXCEPT,
-               old_excepts;  // previous masks
+    static fenv_t fenv;
+    unsigned int new_excepts = excepts & FE_ALL_EXCEPT,
+                 old_excepts; // previous masks
 
-  if ( fegetenv (&fenv) ) return -1;
-  old_excepts = fenv.__control&  FE_ALL_EXCEPT;
+    if (fegetenv(&fenv))
+        return -1;
+    old_excepts = fenv.__control & FE_ALL_EXCEPT;
 
-  // unmask
-  fenv.__control &= ~new_excepts;
-  fenv.__mxcsr   &= ~(new_excepts << 7);
+    // unmask
+    fenv.__control &= ~new_excepts;
+    fenv.__mxcsr &= ~(new_excepts << 7);
 
-  return ( fesetenv (&fenv) ? -1 : old_excepts );
+    return (fesetenv(&fenv) ? -1 : old_excepts);
 }
 
-int
-fedisableexcept (unsigned int excepts)
+int fedisableexcept(unsigned int excepts)
 {
-  static fenv_t fenv;
-  unsigned int new_excepts = excepts&  FE_ALL_EXCEPT,
-               old_excepts;  // all previous masks
+    static fenv_t fenv;
+    unsigned int new_excepts = excepts & FE_ALL_EXCEPT,
+                 old_excepts; // all previous masks
 
-  if ( fegetenv (&fenv) ) return -1;
-  old_excepts = fenv.__control&  FE_ALL_EXCEPT;
+    if (fegetenv(&fenv))
+        return -1;
+    old_excepts = fenv.__control & FE_ALL_EXCEPT;
 
-  // mask
-  fenv.__control |= new_excepts;
-  fenv.__mxcsr   |= new_excepts << 7;
+    // mask
+    fenv.__control |= new_excepts;
+    fenv.__mxcsr |= new_excepts << 7;
 
-  return ( fesetenv (&fenv) ? -1 : old_excepts );
+    return (fesetenv(&fenv) ? -1 : old_excepts);
 }
 
-#endif  // PPC or INTEL enabling
-#endif  // not Q_OS_LINUX
+#endif // PPC or INTEL enabling
+#endif // not Q_OS_LINUX
 
 #if DEFINED_PPC
 
-#define getfpscr(x)    asm volatile ("mffs %0" : "=f" (x));
-#define setfpscr(x)    asm volatile ("mtfsf 255,%0" : : "f" (x));
+#define getfpscr(x) asm volatile("mffs %0" : "=f"(x));
+#define setfpscr(x) asm volatile("mtfsf 255,%0" : : "f"(x));
 
 typedef union {
     struct {
@@ -207,31 +202,35 @@ typedef union {
     double d;
 } hexdouble;
 
-#endif  // DEFINED_PPC
+#endif // DEFINED_PPC
 
 #if DEFINED_INTEL
 
 // x87 fpu
-#define getx87cr(x)    asm ("fnstcw %0" : "=m" (x));
-#define setx87cr(x)    asm ("fldcw %0"  : "=m" (x));
-#define getx87sr(x)    asm ("fnstsw %0" : "=m" (x));
+#define getx87cr(x) asm("fnstcw %0" : "=m"(x));
+#define setx87cr(x) asm("fldcw %0" : "=m"(x));
+#define getx87sr(x) asm("fnstsw %0" : "=m"(x));
 
 // SIMD, gcc with Intel Core 2 Duo uses SSE2(4)
-#define getmxcsr(x)    asm ("stmxcsr %0" : "=m" (x));
-#define setmxcsr(x)    asm ("ldmxcsr %0" : "=m" (x));
+#define getmxcsr(x) asm("stmxcsr %0" : "=m"(x));
+#define setmxcsr(x) asm("ldmxcsr %0" : "=m"(x));
 
-#endif  // DEFINED_INTEL
+#endif // DEFINED_INTEL
 
 #include <signal.h>
-#include <stdio.h>   // printf()
-#include <stdlib.h>  // abort(), exit()
-
-static const char *fe_code_name[] = {
-  "FPE_NOOP",
-  "FPE_FLTDIV", "FPE_FLTINV", "FPE_FLTOVF", "FPE_FLTUND",
-  "FPE_FLTRES", "FPE_FLTSUB", "FPE_INTDIV", "FPE_INTOVF"
-  "FPE_UNKNOWN"
-};
+#include <stdio.h>  // printf()
+#include <stdlib.h> // abort(), exit()
+
+static const char* fe_code_name[] = {"FPE_NOOP",
+                                     "FPE_FLTDIV",
+                                     "FPE_FLTINV",
+                                     "FPE_FLTOVF",
+                                     "FPE_FLTUND",
+                                     "FPE_FLTRES",
+                                     "FPE_FLTSUB",
+                                     "FPE_INTDIV",
+                                     "FPE_INTOVF"
+                                     "FPE_UNKNOWN"};
 
 /* SAMPLE ALTERNATE FP EXCEPTION HANDLER
 
@@ -247,60 +246,75 @@ static const char *fe_code_name[] = {
        fpu (but not the SIMD unit, nor the ppc)
      * imprecision of interrupts from system software
 */
-void
-fhdl ( int sig, siginfo_t *sip, ucontext_t *scp )
+void fhdl(int sig, siginfo_t* sip, ucontext_t* scp)
 {
-  (void)scp;
-  int fe_code = sip->si_code;
-  unsigned int excepts = fetestexcept (FE_ALL_EXCEPT);
-
-  switch (fe_code)
-  {
-#ifdef FPE_NOOP  // occurs in OS X
-    case FPE_NOOP:   fe_code = 0; break;
+    (void)scp;
+    int fe_code = sip->si_code;
+    unsigned int excepts = fetestexcept(FE_ALL_EXCEPT);
+
+    switch (fe_code) {
+#ifdef FPE_NOOP // occurs in OS X
+    case FPE_NOOP:
+        fe_code = 0;
+        break;
 #endif
-    case FPE_FLTDIV: fe_code = 1; break; // divideByZero
-    case FPE_FLTINV: fe_code = 2; break; // invalid
-    case FPE_FLTOVF: fe_code = 3; break; // overflow
-    case FPE_FLTUND: fe_code = 4; break; // underflow
-    case FPE_FLTRES: fe_code = 5; break; // inexact
-    case FPE_FLTSUB: fe_code = 6; break; // invalid
-    case FPE_INTDIV: fe_code = 7; break; // overflow
-    case FPE_INTOVF: fe_code = 8; break; // underflow
-            default: fe_code = 9;
-   }
-
-  if ( sig == SIGFPE )
-  {
+    case FPE_FLTDIV:
+        fe_code = 1;
+        break; // divideByZero
+    case FPE_FLTINV:
+        fe_code = 2;
+        break; // invalid
+    case FPE_FLTOVF:
+        fe_code = 3;
+        break; // overflow
+    case FPE_FLTUND:
+        fe_code = 4;
+        break; // underflow
+    case FPE_FLTRES:
+        fe_code = 5;
+        break; // inexact
+    case FPE_FLTSUB:
+        fe_code = 6;
+        break; // invalid
+    case FPE_INTDIV:
+        fe_code = 7;
+        break; // overflow
+    case FPE_INTOVF:
+        fe_code = 8;
+        break; // underflow
+    default:
+        fe_code = 9;
+    }
+
+    if (sig == SIGFPE) {
 #if DEFINED_INTEL
-    unsigned short x87cr,x87sr;
-    unsigned int mxcsr;
-
-    getx87cr (x87cr);
-    getx87sr (x87sr);
-    getmxcsr (mxcsr);
-    printf ("X87CR:   0x%04X\n", x87cr);
-    printf ("X87SR:   0x%04X\n", x87sr);
-    printf ("MXCSR:   0x%08X\n", mxcsr);
+        unsigned short x87cr, x87sr;
+        unsigned int mxcsr;
+
+        getx87cr(x87cr);
+        getx87sr(x87sr);
+        getmxcsr(mxcsr);
+        printf("X87CR:   0x%04X\n", x87cr);
+        printf("X87SR:   0x%04X\n", x87sr);
+        printf("MXCSR:   0x%08X\n", mxcsr);
 #endif
 
 #if DEFINED_PPC
-   hexdouble t;
+        hexdouble t;
 
-   getfpscr (t.d);
-   printf ("FPSCR:   0x%08X\n", t.i.lo);
+        getfpscr(t.d);
+        printf("FPSCR:   0x%08X\n", t.i.lo);
 #endif
 
-    printf ("signal:  SIGFPE with code %s\n", fe_code_name[fe_code]);
-    printf ("invalid flag:    0x%04X\n", excepts&  FE_INVALID);
-    printf ("divByZero flag:  0x%04X\n", excepts&  FE_DIVBYZERO);
-  }
-  else printf ("Signal is not SIGFPE, it's %i.\n", sig);
+        printf("signal:  SIGFPE with code %s\n", fe_code_name[fe_code]);
+        printf("invalid flag:    0x%04X\n", excepts & FE_INVALID);
+        printf("divByZero flag:  0x%04X\n", excepts & FE_DIVBYZERO);
+    } else
+        printf("Signal is not SIGFPE, it's %i.\n", sig);
 
-  abort();
+    abort();
 }
 
-
 /*
 int main (int argc, char **argv)
 {
diff --git a/Core/Tools/fp_exception_glibc_extension.h b/Core/Tools/fp_exception_glibc_extension.h
index 51415d15fa4..721880b29d4 100644
--- a/Core/Tools/fp_exception_glibc_extension.h
+++ b/Core/Tools/fp_exception_glibc_extension.h
@@ -1,5 +1,5 @@
 // ************************************************************************** //
-//                                                                         
+//
 //! @file      Core/Tools/fp_exception_glibc_extension.h
 //! @brief     glibc floating point extension replacement for OS X.
 //
@@ -16,49 +16,46 @@
 #ifdef __cplusplus
 #endif
 
-  /* GNU C Library:
-     http://www.gnu.org/software/libc/manual/html_node/Control-Functions.html
+/* GNU C Library:
+   http://www.gnu.org/software/libc/manual/html_node/Control-Functions.html
+
+   - Function: int fegetexcept (int excepts)
 
-     - Function: int fegetexcept (int excepts)
+   The function returns a bitmask of all currently enabled
+   exceptions.  It returns -1 in case of failure.
 
-     The function returns a bitmask of all currently enabled
-     exceptions.  It returns -1 in case of failure.
- 
-     The excepts argument appears in other functions in fenv.h,
-     and corresponds to the FE_xxx exception flag constants.  It
-     is unclear whether the bitmask is for the flags or the masks.
-     We return that for the flags, which corresponds to the
-     excepts argument in feenableexcept(excepts) and
-     fedisableexcept(excepts).  In GNU/Linux the argument is void,
-     and that's what we implement.  Linux "man fegetenv" appears
-     to suggest that it's the mask corresponding to bits in
-     excepts that is returned.
-  */
-  int fegetexcept (void) ;
-  int feenableexcept (unsigned int excepts) ;
-  int fedisableexcept (unsigned int excepts) ;
+   The excepts argument appears in other functions in fenv.h,
+   and corresponds to the FE_xxx exception flag constants.  It
+   is unclear whether the bitmask is for the flags or the masks.
+   We return that for the flags, which corresponds to the
+   excepts argument in feenableexcept(excepts) and
+   fedisableexcept(excepts).  In GNU/Linux the argument is void,
+   and that's what we implement.  Linux "man fegetenv" appears
+   to suggest that it's the mask corresponding to bits in
+   excepts that is returned.
+*/
+int fegetexcept(void);
+int feenableexcept(unsigned int excepts);
+int fedisableexcept(unsigned int excepts);
 
-  /* SAMPLE ALTERNATE FP EXCEPTION HANDLER
+/* SAMPLE ALTERNATE FP EXCEPTION HANDLER
 
-     The sample handler just reports information about the
-     exception that invoked it, and aborts.  It makes no attempt
-     to restore state and return to the application.
+   The sample handler just reports information about the
+   exception that invoked it, and aborts.  It makes no attempt
+   to restore state and return to the application.
 
-     More sophisticated handling would have to confront at least
-     these issues:
+   More sophisticated handling would have to confront at least
+   these issues:
 
-     * interface to the system context for restoring state
-     * imprecision of interrupts from hardware for the intel x87
-     fpu (but not the SIMD unit, nor the ppc)
-     * imprecision of interrupts from system software
-     */
-  void fhdl ( int sig, siginfo_t *sip, ucontext_t *scp ) ;
+   * interface to the system context for restoring state
+   * imprecision of interrupts from hardware for the intel x87
+   fpu (but not the SIMD unit, nor the ppc)
+   * imprecision of interrupts from system software
+   */
+void fhdl(int sig, siginfo_t* sip, ucontext_t* scp);
 
 #ifdef __cplusplus
 }
 #endif
 
-
 #endif // FP_EXCEPTION_GLIBC_EXTENSION_H
-
-
diff --git a/Core/Tools/w32pragma.h b/Core/Tools/w32pragma.h
index d544e86162c..09ba0ce27c5 100644
--- a/Core/Tools/w32pragma.h
+++ b/Core/Tools/w32pragma.h
@@ -29,57 +29,55 @@
 #ifdef _WIN32
 
 /* Disable warning about truncated symboles (usually coming from stl) */
-#pragma warning (disable: 4786)
+#pragma warning(disable : 4786)
 /* Disable warning about inconsistent dll linkage (dllexport assumed) */
-#pragma warning (disable: 4273)
+#pragma warning(disable : 4273)
 /* "no suitable definition provided for explicit template instantiation"*/
-#pragma warning (disable: 4661)
+#pragma warning(disable : 4661)
 /* "deprecated, use ISO C++ conformant name" */
-#pragma warning (disable: 4996)
+#pragma warning(disable : 4996)
 /* "new behavior: elements default initialized" */
-#pragma warning (disable: 4351)
+#pragma warning(disable : 4351)
 /* local static not thread safe */
-#pragma warning (disable: 4640)
+#pragma warning(disable : 4640)
 /*forcing int to bool (performance warning) */
-#pragma warning (disable: 4800)
+#pragma warning(disable : 4800)
 /* truncation from double to float */
-#pragma warning (disable: 4305)
+#pragma warning(disable : 4305)
 /* signed unsigned mismatch */
-#pragma warning (disable: 4018)
+#pragma warning(disable : 4018)
 /* truncation of constant value */
-#pragma warning (disable: 4309)
+#pragma warning(disable : 4309)
 /* check op precedence for error */
-#pragma warning (disable: 4554)
+#pragma warning(disable : 4554)
 /* qualifier applied to reference type; ignored */
-#pragma warning (disable: 4181)
+#pragma warning(disable : 4181)
 /* /GS can not buffer overrun protect parameters and locals: function not optimized */
-#pragma warning (disable: 4748)
+#pragma warning(disable : 4748)
 /* function(): resolved overload was found by argument-dependent lookup */
-#pragma warning (disable: 4675)
+#pragma warning(disable : 4675)
 /* X needs to have dll-interface to be used by clients of class Y */
-#pragma warning (disable: 4251)
+#pragma warning(disable : 4251)
 /* decorated name length exceeded, name was truncated */
-#pragma warning (disable: 4503)
+#pragma warning(disable : 4503)
 
 /* function is hidden */
-#pragma warning (3: 4266)
+#pragma warning(3 : 4266)
 /* loop control variable is used outside the for-loop scope */
-#pragma warning (3: 4289)
+#pragma warning(3 : 4289)
 
 /* no override available for virtual member function from base */
-#pragma warning(disable: 4266)
-
-
+#pragma warning(disable : 4266)
 
 #define WIN32 1
 #define _WINDOWS 1
 #define WINVER 0x0400
-#define CRTAPI1 _cdecl 
+#define CRTAPI1 _cdecl
 #define CRTAPI2 _cdecl
 #if defined(_M_IX86)
-#  define _X86_ 1
+#define _X86_ 1
 #endif
-// #define _DLL  - used to be explicitly defined, 
+// #define _DLL  - used to be explicitly defined,
 // but it's implicitely defined via /MD(d)
 #define G__REDIRECTIO 1
 #define G__SHAREDLIB 1
@@ -88,7 +86,7 @@
 #define G__WIN32 1
 
 #if (_MSC_VER >= 1310)
-#  define G__NEWSTDHEADER 1
+#define G__NEWSTDHEADER 1
 #endif
 
 #if (_MSC_VER >= 1400)
diff --git a/Core/Vector/BasicVector3D.cpp b/Core/Vector/BasicVector3D.cpp
index 6e70871e517..1e1d57ea568 100644
--- a/Core/Vector/BasicVector3D.cpp
+++ b/Core/Vector/BasicVector3D.cpp
@@ -24,11 +24,9 @@ typedef std::complex<double> complex_t;
 
 BasicVector3D<double> vecOfLambdaAlphaPhi(double _lambda, double _alpha, double _phi)
 {
-    double k = M_TWOPI/_lambda;
-    return BasicVector3D<double>(
-        k*std::cos(_alpha) * std::cos(_phi),
-        -k*std::cos(_alpha) * std::sin(_phi),
-        k*std::sin(_alpha) );
+    double k = M_TWOPI / _lambda;
+    return BasicVector3D<double>(k * std::cos(_alpha) * std::cos(_phi),
+                                 -k * std::cos(_alpha) * std::sin(_phi), k * std::sin(_alpha));
 }
 
 // -----------------------------------------------------------------------------
@@ -36,83 +34,72 @@ BasicVector3D<double> vecOfLambdaAlphaPhi(double _lambda, double _alpha, double
 // -----------------------------------------------------------------------------
 
 //! Returns complex conjugate vector
-template<>
-BasicVector3D<double> BasicVector3D<double>::conj() const
+template <> BasicVector3D<double> BasicVector3D<double>::conj() const
 {
     return *this;
 }
 
-template<>
-BasicVector3D<complex_t> BasicVector3D<complex_t >::conj() const
+template <> BasicVector3D<complex_t> BasicVector3D<complex_t>::conj() const
 {
-    return BasicVector3D<complex_t >(std::conj(v_[0]), std::conj(v_[1]), std::conj(v_[2]));
+    return BasicVector3D<complex_t>(std::conj(v_[0]), std::conj(v_[1]), std::conj(v_[2]));
 }
 
 //! Returns azimuth angle.
-template<>
-double BasicVector3D<double>::phi() const
+template <> double BasicVector3D<double>::phi() const
 {
-    return x() == 0.0 && y() == 0.0 ? 0.0 : std::atan2(-y(),x());
+    return x() == 0.0 && y() == 0.0 ? 0.0 : std::atan2(-y(), x());
 }
 
 //! Returns polar angle.
-template<>
-double BasicVector3D<double>::theta() const
+template <> double BasicVector3D<double>::theta() const
 {
-    return x() == 0.0 && y() == 0.0 && z() == 0.0 ? 0.0 : std::atan2(magxy(),z());
+    return x() == 0.0 && y() == 0.0 && z() == 0.0 ? 0.0 : std::atan2(magxy(), z());
 }
 
 //! Returns cosine of polar angle.
-template<>
-double BasicVector3D<double>::cosTheta() const
+template <> double BasicVector3D<double>::cosTheta() const
 {
-    return mag() == 0 ? 1 : z()/mag();
+    return mag() == 0 ? 1 : z() / mag();
 }
 
 //! Returns squared sine of polar angle.
-template<>
-double BasicVector3D<double>::sin2Theta() const
+template <> double BasicVector3D<double>::sin2Theta() const
 {
-    return mag2() == 0 ? 0 : magxy2()/mag2();
+    return mag2() == 0 ? 0 : magxy2() / mag2();
 }
 
 //! Returns this, trivially converted to complex type.
-template<>
-BasicVector3D<complex_t> BasicVector3D<double>::complex() const
+template <> BasicVector3D<complex_t> BasicVector3D<double>::complex() const
 {
-    return BasicVector3D<complex_t>( v_[0], v_[1], v_[2] );
+    return BasicVector3D<complex_t>(v_[0], v_[1], v_[2]);
 }
 
 //! Returns real parts.
-template<>
-BasicVector3D<double> BasicVector3D<double>::real() const
+template <> BasicVector3D<double> BasicVector3D<double>::real() const
 {
     return *this;
 }
 
-template<>
-BasicVector3D<double> BasicVector3D<complex_t>::real() const
+template <> BasicVector3D<double> BasicVector3D<complex_t>::real() const
 {
-    return BasicVector3D<double>( v_[0].real(), v_[1].real(), v_[2].real() );
+    return BasicVector3D<double>(v_[0].real(), v_[1].real(), v_[2].real());
 }
 
 //! Returns unit vector in direction of this. Throws for null vector.
-template<>
-BasicVector3D<double> BasicVector3D<double>::unit() const
+template <> BasicVector3D<double> BasicVector3D<double>::unit() const
 {
     double len = mag();
-    if ( len==0.0 )
+    if (len == 0.0)
         throw Exceptions::DivisionByZeroException("Cannot normalize zero vector");
-    return BasicVector3D<double>(x()/len, y()/len, z()/len);
+    return BasicVector3D<double>(x() / len, y() / len, z() / len);
 }
 
-template<>
-BasicVector3D<complex_t> BasicVector3D<complex_t>::unit() const
+template <> BasicVector3D<complex_t> BasicVector3D<complex_t>::unit() const
 {
     double len = mag();
-    if ( len==0.0 )
+    if (len == 0.0)
         throw Exceptions::DivisionByZeroException("Cannot normalize zero vector");
-    return BasicVector3D<complex_t>(x()/len, y()/len, z()/len);
+    return BasicVector3D<complex_t>(x() / len, y() / len, z() / len);
 }
 
 // -----------------------------------------------------------------------------
@@ -120,15 +107,16 @@ BasicVector3D<complex_t> BasicVector3D<complex_t>::unit() const
 // -----------------------------------------------------------------------------
 
 //! Returns angle with respect to another vector.
-template<>
-double BasicVector3D<double>::angle(const BasicVector3D<double>& v) const
+template <> double BasicVector3D<double>::angle(const BasicVector3D<double>& v) const
 {
     double cosa = 0;
-    double ptot = mag()*v.mag();
-    if(ptot > 0) {
-        cosa = dot(v)/ptot;
-        if(cosa >  1) cosa =  1;
-        if(cosa < -1) cosa = -1;
+    double ptot = mag() * v.mag();
+    if (ptot > 0) {
+        cosa = dot(v) / ptot;
+        if (cosa > 1)
+            cosa = 1;
+        if (cosa < -1)
+            cosa = -1;
     }
     return std::acos(cosa);
 }
diff --git a/Core/Vector/BasicVector3D.h b/Core/Vector/BasicVector3D.h
index 16dd6da3150..adf83f532e7 100644
--- a/Core/Vector/BasicVector3D.h
+++ b/Core/Vector/BasicVector3D.h
@@ -25,8 +25,8 @@
 //! Three-dimensional vector template, for use with integer, double, or complex components.
 //! @ingroup tools_internal
 
-template<class T>
-class BasicVector3D {
+template <class T> class BasicVector3D
+{
 private:
     T v_[3];
 
@@ -36,10 +36,20 @@ public:
     // -------------------------------------------------------------------------
 
     //! Default constructor.
-    BasicVector3D() { v_[0] = 0.0; v_[1] = 0.0; v_[2] = 0.0; }
+    BasicVector3D()
+    {
+        v_[0] = 0.0;
+        v_[1] = 0.0;
+        v_[2] = 0.0;
+    }
 
     //! Constructor from cartesian components.
-    BasicVector3D(const T x1, const T y1, const T z1) { v_[0] = x1; v_[1] = y1; v_[2] = z1; }
+    BasicVector3D(const T x1, const T y1, const T z1)
+    {
+        v_[0] = x1;
+        v_[1] = y1;
+        v_[2] = z1;
+    }
 
     // -------------------------------------------------------------------------
     // Component access
@@ -59,37 +69,54 @@ public:
     T z() const { return v_[2]; }
 
     //! Sets x-component in cartesian coordinate system.
-    void setX(const T&a) { v_[0] = a; }
+    void setX(const T& a) { v_[0] = a; }
     //! Sets y-component in cartesian coordinate system.
-    void setY(const T&a) { v_[1] = a; }
+    void setY(const T& a) { v_[1] = a; }
     //! Sets z-component in cartesian coordinate system.
-    void setZ(const T&a) { v_[2] = a; }
+    void setZ(const T& a) { v_[2] = a; }
 
     // -------------------------------------------------------------------------
     // In-place operations
     // -------------------------------------------------------------------------
 
     //! Adds other vector to this, and returns result.
-    BasicVector3D<T>& operator+=(const BasicVector3D<T>& v) {
-        v_[0] += v.v_[0]; v_[1] += v.v_[1]; v_[2] += v.v_[2]; return *this; }
+    BasicVector3D<T>& operator+=(const BasicVector3D<T>& v)
+    {
+        v_[0] += v.v_[0];
+        v_[1] += v.v_[1];
+        v_[2] += v.v_[2];
+        return *this;
+    }
 
     //! Subtracts other vector from this, and returns result.
-    BasicVector3D<T>& operator-=(const BasicVector3D<T>& v) {
-        v_[0] -= v.v_[0]; v_[1] -= v.v_[1]; v_[2] -= v.v_[2]; return *this; }
-
+    BasicVector3D<T>& operator-=(const BasicVector3D<T>& v)
+    {
+        v_[0] -= v.v_[0];
+        v_[1] -= v.v_[1];
+        v_[2] -= v.v_[2];
+        return *this;
+    }
 
     //! Multiplies this with a scalar, and returns result.
 #ifndef SWIG
-    template<class U>
-    auto operator*=(U a) -> BasicVector3D<decltype(this->x()*a)>& {
-        v_[0] *= a; v_[1] *= a; v_[2] *= a; return *this; }
+    template <class U> auto operator*=(U a) -> BasicVector3D<decltype(this->x() * a)>&
+    {
+        v_[0] *= a;
+        v_[1] *= a;
+        v_[2] *= a;
+        return *this;
+    }
 #endif // SWIG
 
     //! Divides this by a scalar, and returns result.
 #ifndef SWIG
-    template<class U>
-    auto operator/=(U a) -> BasicVector3D<decltype(this->x()*a)>& {
-        v_[0] /= a; v_[1] /= a; v_[2] /= a; return *this; }
+    template <class U> auto operator/=(U a) -> BasicVector3D<decltype(this->x() * a)>&
+    {
+        v_[0] /= a;
+        v_[1] /= a;
+        v_[2] /= a;
+        return *this;
+    }
 #endif // SWIG
 
     // -------------------------------------------------------------------------
@@ -138,22 +165,23 @@ public:
 
     //! Returns dot product of vectors (antilinear in the first [=self] argument).
 #ifndef SWIG
-    template<class U>
-    auto dot(const BasicVector3D<U>& v) const -> decltype(this->x()*v.x());
+    template <class U> auto dot(const BasicVector3D<U>& v) const -> decltype(this->x() * v.x());
 #endif // SWIG
 
     //! Returns cross product of vectors (linear in both arguments).
 #ifndef SWIG
-    template<class U>
-    auto cross(const BasicVector3D<U>& v) const -> BasicVector3D<decltype(this->x()*v.x())>;
+    template <class U>
+    auto cross(const BasicVector3D<U>& v) const -> BasicVector3D<decltype(this->x() * v.x())>;
 #endif // SWIG
 
     //! Returns angle with respect to another vector.
     double angle(const BasicVector3D<T>& v) const;
 
     //! Returns projection of this onto other vector: (this*v)*v/|v|^2.
-    inline BasicVector3D<T> project(const BasicVector3D<T>& v) const {
-        return dot(v)*v/v.mag2(); }
+    inline BasicVector3D<T> project(const BasicVector3D<T>& v) const
+    {
+        return dot(v) * v / v.mag2();
+    }
 
     // -------------------------------------------------------------------------
     // Rotations
@@ -164,8 +192,9 @@ public:
     //! Returns result of rotation around y-axis.
     BasicVector3D<T> rotatedY(double a) const;
     //! Returns result of rotation around z-axis.
-    BasicVector3D<T> rotatedZ(double a) const {
-        return BasicVector3D<T>( cos(a)*x()+sin(a)*y(), -sin(a)*x()+cos(a)*y(), z() );
+    BasicVector3D<T> rotatedZ(double a) const
+    {
+        return BasicVector3D<T>(cos(a) * x() + sin(a) * y(), -sin(a) * x() + cos(a) * y(), z());
     }
     //! Returns result of rotation around the axis specified by another vector.
     BasicVector3D<T> rotated(double a, const BasicVector3D<T>& v) const;
@@ -177,10 +206,10 @@ public:
 
 //! Output to stream.
 //! @relates BasicVector3D
-template <class T>
-std::ostream&
-operator<<(std::ostream& os, const BasicVector3D<T>& a)
-{ return os << "(" << a.x() << "," << a.y() << "," << a.z() << ")"; }
+template <class T> std::ostream& operator<<(std::ostream& os, const BasicVector3D<T>& a)
+{
+    return os << "(" << a.x() << "," << a.y() << "," << a.z() << ")";
+}
 
 // -----------------------------------------------------------------------------
 // Unary operators
@@ -188,15 +217,17 @@ operator<<(std::ostream& os, const BasicVector3D<T>& a)
 
 //! Unary plus.
 //! @relates BasicVector3D
-template <class T>
-inline BasicVector3D<T> operator+ (const BasicVector3D<T>& v)
-{ return v; }
+template <class T> inline BasicVector3D<T> operator+(const BasicVector3D<T>& v)
+{
+    return v;
+}
 
 //! Unary minus.
 //! @relates BasicVector3D
-template <class T>
-inline BasicVector3D<T> operator- (const BasicVector3D<T>& v)
-{ return BasicVector3D<T>(-v.x(), -v.y(), -v.z()); }
+template <class T> inline BasicVector3D<T> operator-(const BasicVector3D<T>& v)
+{
+    return BasicVector3D<T>(-v.x(), -v.y(), -v.z());
+}
 
 // -----------------------------------------------------------------------------
 // Binary operators
@@ -206,28 +237,36 @@ inline BasicVector3D<T> operator- (const BasicVector3D<T>& v)
 //! @relates BasicVector3D
 template <class T>
 inline BasicVector3D<T> operator+(const BasicVector3D<T>& a, const BasicVector3D<T>& b)
-{ return BasicVector3D<T>(a.x()+b.x(), a.y()+b.y(), a.z()+b.z()); }
+{
+    return BasicVector3D<T>(a.x() + b.x(), a.y() + b.y(), a.z() + b.z());
+}
 
 //! Subtraction of two vectors.
 //! @relates BasicVector3D
 template <class T>
 inline BasicVector3D<T> operator-(const BasicVector3D<T>& a, const BasicVector3D<T>& b)
-{ return BasicVector3D<T>(a.x()-b.x(), a.y()-b.y(), a.z()-b.z()); }
+{
+    return BasicVector3D<T>(a.x() - b.x(), a.y() - b.y(), a.z() - b.z());
+}
 
 //! Multiplication vector by scalar.
 //! @relates BasicVector3D
 #ifndef SWIG
 template <class T, class U>
-inline auto operator* (const BasicVector3D<T>& v, const U a) -> BasicVector3D<decltype(v.x()*a)>
-{ return BasicVector3D<decltype(v.x()*a)>(v.x()*a, v.y()*a, v.z()*a); }
+inline auto operator*(const BasicVector3D<T>& v, const U a) -> BasicVector3D<decltype(v.x() * a)>
+{
+    return BasicVector3D<decltype(v.x() * a)>(v.x() * a, v.y() * a, v.z() * a);
+}
 #endif // SWIG
 
 //! Multiplication scalar by vector.
 //! @relates BasicVector3D
 #ifndef SWIG
 template <class T, class U>
-inline auto operator* (const U a, const BasicVector3D<T>& v) -> BasicVector3D<decltype(a*v.x())>
-{ return BasicVector3D<decltype(a*v.x())>(a*v.x(), a*v.y(), a*v.z()); }
+inline auto operator*(const U a, const BasicVector3D<T>& v) -> BasicVector3D<decltype(a * v.x())>
+{
+    return BasicVector3D<decltype(a * v.x())>(a * v.x(), a * v.y(), a * v.z());
+}
 #endif // SWIG
 
 // vector*vector not supported
@@ -237,21 +276,24 @@ inline auto operator* (const U a, const BasicVector3D<T>& v) -> BasicVector3D<de
 
 //! Division vector by scalar.
 //! @relates BasicVector3D
-template <class T, class U>
-inline BasicVector3D<T> operator/ (const BasicVector3D<T>& v, U a)
-{ return BasicVector3D<T>(v.x()/a, v.y()/a, v.z()/a); }
+template <class T, class U> inline BasicVector3D<T> operator/(const BasicVector3D<T>& v, U a)
+{
+    return BasicVector3D<T>(v.x() / a, v.y() / a, v.z() / a);
+}
 
 //! Comparison of two vectors for equality.
 //! @relates BasicVector3D
-template <class T>
-inline bool operator==(const BasicVector3D<T>& a, const BasicVector3D<T>& b)
-{ return (a.x()==b.x()&& a.y()==b.y()&& a.z()==b.z()); }
+template <class T> inline bool operator==(const BasicVector3D<T>& a, const BasicVector3D<T>& b)
+{
+    return (a.x() == b.x() && a.y() == b.y() && a.z() == b.z());
+}
 
 //! Comparison of two vectors for inequality.
 //! @relates BasicVector3D
-template <class T>
-inline bool operator!=(const BasicVector3D<T>& a, const BasicVector3D<T>& b)
-{ return (a.x()!=b.x() || a.y()!=b.y() || a.z()!=b.z()); }
+template <class T> inline bool operator!=(const BasicVector3D<T>& a, const BasicVector3D<T>& b)
+{
+    return (a.x() != b.x() || a.y() != b.y() || a.z() != b.z());
+}
 
 // -----------------------------------------------------------------------------
 // Quasi constructor
@@ -261,58 +303,57 @@ inline bool operator!=(const BasicVector3D<T>& a, const BasicVector3D<T>& b)
 //! Specifically needed for grazing-incidence scattering.
 BA_CORE_API_ BasicVector3D<double> vecOfLambdaAlphaPhi(double _lambda, double _alpha, double _phi);
 
-
 // =============================================================================
 // ?? for API generation ??
 // =============================================================================
 
 //! Returns dot product of (complex) vectors (antilinear in the first [=self] argument).
 #ifndef SWIG
-template<class T> template<class U>
-inline auto BasicVector3D<T>::dot(const BasicVector3D<U> &v) const
--> decltype(this->x()*v.x())
+template <class T>
+template <class U>
+inline auto BasicVector3D<T>::dot(const BasicVector3D<U>& v) const -> decltype(this->x() * v.x())
 {
     BasicVector3D<T> left_star = this->conj();
-    return left_star.x()*v.x() + left_star.y()*v.y() + left_star.z()*v.z();
+    return left_star.x() * v.x() + left_star.y() * v.y() + left_star.z() * v.z();
 }
 #endif // SWIG
 
 //! Returns cross product of (complex) vectors.
 #ifndef SWIG
-template<class T> template<class U>
+template <class T>
+template <class U>
 inline auto BasicVector3D<T>::cross(const BasicVector3D<U>& v) const
--> BasicVector3D<decltype(this->x()*v.x())>
+    -> BasicVector3D<decltype(this->x() * v.x())>
 {
-    return BasicVector3D<decltype(this->x()*v.x())>(y()*v.z()-v.y()*z(),
-                                                    z()*v.x()-v.z()*x(),
-                                                    x()*v.y()-v.x()*y());
+    return BasicVector3D<decltype(this->x() * v.x())>(
+        y() * v.z() - v.y() * z(), z() * v.x() - v.z() * x(), x() * v.y() - v.x() * y());
 }
 #endif // SWIG
 
-template<> BA_CORE_API_ BasicVector3D<double> BasicVector3D<double>::conj() const;
+template <> BA_CORE_API_ BasicVector3D<double> BasicVector3D<double>::conj() const;
 
-template<> BA_CORE_API_ BasicVector3D<std::complex<double>>
-    BasicVector3D<std::complex<double>>::conj() const;
+template <>
+BA_CORE_API_ BasicVector3D<std::complex<double>> BasicVector3D<std::complex<double>>::conj() const;
 
-template<> BA_CORE_API_ double BasicVector3D<double>::phi() const;
+template <> BA_CORE_API_ double BasicVector3D<double>::phi() const;
 
-template<> BA_CORE_API_ double BasicVector3D<double>::theta() const;
+template <> BA_CORE_API_ double BasicVector3D<double>::theta() const;
 
-template<> BA_CORE_API_ double BasicVector3D<double>::cosTheta() const;
+template <> BA_CORE_API_ double BasicVector3D<double>::cosTheta() const;
 
-template<> BA_CORE_API_ double BasicVector3D<double>::sin2Theta() const;
+template <> BA_CORE_API_ double BasicVector3D<double>::sin2Theta() const;
 
-template<> BA_CORE_API_ BasicVector3D<std::complex<double>> BasicVector3D<double>::complex() const;
+template <> BA_CORE_API_ BasicVector3D<std::complex<double>> BasicVector3D<double>::complex() const;
 
-template<> BA_CORE_API_ BasicVector3D<double> BasicVector3D<double>::real() const;
+template <> BA_CORE_API_ BasicVector3D<double> BasicVector3D<double>::real() const;
 
-template<> BA_CORE_API_ BasicVector3D<double> BasicVector3D<std::complex<double>>::real() const;
+template <> BA_CORE_API_ BasicVector3D<double> BasicVector3D<std::complex<double>>::real() const;
 
-template<> BA_CORE_API_ BasicVector3D<double> BasicVector3D<double>::unit() const;
+template <> BA_CORE_API_ BasicVector3D<double> BasicVector3D<double>::unit() const;
 
-template<> BA_CORE_API_ BasicVector3D<std::complex<double>>
-    BasicVector3D<std::complex<double>>::unit() const;
+template <>
+BA_CORE_API_ BasicVector3D<std::complex<double>> BasicVector3D<std::complex<double>>::unit() const;
 
-template<> BA_CORE_API_ double BasicVector3D<double>::angle(const BasicVector3D<double>& v) const;
+template <> BA_CORE_API_ double BasicVector3D<double>::angle(const BasicVector3D<double>& v) const;
 
 #endif // BASICVECTOR3D_H
diff --git a/Core/Vector/Transform3D.cpp b/Core/Vector/Transform3D.cpp
index fb18edd089a..f400dd6867e 100644
--- a/Core/Vector/Transform3D.cpp
+++ b/Core/Vector/Transform3D.cpp
@@ -15,15 +15,13 @@
 #include "Transform3D.h"
 #include <Eigen/LU>
 
-
 Transform3D::Transform3D()
 {
     m_matrix.setIdentity();
     m_inverse_matrix.setIdentity();
 }
 
-Transform3D::Transform3D(const Eigen::Matrix3d& matrix)
-    : m_matrix(matrix)
+Transform3D::Transform3D(const Eigen::Matrix3d& matrix) : m_matrix(matrix)
 {
     m_inverse_matrix = m_matrix.inverse();
 }
@@ -39,10 +37,10 @@ Transform3D Transform3D::createRotateX(double phi)
     double sine = std::sin(phi);
     Eigen::Matrix3d matrix;
     matrix.setIdentity();
-    matrix(1,1) = cosine;
-    matrix(1,2) = -sine;
-    matrix(2,1) = sine;
-    matrix(2,2) = cosine;
+    matrix(1, 1) = cosine;
+    matrix(1, 2) = -sine;
+    matrix(2, 1) = sine;
+    matrix(2, 2) = cosine;
     return Transform3D(matrix);
 }
 
@@ -52,10 +50,10 @@ Transform3D Transform3D::createRotateY(double phi)
     double sine = std::sin(phi);
     Eigen::Matrix3d matrix;
     matrix.setIdentity();
-    matrix(0,0) = cosine;
-    matrix(0,2) = sine;
-    matrix(2,0) = -sine;
-    matrix(2,2) = cosine;
+    matrix(0, 0) = cosine;
+    matrix(0, 2) = sine;
+    matrix(2, 0) = -sine;
+    matrix(2, 2) = cosine;
     return Transform3D(matrix);
 }
 
@@ -65,49 +63,47 @@ Transform3D Transform3D::createRotateZ(double phi)
     double sine = std::sin(phi);
     Eigen::Matrix3d matrix;
     matrix.setIdentity();
-    matrix(0,0) = cosine;
-    matrix(0,1) = -sine;
-    matrix(1,0) = sine;
-    matrix(1,1) = cosine;
+    matrix(0, 0) = cosine;
+    matrix(0, 1) = -sine;
+    matrix(1, 0) = sine;
+    matrix(1, 1) = cosine;
     return Transform3D(matrix);
 }
 
-Transform3D Transform3D::createRotateEuler(
-    double alpha, double beta, double gamma)
+Transform3D Transform3D::createRotateEuler(double alpha, double beta, double gamma)
 {
     Transform3D zrot = createRotateZ(alpha);
     Transform3D xrot = createRotateX(beta);
     Transform3D zrot2 = createRotateZ(gamma);
-    return zrot*xrot*zrot2;
+    return zrot * xrot * zrot2;
 }
 
-void Transform3D::calculateEulerAngles(
-    double *p_alpha, double *p_beta, double *p_gamma) const
+void Transform3D::calculateEulerAngles(double* p_alpha, double* p_beta, double* p_gamma) const
 {
-    *p_beta = std::acos(m_matrix(2,2));
+    *p_beta = std::acos(m_matrix(2, 2));
     // First check if second angle is zero or pi
-    if (std::abs(m_matrix(2,2))==1.0) {
-        *p_alpha = std::atan2(m_matrix(1,0), m_matrix(0,0));
+    if (std::abs(m_matrix(2, 2)) == 1.0) {
+        *p_alpha = std::atan2(m_matrix(1, 0), m_matrix(0, 0));
         *p_gamma = 0.0;
     } else {
-        *p_alpha = std::atan2(m_matrix(0,2), -m_matrix(1,2));
-        *p_gamma = std::atan2(m_matrix(2,0), m_matrix(2,1));
+        *p_alpha = std::atan2(m_matrix(0, 2), -m_matrix(1, 2));
+        *p_gamma = std::atan2(m_matrix(2, 0), m_matrix(2, 1));
     }
 }
 
 double Transform3D::calculateRotateXAngle() const
 {
-    return std::atan2(m_matrix(2,1), m_matrix(1,1));
+    return std::atan2(m_matrix(2, 1), m_matrix(1, 1));
 }
 
 double Transform3D::calculateRotateYAngle() const
 {
-    return std::atan2(m_matrix(0,2), m_matrix(2,2));
+    return std::atan2(m_matrix(0, 2), m_matrix(2, 2));
 }
 
 double Transform3D::calculateRotateZAngle() const
 {
-    return std::atan2(m_matrix(1,0), m_matrix(0,0));
+    return std::atan2(m_matrix(1, 0), m_matrix(0, 0));
 }
 
 Transform3D Transform3D::getInverse() const
@@ -116,8 +112,7 @@ Transform3D Transform3D::getInverse() const
     return result;
 }
 
-template <class ivector_t>
-ivector_t Transform3D::transformed(const ivector_t& v) const
+template <class ivector_t> ivector_t Transform3D::transformed(const ivector_t& v) const
 {
     auto x = m_matrix(0, 0) * v.x() + m_matrix(0, 1) * v.y() + m_matrix(0, 2) * v.z();
     auto y = m_matrix(1, 0) * v.x() + m_matrix(1, 1) * v.y() + m_matrix(1, 2) * v.z();
@@ -128,8 +123,7 @@ ivector_t Transform3D::transformed(const ivector_t& v) const
 template BA_CORE_API_ kvector_t Transform3D::transformed<kvector_t>(const kvector_t& v) const;
 template BA_CORE_API_ cvector_t Transform3D::transformed<cvector_t>(const cvector_t& v) const;
 
-template <class ivector_t>
-ivector_t Transform3D::transformedInverse(const ivector_t& v) const
+template <class ivector_t> ivector_t Transform3D::transformedInverse(const ivector_t& v) const
 {
     auto x = m_inverse_matrix(0, 0) * v.x() + m_inverse_matrix(0, 1) * v.y()
              + m_inverse_matrix(0, 2) * v.z();
@@ -156,16 +150,19 @@ Transform3D Transform3D::operator*(const Transform3D& other) const
     return Transform3D(product_matrix);
 }
 
-bool Transform3D::operator==(const Transform3D &other) const
+bool Transform3D::operator==(const Transform3D& other) const
 {
     return this->m_matrix == other.m_matrix;
 }
 
 Transform3D::ERotationType Transform3D::getRotationType() const
 {
-    if (isXRotation()) return XAXIS;
-    if (isYRotation()) return YAXIS;
-    if (isZRotation()) return ZAXIS;
+    if (isXRotation())
+        return XAXIS;
+    if (isYRotation())
+        return YAXIS;
+    if (isZRotation())
+        return ZAXIS;
     return EULER;
 }
 
@@ -173,7 +170,7 @@ bool Transform3D::isIdentity() const
 {
     double alpha, beta, gamma;
     calculateEulerAngles(&alpha, &beta, &gamma);
-    return (alpha==0.0 && beta==0.0 && gamma==0.0);
+    return (alpha == 0.0 && beta == 0.0 && gamma == 0.0);
 }
 
 void Transform3D::print(std::ostream& ostr) const
@@ -183,41 +180,56 @@ void Transform3D::print(std::ostream& ostr) const
 
 bool Transform3D::isXRotation() const
 {
-    if (m_matrix(0,0) != 1.0) return false;
-    if (m_matrix(0,1) != 0.0) return false;
-    if (m_matrix(0,2) != 0.0) return false;
-    if (m_matrix(1,0) != 0.0) return false;
-    if (m_matrix(2,0) != 0.0) return false;
+    if (m_matrix(0, 0) != 1.0)
+        return false;
+    if (m_matrix(0, 1) != 0.0)
+        return false;
+    if (m_matrix(0, 2) != 0.0)
+        return false;
+    if (m_matrix(1, 0) != 0.0)
+        return false;
+    if (m_matrix(2, 0) != 0.0)
+        return false;
     return true;
 }
 
 bool Transform3D::isYRotation() const
 {
-    if (m_matrix(1,1) != 1.0) return false;
-    if (m_matrix(0,1) != 0.0) return false;
-    if (m_matrix(1,0) != 0.0) return false;
-    if (m_matrix(1,2) != 0.0) return false;
-    if (m_matrix(2,1) != 0.0) return false;
+    if (m_matrix(1, 1) != 1.0)
+        return false;
+    if (m_matrix(0, 1) != 0.0)
+        return false;
+    if (m_matrix(1, 0) != 0.0)
+        return false;
+    if (m_matrix(1, 2) != 0.0)
+        return false;
+    if (m_matrix(2, 1) != 0.0)
+        return false;
     return true;
 }
 
 bool Transform3D::isZRotation() const
 {
-    if (m_matrix(2,2) != 1.0) return false;
-    if (m_matrix(0,2) != 0.0) return false;
-    if (m_matrix(1,2) != 0.0) return false;
-    if (m_matrix(2,0) != 0.0) return false;
-    if (m_matrix(2,1) != 0.0) return false;
+    if (m_matrix(2, 2) != 1.0)
+        return false;
+    if (m_matrix(0, 2) != 0.0)
+        return false;
+    if (m_matrix(1, 2) != 0.0)
+        return false;
+    if (m_matrix(2, 0) != 0.0)
+        return false;
+    if (m_matrix(2, 1) != 0.0)
+        return false;
     return true;
 }
 
 double BottomZ(const std::vector<kvector_t>& vertices, const Transform3D& rotation)
 {
-    if (vertices.size()==0)
+    if (vertices.size() == 0)
         throw std::runtime_error("BottomZ() error: no vertices passed!");
     kvector_t vertex_rot = rotation.transformed(vertices[0]);
     double zmin = vertex_rot.z();
-    for (size_t index=1; index<vertices.size(); ++index) {
+    for (size_t index = 1; index < vertices.size(); ++index) {
         vertex_rot = rotation.transformed(vertices[index]);
         zmin = std::min(zmin, vertex_rot.z());
     }
@@ -226,11 +238,11 @@ double BottomZ(const std::vector<kvector_t>& vertices, const Transform3D& rotati
 
 double TopZ(const std::vector<kvector_t>& vertices, const Transform3D& rotation)
 {
-    if (vertices.size()==0)
+    if (vertices.size() == 0)
         throw std::runtime_error("TopZ() error: no vertices passed!");
     kvector_t vertex_rot = rotation.transformed(vertices[0]);
     double zmax = vertex_rot.z();
-    for (size_t index=1; index<vertices.size(); ++index) {
+    for (size_t index = 1; index < vertices.size(); ++index) {
         vertex_rot = rotation.transformed(vertices[index]);
         zmax = std::max(zmax, vertex_rot.z());
     }
diff --git a/Core/Vector/Transform3D.h b/Core/Vector/Transform3D.h
index 8289d8b103e..3c26aa77165 100644
--- a/Core/Vector/Transform3D.h
+++ b/Core/Vector/Transform3D.h
@@ -15,16 +15,17 @@
 #ifndef TRANSFORM3D_H
 #define TRANSFORM3D_H
 
-#include "Vectors3D.h"
 #include "Complex.h"
 #include "EigenCore.h"
+#include "Vectors3D.h"
 
 #include <vector>
 
 //! Vector transformations in three dimensions.
 //! @ingroup tools_internal
 
-class BA_CORE_API_ Transform3D {
+class BA_CORE_API_ Transform3D
+{
 public:
     enum ERotationType { EULER, XAXIS, YAXIS, ZAXIS };
 
@@ -40,7 +41,7 @@ public:
     ~Transform3D() {}
 
     //! Clones the transformation
-    Transform3D *clone() const;
+    Transform3D* clone() const;
 
     //! Creates identity transformation (default)
     static Transform3D createIdentity();
@@ -58,7 +59,7 @@ public:
     static Transform3D createRotateEuler(double alpha, double beta, double gamma);
 
     //! Calculates the Euler angles corresponding to the rotation
-    void calculateEulerAngles(double *p_alpha, double *p_beta, double *p_gamma) const;
+    void calculateEulerAngles(double* p_alpha, double* p_beta, double* p_gamma) const;
 
     //! Calculates the rotation angle for a rotation around the x-axis alone
     //! Only meaningfull if the actual rotation is around the x-axis
@@ -76,18 +77,16 @@ public:
     Transform3D getInverse() const;
 
     //! Return transformed vector _v_.
-    template <class ivector_t>
-    ivector_t transformed(const ivector_t& v) const;
+    template <class ivector_t> ivector_t transformed(const ivector_t& v) const;
 
     //! Return transformed vector _v_.
-    template <class ivector_t>
-    ivector_t transformedInverse(const ivector_t& v) const;
+    template <class ivector_t> ivector_t transformedInverse(const ivector_t& v) const;
 
     //! Composes two transformations
-    Transform3D operator*(const Transform3D &other) const;
+    Transform3D operator*(const Transform3D& other) const;
 
     //! Provides equality operator
-    bool operator==(const Transform3D &other) const;
+    bool operator==(const Transform3D& other) const;
 
     //! Retrieve the rotation type (general, around x, y or z-axis)
     ERotationType getRotationType() const;
@@ -96,13 +95,17 @@ public:
     bool isIdentity() const;
 
     friend std::ostream& operator<<(std::ostream& ostr, const Transform3D& m)
-    { m.print(ostr); return ostr; }
+    {
+        m.print(ostr);
+        return ostr;
+    }
 
     void print(std::ostream& ostr) const;
 
     bool isXRotation() const;
     bool isYRotation() const;
     bool isZRotation() const;
+
 private:
 #ifndef SWIG
     Eigen::Matrix3d m_matrix;
diff --git a/Core/Vector/WavevectorInfo.cpp b/Core/Vector/WavevectorInfo.cpp
index 8bfbb7df8ab..6622c135dfd 100644
--- a/Core/Vector/WavevectorInfo.cpp
+++ b/Core/Vector/WavevectorInfo.cpp
@@ -15,7 +15,6 @@
 #include "WavevectorInfo.h"
 #include "Transform3D.h"
 
-
 // TODO: can be removed when IFormFactor::volume() is refactored
 // (static function is provided to easily track usage of default constructor)
 WavevectorInfo WavevectorInfo::GetZeroQ()
@@ -30,8 +29,4 @@ WavevectorInfo WavevectorInfo::transformed(const Transform3D& transform) const
 }
 
 // same as GetZeroQ
-WavevectorInfo::WavevectorInfo()
-    : m_ki(1, 0, 0)
-    , m_kf(1, 0, 0)
-    , m_vacuum_wavelength(1)
-{}
+WavevectorInfo::WavevectorInfo() : m_ki(1, 0, 0), m_kf(1, 0, 0), m_vacuum_wavelength(1) {}
diff --git a/Core/Vector/WavevectorInfo.h b/Core/Vector/WavevectorInfo.h
index bfb60c7f9ca..b4c5d829b72 100644
--- a/Core/Vector/WavevectorInfo.h
+++ b/Core/Vector/WavevectorInfo.h
@@ -27,13 +27,13 @@ class BA_CORE_API_ WavevectorInfo
 public:
     static WavevectorInfo GetZeroQ();
     WavevectorInfo(cvector_t ki, cvector_t kf, double wavelength)
-        : m_ki(ki)
-        , m_kf(kf)
-        , m_vacuum_wavelength(wavelength) {}
+        : m_ki(ki), m_kf(kf), m_vacuum_wavelength(wavelength)
+    {
+    }
     WavevectorInfo(kvector_t ki, kvector_t kf, double wavelength)
-        : m_ki(ki.complex())
-        , m_kf(kf.complex())
-        , m_vacuum_wavelength(wavelength) {}
+        : m_ki(ki.complex()), m_kf(kf.complex()), m_vacuum_wavelength(wavelength)
+    {
+    }
 
     WavevectorInfo transformed(const Transform3D& transform) const;
     cvector_t getKi() const { return m_ki; }
diff --git a/Core/includeIncludes/SoftParticles.h b/Core/includeIncludes/SoftParticles.h
index 9f41df24604..62eb41a2c85 100644
--- a/Core/includeIncludes/SoftParticles.h
+++ b/Core/includeIncludes/SoftParticles.h
@@ -15,13 +15,13 @@
 #ifndef SOFTPARTICLES_H
 #define SOFTPARTICLES_H
 
-#include "SoftParticles.h"
+#include "FormFactorDebyeBueche.h"
 #include "FormFactorGauss.h"
 #include "FormFactorLorentz.h"
+#include "FormFactorOrnsteinZernike.h"
 #include "FormFactorSphereGaussianRadius.h"
 #include "FormFactorSphereLogNormalRadius.h"
 #include "FormFactorSphereUniformRadius.h"
-#include "FormFactorOrnsteinZernike.h"
-#include "FormFactorDebyeBueche.h"
+#include "SoftParticles.h"
 
 #endif // SOFTPARTICLES_H
-- 
GitLab