diff --git a/App/App.pro b/App/App.pro
index d0dd359661542e2fe87470a1dfc100634d1bf377..1a816bcb704ff12cb529ec869fe7a25ddc8ff53e 100644
--- a/App/App.pro
+++ b/App/App.pro
@@ -37,7 +37,6 @@ SOURCES += \
     $${FUNCTIONAL_TESTS}/IsGISAXS11/IsGISAXS11.cpp \
     $${FUNCTIONAL_TESTS}/IsGISAXS15/IsGISAXS15.cpp \
     src/AppOptionsDescription.cpp \
-    src/CommandLine.cpp \
     src/DrawHelper.cpp \
     src/FitSuiteObserverFactory.cpp \
     src/FunctionalTestFactory.cpp \
@@ -104,7 +103,6 @@ HEADERS += \
     inc/App.h \
     inc/AppLinkDef.h \
     inc/AppOptionsDescription.h \
-    inc/CommandLine.h \
     inc/DrawHelper.h \
     inc/FitSuiteObserverFactory.h \
     inc/FunctionalTestFactory.h \
diff --git a/App/inc/App.h b/App/inc/App.h
index dee1d9fdea64c5d952db712bca0237ad9570da79..1681aaee1b057195d64936751195b59ad91036eb 100644
--- a/App/inc/App.h
+++ b/App/inc/App.h
@@ -14,7 +14,7 @@
 //! @author Scientific Computing Group at FRM II
 //! @date   01.04.2012
 
-#include "ISingleton.h"
+//#include "ISingleton.h"
 #include "DrawHelper.h"
 #include "TreeEventStructure.h"
 
diff --git a/App/inc/AppLinkDef.h b/App/inc/AppLinkDef.h
index e93d4c2ad0f48604f0cb03fa7cac90b3ba5e5ca4..95b3efb757fd3e6248eb390ac993c10a9d490e40 100644
--- a/App/inc/AppLinkDef.h
+++ b/App/inc/AppLinkDef.h
@@ -18,7 +18,7 @@
 #pragma link off all classes;
 #pragma link off all functions;
 
-#pragma link C++ class ISingleton<DrawHelper>+;
+//#pragma link C++ class ISingleton<DrawHelper>+;
 #pragma link C++ class DrawHelper+;
 #pragma link C++ class TreeEventOutputData+;
 #pragma link C++ class TreeEventFitData+;
diff --git a/App/inc/CommandLine.h b/App/inc/CommandLine.h
deleted file mode 100644
index 0e3877c93f1e869aef5d35aca6068dc6c3845e0e..0000000000000000000000000000000000000000
--- a/App/inc/CommandLine.h
+++ /dev/null
@@ -1,71 +0,0 @@
-#ifndef COMMANDLINE_H
-#define COMMANDLINE_H
-// ********************************************************************
-// * The BornAgain project                                            *
-// * Simulation of neutron and x-ray scattering at grazing incidence  *
-// *                                                                  *
-// * LICENSE AND DISCLAIMER                                           *
-// * Lorem ipsum dolor sit amet, consectetur adipiscing elit.  Mauris *
-// * eget quam orci. Quisque  porta  varius  dui,  quis  posuere nibh *
-// * mollis quis. Mauris commodo rhoncus porttitor.                   *
-// ********************************************************************
-//! @file   CommandLine.h
-//! @brief  Definition of CommandLine class
-//! @author Scientific Computing Group at FRM II
-//! @date   01.05.2012
-
-#include <string>
-#include <vector>
-#include <map>
-
-#include <algorithm>
-#include "Utils.h"
-
-//- -------------------------------------------------------------------
-//! @class CommandLine
-//! @brief Simple handling of command line parameters
-//- -------------------------------------------------------------------
-class CommandLine
-{
-public:
-    typedef std::vector<std::string > arguments_t;
-
-    //! command line constructor parses command line arguments
-    CommandLine(int argc, char **argv);
-
-    //! return command line argument
-    std::string &operator[](int i) {return m_arguments.at(i); }
-
-    //! check if such name present in command line arguments
-    bool find(std::string name) {return std::find(m_arguments.begin(), m_arguments.end(), name)==m_arguments.end() ? false : true; }
-
-    //! return original comand line argc
-    int  getArgc() const  { return m_argc; }
-
-    //! return original comand line argv
-    char **getArgv() const  { return m_argv; }
-
-    //! print help on the screen
-    void print_help();
-
-    //! return true if all command line arguments are recognized
-    bool isGood();
-
-    //! return true if there is functional test with such name
-    bool isFunctionalTest(std::string name);
-
-    //! return number of arguments in command line
-    size_t size() { return m_arguments.size(); }
-
-private:
-    int m_argc; //! original command line argc
-    char **m_argv; //! original command line argv
-    arguments_t m_arguments; //! parsed command line arguments
-
-    arguments_t m_defined_arguments; //! defined command line arguments
-//    arguments_t m_defined_functional_tests; //! defined names of functional tests
-    std::map<std::string, std::string > m_description; //! description of command line arguments
-
-};
-
-#endif // COMMANDLINE_H
diff --git a/App/inc/DrawHelper.h b/App/inc/DrawHelper.h
index 56e9800de0cb9cc7d85e45374b7e0aba103de443..744c206d8f6d51e9741a0260afe90337ec49f34b 100644
--- a/App/inc/DrawHelper.h
+++ b/App/inc/DrawHelper.h
@@ -15,8 +15,6 @@
 //! @date   01.04.2012
 
 #include "TObject.h"
-#include "ISingleton.h"
-
 #include <vector>
 #include <string>
 
@@ -24,7 +22,6 @@ class TCanvas;
 class MultiLayer;
 class TPad;
 
-
 //- -------------------------------------------------------------------
 //! @class DrawHelper
 //! @brief Several usefull utilities for graphics in ROOT
@@ -32,7 +29,7 @@ class TPad;
 //! Provides magnification of pads in canvas, common style for drawing,
 //! saving of all opened canvases from memory to pdf file
 //- -------------------------------------------------------------------
-class DrawHelper : public ISingleton<DrawHelper>, public TObject
+class DrawHelper :public TObject
 {
 public:
     //! set own drawing style
@@ -42,32 +39,27 @@ public:
     static void SaveReportPDFObsolete();
 
     //! connect user canvas with magnifier function
-    void SetMagnifier(TCanvas *c);
+    static void SetMagnifier(TCanvas *c);
 
     //! process double click in canvas to magnify given pad
-    void ExecuteMagnifier(Int_t event, Int_t px, Int_t py, TObject *sel);
+    static void ExecuteMagnifier(Int_t event, Int_t px, Int_t py, TObject *sel);
 
     //! draw multilayer structure in TPad
-    void DrawMultilayer(const MultiLayer *sample);
+    static void DrawMultilayer(const MultiLayer *sample);
 
     //! create and register canvas
-    TCanvas *createAndRegisterCanvas(std::string name, std::string title, int xsize=0, int ysize=0);
+    static TCanvas *createAndRegisterCanvas(std::string name, std::string title, int xsize=0, int ysize=0);
 
     //! save reports (pdf and ROOT)
-    void saveReport();
+    static void saveReport();
 
     //! attempt to draw meso crystal lattice in 3d
-    void DrawMesoCrystal(const MultiLayer *sample);
-
-protected:
-    DrawHelper();
-    friend class ISingleton<DrawHelper >;
+    static void DrawMesoCrystal(const MultiLayer *sample);
 
 private:
-    int m_default_canvas_xsize;
-    int m_default_canvas_ysize;
-
-    std::vector<TCanvas *> m_registered_canvases;
+    static int m_default_canvas_xsize;
+    static int m_default_canvas_ysize;
+    static std::vector<TCanvas *> m_registered_canvases;
 
   ClassDef(DrawHelper,1)
 };
diff --git a/App/inc/FunctionalTestFactory.h b/App/inc/FunctionalTestFactory.h
index 5db36666cd3ed9adbd3f3de97e58984412410fff..a213c3c47aefdc382b37eb19bd198a2983ee3b34 100644
--- a/App/inc/FunctionalTestFactory.h
+++ b/App/inc/FunctionalTestFactory.h
@@ -25,37 +25,36 @@ class TBenchmark;
 class ProgramOptions;
 
 class FunctionalTestFactory : public ISingleton<FunctionalTestFactory>, public IFactory<std::string, IFunctionalTest>
-//before it was template class ISingleton<IFactory<std::string, IFunctionalTest> >;
 {
 public:
-    typedef DescriptionMap_t::iterator iterator;
-    typedef DescriptionMap_t::const_iterator const_iterator;
-
     FunctionalTestFactory();
     virtual ~FunctionalTestFactory();
 
     //! execute specified test
-    void execute(std::string name, ProgramOptions *p_options);
+    static void execute(std::string name, ProgramOptions *p_options) { instance().this_execute(name, p_options); }
 
     //! profile specified test
-    void profile(std::string name, ProgramOptions *p_options);
+    static void profile(std::string name, ProgramOptions *p_options)  { instance().this_profile(name, p_options); }
 
     //! execute all registered tests
-    void execute_all(ProgramOptions *p_options);
+    static void execute_all(ProgramOptions *p_options)  { instance().this_execute_all(p_options); }
 
     //! print names of registered tests
-    void print_testnames();
+    static void print_testnames() { instance().this_print_testnames(); }
 
     //! print benchmark summary
-    void print_benchmarks();
-
-    //! return vector of registered test names and they desciptions map["name"]="description"
-    DescriptionMap_t getDescriptionMap();
+    static void print_benchmarks() { instance().this_print_benchmarks(); }
 
-    iterator begin() { return m_descriptions.begin(); }
-    iterator end() { return m_descriptions.end(); }
+    static iterator begin() { return instance().m_descriptions.begin(); }
+    static iterator end() { return instance().m_descriptions.end(); }
 
 private:
+    void this_execute(std::string name, ProgramOptions *p_options);
+    void this_profile(std::string name, ProgramOptions *p_options);
+    void this_execute_all(ProgramOptions *p_options);
+    void this_print_testnames();
+    void this_print_benchmarks();
+
     TBenchmark *m_benchmark;
 };
 
diff --git a/App/src/AppOptionsDescription.cpp b/App/src/AppOptionsDescription.cpp
index 41b2dd5b65eb7a8c41d4ead39145966e00d49662..66a80f947e1d3684af6c9ea3d2121226e1a7ff2d 100644
--- a/App/src/AppOptionsDescription.cpp
+++ b/App/src/AppOptionsDescription.cpp
@@ -26,8 +26,8 @@ void AddApplicationOptions(ProgramOptions* p_options)
 
     // functional tests options constructed from information carried by FunctionalTestFactory
     bpo::options_description functional_test_options("Functional tests");
-    FunctionalTestFactory::iterator it = FunctionalTestFactory::instance().begin();
-    for(; it!= FunctionalTestFactory::instance().end(); ++it) {
+    FunctionalTestFactory::iterator it = FunctionalTestFactory::begin();
+    for(; it!= FunctionalTestFactory::end(); ++it) {
         // it.first - test name, it.second - test description
         functional_test_options.add_options()((*it).first.c_str(), (*it).second.c_str());
     }
diff --git a/App/src/CommandLine.cpp b/App/src/CommandLine.cpp
deleted file mode 100644
index 04f7830b2153d8e22d9caa218e5ea251ef402509..0000000000000000000000000000000000000000
--- a/App/src/CommandLine.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-#include "CommandLine.h"
-#include "FunctionalTestFactory.h"
-#include <iomanip>
-#include <set>
-#include <algorithm>
-
-
-/* ************************************************************************* */
-// command line constructor parses command line arguments, create list of
-// known arguments and they description
-/* ************************************************************************* */
-CommandLine::CommandLine(int argc, char **argv) : m_argc(argc), m_argv(argv)
-{
-    // saving command line argument for later convenient access
-    for(int i=1; i<argc; i++) m_arguments.push_back(std::string(argv[i]));
-
-    // saving relative path to the application for later usage
-    Utils::FileSystem::SetRelativePath(argv[0]);
-
-    // creating list of defined arguments
-    m_defined_arguments.push_back("help");
-    m_defined_arguments.push_back("batch");
-    m_defined_arguments.push_back("report");
-    m_defined_arguments.push_back("all");
-    m_defined_arguments.push_back("profile");
-    // getting info about names of defined functional tests and adding them to the list of defined arguments
-//    m_defined_functional_tests = FunctionalTestFactory::instance().get_testinfo();
-//    m_defined_arguments.insert(m_defined_arguments.end(), m_defined_functional_tests.begin(), m_defined_functional_tests.end());
-
-    // adding description of command line arguments
-
-    // description of general command line arguments
-    m_description["help"]         = "print given help";
-    m_description["batch"]        = "run application in batch mode (no graphics)";
-    m_description["report"]    = "write functional tests report in pdf file";
-    m_description["all"]          = "run all registered functional test";
-    m_description["profile"]      = "profile specified test";
-
-    // collecting description of functional tests
-//    std::map<std::string, std::string> test_descriptions= FunctionalTestFactory::instance().get_testinfo();
-//    for(std::map<std::string, std::string>::iterator it=test_descriptions.begin(); it!= test_descriptions.end(); ++it) {
-//        m_description[(*it).first] = (*it).second;
-//    }
-
-
-//    for(arguments_t::iterator it = m_defined_functional_tests.begin(); it!=m_defined_functional_tests.end(); ++it ) {
-//        m_description[ (*it) ]        = "functional test: no description";
-//    }
-    // additional description of functional tests (overwrites previous default)
-//    m_description["isgisaxs1"]        = "functional test: isgisaxs ex-1 (2 types of particles without inteference on top of substrate)";
-//    m_description["isgisaxs2"]        = "functional test: isgisaxs ex-2 (mean form factors for particles with shape size distribution)";
-//    m_description["isgisaxs3"]        = "functional test: isgisaxs ex-3 (cylinder FF)";
-//    m_description["isgisaxs9"]        = "functional test: isgisaxs ex-9 (rotated pyramid FF)";
-//    m_description["isgisaxs10"]       = "functional test: isgisaxs ex-10 (cylinders with interference on top of substrate)";
-//    m_description["convolution"]      = "functional test: test of convolution via fft";
-//    m_description["diffuse"]          = "functional test: diffuse scattering from multi layer with roughness";
-//    m_description["formfactor"]       = "functional test: some formfactor";
-//    m_description["roughness"]        = "functional test: roughness parameters";
-//    m_description["roottree"]         = "functional test: using root trees to read/write data from/to disk";
-//    m_description["performance"]      = "functional test: run performance test for several predefined tasks";
-//    m_description["roughdwba"]        = "functional test: diffuse scattering from multi layer with roughness";
-//    m_description["testmisc"]         = "functional test: test of different miscellaneous issues";
-
-
-}
-
-
-/* ************************************************************************* */
-// return true if all command line arguments are recognized
-/* ************************************************************************* */
-bool CommandLine::isGood()
-{
-//    // no arguments in command line is not good
-//    if(!m_arguments.size() ) return false;
-
-//    // pleading for 'help' in command line is also not good
-//    if( find("help") ) return false;
-
-//    // check if all arguments from command line are known
-//    std::set<std::string> s_defined( m_defined_arguments.begin(), m_defined_arguments.end() );
-//    std::set<std::string> s_requested( m_arguments.begin(), m_arguments.end() );
-//    arguments_t unknown_arguments;
-//    std::set_difference(s_requested.begin(), s_requested.end(), s_defined.begin(), s_defined.end(), std::back_inserter(unknown_arguments) );
-//    if( unknown_arguments.size() ) {
-//        std::cout << "Unkown arguments: ";
-//        for(size_t i=0; i<unknown_arguments.size(); i++){
-//            std::cout << "'" << unknown_arguments[i] << "' ";
-//        }
-//        std::cout << std::endl;
-//        return false;
-//    }
-
-    return true;
-}
-
-
-/* ************************************************************************* */
-// return true if there is functional test with such name
-/* ************************************************************************* */
-bool CommandLine::isFunctionalTest(std::string name)
-{
-    (void) name;
-//    for(arguments_t::iterator it=m_defined_functional_tests.begin(); it!= m_defined_functional_tests.end(); ++it) {
-//        if(name == (*it)) return true;
-//    }
-    return false;
-}
-
-
-/* ************************************************************************* */
-// print help on the screen
-/* ************************************************************************* */
-void CommandLine::print_help()
-{
-    std::cout << " " << std::endl;
-    std::cout << "CommandLine::print_help() -> Run application with one ore more arguments from the list below" << std::endl;
-    std::cout << " " << std::endl;
-    for(arguments_t::iterator it=m_defined_arguments.begin(); it!= m_defined_arguments.end(); ++it) {
-        std::cout << std::setw(15) << std::left << (*it) << " - " << m_description[(*it)] << std::endl;
-    }
-    std::cout << " " << std::endl;
-    std::cout << "Example: ./App isgisaxs10 " << std::endl;
-    std::cout << "Example: ./App isgisaxs3 isgisaxs10 pdfreport batch " << std::endl;
-
-}
diff --git a/App/src/DrawHelper.cpp b/App/src/DrawHelper.cpp
index a873c05d288c0d176948d75db221133d59364a6c..3f33a27a494aa1aafb4a682c91c5607c5d5e8fef 100644
--- a/App/src/DrawHelper.cpp
+++ b/App/src/DrawHelper.cpp
@@ -40,12 +40,9 @@
 //#include "TGLViewer.h"
 
 
-
-DrawHelper::DrawHelper() : m_default_canvas_xsize(1024), m_default_canvas_ysize(768)
-//DrawHelper::DrawHelper() : m_default_canvas_xsize(1600), m_default_canvas_ysize(1200)
-{
-
-}
+std::vector<TCanvas *> DrawHelper::m_registered_canvases = std::vector<TCanvas *>();
+int DrawHelper::m_default_canvas_xsize = 1024;
+int DrawHelper::m_default_canvas_ysize = 768;
 
 
 /* ************************************************************************* */
@@ -53,7 +50,8 @@ DrawHelper::DrawHelper() : m_default_canvas_xsize(1024), m_default_canvas_ysize(
 /* ************************************************************************* */
 void DrawHelper::SetMagnifier(TCanvas *canvas)
 {
-  canvas->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", "DrawHelper", this, "ExecuteMagnifier(int,int,int,TObject*)");
+//    canvas->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", "DrawHelper", this, "ExecuteMagnifier(int,int,int,TObject*)");
+    canvas->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", "DrawHelper", 0, "ExecuteMagnifier(int,int,int,TObject*)");
 }
 
 
diff --git a/App/src/FunctionalTestFactory.cpp b/App/src/FunctionalTestFactory.cpp
index 717ac3fe4c21a545c78c1e4a26155f4e0d75acaa..25ec5750cf10408c2ab9b42646cb33b7b65a2868 100644
--- a/App/src/FunctionalTestFactory.cpp
+++ b/App/src/FunctionalTestFactory.cpp
@@ -1,10 +1,23 @@
 #include "FunctionalTestFactory.h"
-#include "TestRoughness.h"
-#include "TestFresnelCoeff.h"
+#include "TestConvolution.h"
+#include "TestDetectorResolution.h"
+#include "TestDiffuseReflection.h"
+#include "TestFittingBenchmark.h"
+#include "TestFittingModule1.h"
+#include "TestFittingModule2.h"
+#include "TestFittingModule3.h"
 #include "TestFormFactor.h"
+#include "TestFormFactors.h"
+#include "TestFourier.h"
+#include "TestFresnelCoeff.h"
 #include "TestFumiliLMA.h"
-#include "TestDiffuseReflection.h"
 #include "TestIsGISAXS1.h"
+#include "TestIsGISAXS10.h"
+#include "TestIsGISAXS11.h"
+#include "TestIsGISAXS12.h"
+#include "TestIsGISAXS13.h"
+#include "TestIsGISAXS14.h"
+#include "TestIsGISAXS15.h"
 #include "TestIsGISAXS2.h"
 #include "TestIsGISAXS3.h"
 #include "TestIsGISAXS4.h"
@@ -13,35 +26,18 @@
 #include "TestIsGISAXS7.h"
 #include "TestIsGISAXS8.h"
 #include "TestIsGISAXS9.h"
-#include "TestIsGISAXS10.h"
-#include "TestIsGISAXS11.h"
-#include "TestIsGISAXS12.h"
-#include "TestIsGISAXS13.h"
-#include "TestIsGISAXS14.h"
-#include "TestIsGISAXS15.h"
-#include "TestConvolution.h"
-#include "TestDetectorResolution.h"
 #include "TestMesoCrystal1.h"
 #include "TestMesoCrystal2.h"
-
-#include "TestFormFactors.h"
-
-#include "TestRootTree.h"
-#include "TestFittingModule1.h"
-#include "TestFittingModule2.h"
-#include "TestFittingModule3.h"
-#include "TestPerformance.h"
-#include "TestMultiLayerRoughness.h"
 #include "TestMiscellaneous.h"
-#include "TestFittingBenchmark.h"
-#include "TestFourier.h"
+#include "TestMultiLayerRoughness.h"
+#include "TestPerformance.h"
+#include "TestRootTree.h"
+#include "TestRoughness.h"
 #include "TestToySimulation.h"
 
-
 #include "TBenchmark.h"
 
 
-
 FunctionalTestFactory::FunctionalTestFactory() : m_benchmark(0)
 {
     setOwnObjects(true);
@@ -122,17 +118,14 @@ FunctionalTestFactory::FunctionalTestFactory() : m_benchmark(0)
 }
 
 
-
 FunctionalTestFactory::~FunctionalTestFactory()
 {
     delete m_benchmark;
 }
 
 
-/* ************************************************************************* */
 // print benchmark summary on the screen
-/* ************************************************************************* */
-void FunctionalTestFactory::print_benchmarks()
+void FunctionalTestFactory::this_print_benchmarks()
 {
     std::cout << "--- TestFactory::print_benchmarks() ---" << std::endl;
     Float_t rp, cp;
@@ -140,12 +133,9 @@ void FunctionalTestFactory::print_benchmarks()
 }
 
 
-/* ************************************************************************* */
 // execute specific functional tests
-/* ************************************************************************* */
-void FunctionalTestFactory::execute(std::string name, ProgramOptions *p_options)
+void FunctionalTestFactory::this_execute(std::string name, ProgramOptions *p_options)
 {
-    //IFunctionalTest *test = TestFactory::instance().createItem( args[i] );
     IFunctionalTest *test(0);
     try {
         test = createItem( name );
@@ -165,9 +155,9 @@ void FunctionalTestFactory::execute(std::string name, ProgramOptions *p_options)
 }
 
 
-void FunctionalTestFactory::profile(std::string name, ProgramOptions *p_options)
+// run tests in profile mode
+void FunctionalTestFactory::this_profile(std::string name, ProgramOptions *p_options)
 {
-    //IFunctionalTest *test = TestFactory::instance().createItem( args[i] );
     IFunctionalTest *test(0);
     try {
         test = createItem( name );
@@ -183,11 +173,8 @@ void FunctionalTestFactory::profile(std::string name, ProgramOptions *p_options)
 }
 
 
-
-/* ************************************************************************* */
 // execute all registered functional tests
-/* ************************************************************************* */
-void FunctionalTestFactory::execute_all(ProgramOptions *p_options)
+void FunctionalTestFactory::this_execute_all(ProgramOptions *p_options)
 {
     CallbackMap_t::const_iterator it;
     for(it=m_callbacks.begin(); it != m_callbacks.end(); ++it ) {
@@ -198,10 +185,8 @@ void FunctionalTestFactory::execute_all(ProgramOptions *p_options)
 }
 
 
-/* ************************************************************************* */
 // print on the screen names of registered tests
-/* ************************************************************************* */
-void FunctionalTestFactory::print_testnames()
+void FunctionalTestFactory::this_print_testnames()
 {
     std::string help;
     help += "TestFactory::print_testnames() -> Info. \n";
@@ -213,13 +198,3 @@ void FunctionalTestFactory::print_testnames()
         std::cout << it->first << std::endl;
     }
 }
-
-
-/* ************************************************************************* */
-// return vector of registered test names
-/* ************************************************************************* */
-FunctionalTestFactory::DescriptionMap_t FunctionalTestFactory::getDescriptionMap()
-{
-    return m_descriptions;
-}
-
diff --git a/App/src/IsGISAXSTools.cpp b/App/src/IsGISAXSTools.cpp
index 59108c7ca2a97e517ce1aed09e14c3e501c96390..78ab4e4aeabd81d0a48138ff43c378abc6703f9c 100644
--- a/App/src/IsGISAXSTools.cpp
+++ b/App/src/IsGISAXSTools.cpp
@@ -567,7 +567,7 @@ void IsGISAXSTools::drawOutputDataComparisonResults(const OutputData<double> &da
 {
     assert(&data);
     assert(&reference);
-    TCanvas *c1 = DrawHelper::instance().createAndRegisterCanvas(name, title);
+    TCanvas *c1 = DrawHelper::createAndRegisterCanvas(name, title);
     c1->Divide(2,2);
 
     // our calculations
diff --git a/App/src/StandardSamples.cpp b/App/src/StandardSamples.cpp
index 380849571741b6fa4ac3c2c10a6ed66a618ed2b4..66f1c1c07c44a02e41d8980e1ed0d57928f9fccb 100644
--- a/App/src/StandardSamples.cpp
+++ b/App/src/StandardSamples.cpp
@@ -29,9 +29,8 @@
 /* ************************************************************************* */
 ISample *StandardSamples::AirOnSubstrate()
 {
-    MaterialManager &matManager = MaterialManager::instance();
-    const IMaterial *mAmbience = matManager.addHomogeneousMaterial("ambience",complex_t(1.0, 0.0) );
-    const IMaterial *mSubstrate = matManager.addHomogeneousMaterial("substrate", complex_t(1.0-15e-6, 0) );
+    const IMaterial *mAmbience = MaterialManager::getHomogeneousMaterial("ambience",complex_t(1.0, 0.0) );
+    const IMaterial *mSubstrate = MaterialManager::getHomogeneousMaterial("substrate", complex_t(1.0-15e-6, 0) );
 
     MultiLayer *mySample = new MultiLayer;
 
@@ -56,9 +55,8 @@ ISample *StandardSamples::AirOnSubstrate()
 /* ************************************************************************* */
 ISample *StandardSamples::SubstrateOnSubstrate()
 {
-    MaterialManager &matManager = MaterialManager::instance();
-    const IMaterial *mAmbience = matManager.addHomogeneousMaterial("ambience",complex_t(1.0, 0.0) );
-    const IMaterial *mSubstrate = matManager.addHomogeneousMaterial("substrate", complex_t(1.0-15e-6, 0) );
+    const IMaterial *mAmbience = MaterialManager::getHomogeneousMaterial("ambience",complex_t(1.0, 0.0) );
+    const IMaterial *mSubstrate = MaterialManager::getHomogeneousMaterial("substrate", complex_t(1.0-15e-6, 0) );
 
     MultiLayer *mySample = new MultiLayer;
 
@@ -83,12 +81,10 @@ ISample *StandardSamples::SubstrateOnSubstrate()
 /* ************************************************************************* */
 ISample *StandardSamples::SimpleMultilayer()
 {
-    MaterialManager &matManager = MaterialManager::instance();
-
-    const IMaterial *mAmbience = matManager.addHomogeneousMaterial("ambience", complex_t(1.0, 0.0) );
-    const IMaterial *mAg1 = matManager.addHomogeneousMaterial("ag1", complex_t(1.0-5e-6, 0.0) );
-    const IMaterial *mCr1 = matManager.addHomogeneousMaterial("cr1", complex_t(1.0-10e-6, 0.0) );
-    const IMaterial *mSubstrate = matManager.addHomogeneousMaterial("substrate2", complex_t(1.0-15e-6, 0.0) );
+    const IMaterial *mAmbience = MaterialManager::getHomogeneousMaterial("ambience", complex_t(1.0, 0.0) );
+    const IMaterial *mAg1 = MaterialManager::getHomogeneousMaterial("ag1", complex_t(1.0-5e-6, 0.0) );
+    const IMaterial *mCr1 = MaterialManager::getHomogeneousMaterial("cr1", complex_t(1.0-10e-6, 0.0) );
+    const IMaterial *mSubstrate = MaterialManager::getHomogeneousMaterial("substrate2", complex_t(1.0-15e-6, 0.0) );
 
     Layer lAmbience;
     lAmbience.setMaterial(mAmbience, 0);
@@ -129,12 +125,10 @@ ISample *StandardSamples::SimpleMultilayer()
 /* ************************************************************************* */
 ISample *StandardSamples::MultilayerOffspecTestcase1a()
 {
-    MaterialManager &matManager = MaterialManager::instance();
-
-    const IMaterial *mAmbience = matManager.addHomogeneousMaterial("ambience", complex_t(1.0, 0.0) );
-    const IMaterial *mPartA = matManager.addHomogeneousMaterial("PartA", complex_t(1.0-5e-6, 0.0) );
-    const IMaterial *mPartB = matManager.addHomogeneousMaterial("PartB", complex_t(1.0-10e-6, 0.0) );
-    const IMaterial *mSubstrate = matManager.addHomogeneousMaterial("substrate", complex_t(1.0-15e-6, 0.0) );
+    const IMaterial *mAmbience = MaterialManager::getHomogeneousMaterial("ambience", complex_t(1.0, 0.0) );
+    const IMaterial *mPartA = MaterialManager::getHomogeneousMaterial("PartA", complex_t(1.0-5e-6, 0.0) );
+    const IMaterial *mPartB = MaterialManager::getHomogeneousMaterial("PartB", complex_t(1.0-10e-6, 0.0) );
+    const IMaterial *mSubstrate = MaterialManager::getHomogeneousMaterial("substrate", complex_t(1.0-15e-6, 0.0) );
 
     Layer lAmbience;
     lAmbience.setMaterial(mAmbience, 0);
@@ -194,9 +188,8 @@ ISample *StandardSamples::MultilayerOffspecTestcase1b()
 /* ************************************************************************* */
 ISample *StandardSamples::MultilayerOffspecTestcase2a()
 {
-    MaterialManager &matManager = MaterialManager::instance();
-    const IMaterial *mAmbience = matManager.addHomogeneousMaterial("ambience",complex_t(1.0, 0.0) );
-    const IMaterial *mSubstrate = matManager.addHomogeneousMaterial("substrate", complex_t(1.0-15e-6, 0) );
+    const IMaterial *mAmbience = MaterialManager::getHomogeneousMaterial("ambience",complex_t(1.0, 0.0) );
+    const IMaterial *mSubstrate = MaterialManager::getHomogeneousMaterial("substrate", complex_t(1.0-15e-6, 0) );
 
     MultiLayer *mySample = new MultiLayer;
 
@@ -245,8 +238,8 @@ ISample *StandardSamples::MultilayerOffspecTestcase2b()
 //    complex_t n_air(1.0, 0.0);
 //    complex_t n_substrate(1.0-4e-6, 2e-8);
 //    complex_t n_particle(1.0-5e-4, 2e-8);
-//    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
-//    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+//    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
+//    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate);
 //    Layer air_layer;
 //    air_layer.setMaterial(p_air_material);
 //    Layer substrate_layer;
@@ -273,8 +266,8 @@ ISample *StandardSamples::MultilayerOffspecTestcase2b()
 //    complex_t n_air(1.0, 0.0);
 //    complex_t n_substrate(1.0-4e-6, 2e-8);
 //    complex_t n_particle(1.0-5e-4, 2e-8);
-//    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
-//    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+//    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
+//    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate);
 //    Layer air_layer;
 //    air_layer.setMaterial(p_air_material);
 //    Layer substrate_layer;
@@ -302,8 +295,8 @@ ISample *StandardSamples::MultilayerOffspecTestcase2b()
 //    complex_t n_air(1.0, 0.0);
 //    complex_t n_substrate(1.0-5e-6, 2e-8);
 //    complex_t n_particle(1.0-6e-4, 2e-8);
-//    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
-//    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+//    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
+//    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate);
 //    Layer air_layer;
 //    air_layer.setMaterial(p_air_material);
 //    Layer substrate_layer;
@@ -330,8 +323,8 @@ ISample *StandardSamples::MultilayerOffspecTestcase2b()
 //    complex_t n_air(1.0, 0.0);
 //    complex_t n_substrate(1.0-3e-6, 2e-8);
 //    complex_t n_particle(1.0-5e-4, 2e-8);
-//    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
-//    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+//    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
+//    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate);
 //    Layer air_layer;
 //    air_layer.setMaterial(p_air_material);
 //    Layer substrate_layer;
@@ -359,8 +352,8 @@ ISample *StandardSamples::MultilayerOffspecTestcase2b()
 //    complex_t n_air(1.0, 0.0);
 //    complex_t n_substrate(1.0-6e-6, 2e-8);
 //    complex_t n_particle(1.0-6e-4, 2e-8);
-//    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
-//    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+//    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
+//    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate);
 //    Layer air_layer;
 //    air_layer.setMaterial(p_air_material);
 //    Layer substrate_layer;
@@ -385,7 +378,7 @@ ISample *StandardSamples::IsGISAXS2_CylindersMixture()
     MultiLayer *p_multi_layer = new MultiLayer();
     complex_t n_air(1.0, 0.0);
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
 
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
@@ -438,8 +431,8 @@ ISample *StandardSamples::IsGISAXS3_CylinderDWBA()
     complex_t n_air(1.0, 0.0);
     complex_t n_substrate(1.0-6e-6, 2e-8);
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
@@ -459,7 +452,7 @@ ISample *StandardSamples::IsGISAXS3_CylinderBA()
     MultiLayer *p_multi_layer = new MultiLayer();
     complex_t n_air(1.0, 0.0);
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     ParticleDecoration particle_decoration( new Particle(n_particle, new FormFactorCylinder(5*Units::nanometer, 5*Units::nanometer)));
@@ -475,7 +468,7 @@ ISample *StandardSamples::IsGISAXS3_CylinderBASize()
     MultiLayer *p_multi_layer = new MultiLayer();
     complex_t n_air(1.0, 0.0);
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
 
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
@@ -513,8 +506,8 @@ ISample *StandardSamples::IsGISAXS4_1DDL()
     complex_t n_air(1.0, 0.0);
     complex_t n_substrate(1.0-6e-6, 2e-8);
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
@@ -536,8 +529,8 @@ ISample *StandardSamples::IsGISAXS4_2DDL()
     complex_t n_air(1.0, 0.0);
     complex_t n_substrate(1.0-6e-6, 2e-8);
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
@@ -564,8 +557,8 @@ ISample *StandardSamples::IsGISAXS6_lattice()
     complex_t n_air(1.0, 0.0);
     complex_t n_substrate(1.0-6e-6, 2e-8);
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
@@ -614,8 +607,8 @@ ISample *StandardSamples::IsGISAXS6_centered()
     complex_t n_air(1.0, 0.0);
     complex_t n_substrate(1.0-6e-6, 2e-8);
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
@@ -668,8 +661,8 @@ ISample *StandardSamples::IsGISAXS6_rotated()
     complex_t n_air(1.0, 0.0);
     complex_t n_substrate(1.0-6e-6, 2e-8);
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
@@ -720,7 +713,7 @@ ISample *StandardSamples::IsGISAXS7_morphology()
     MultiLayer *p_multi_layer = new MultiLayer();
     complex_t n_air(1.0, 0.0);
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     ParticleDecoration particle_decoration;
@@ -798,8 +791,8 @@ ISample *StandardSamples::IsGISAXS8_2DDL_lattice()
     complex_t n_air(1.0, 0.0);
     complex_t n_substrate(1.0-6e-6, 2e-8);
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
@@ -825,8 +818,8 @@ ISample *StandardSamples::IsGISAXS8_2DDL_lattice2()
     complex_t n_air(1.0, 0.0);
     complex_t n_substrate(1.0-6e-6, 2e-8);
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
@@ -854,8 +847,8 @@ ISample *StandardSamples::IsGISAXS9_Pyramid()
     complex_t n_air(1.0, 0.0);
     complex_t n_substrate(1.0-6e-6, 2e-8);
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
@@ -881,8 +874,8 @@ ISample *StandardSamples::IsGISAXS9_RotatedPyramid()
     complex_t n_air(1.0, 0.0);
     complex_t n_substrate(1.0-6e-6, 2e-8);
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
@@ -914,8 +907,8 @@ ISample *StandardSamples::IsGISAXS10_CylindersParacrystal1D()
     complex_t n_air(1.0, 0.0);
     complex_t n_substrate(1.0-5e-6, 2e-8);
     complex_t n_particle(1.0-5e-5, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air10", n_air);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate10", n_substrate);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air10", n_air);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate10", n_substrate);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
@@ -940,7 +933,7 @@ ISample *StandardSamples::IsGISAXS11_CoreShellParticles()
     complex_t n_air(1.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);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air11", n_air);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air11", n_air);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Particle shell_particle(n_particle_shell, new FormFactorParallelepiped(8*Units::nanometer, 8*Units::nanometer));
@@ -964,8 +957,8 @@ ISample *StandardSamples::IsGISAXS14_LayeredSpheresOnGradedInterface()
     complex_t n_air(1.0, 0.0);
     complex_t n_substrate(1.0-6e-6, 2e-8);
     complex_t n_particle(1.0-6e-5, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air10", n_air);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate10", n_substrate);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air10", n_air);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate10", n_substrate);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
@@ -992,7 +985,7 @@ ISample *StandardSamples::IsGISAXS15_SSCA()
     MultiLayer *p_multi_layer = new MultiLayer();
     complex_t n_air(1.0, 0.0);
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     InterferenceFunction1DParaCrystal *p_interference_function = new InterferenceFunction1DParaCrystal(15.0*Units::nanometer,5*Units::nanometer, 1e3*Units::nanometer);
@@ -1051,8 +1044,8 @@ ISample *StandardSamples::MesoCrystal1()
     complex_t n_air(1.0, 0.0);
     complex_t n_substrate(1.0-3.5e-6, 7.8e-8);
 
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air2", n_air);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate2", n_substrate);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air2", n_air);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate2", n_substrate);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
@@ -1093,9 +1086,9 @@ ISample *StandardSamples::MesoCrystal2()
     complex_t n_air(1.0, 0.0);
     complex_t n_substrate(1.0-7.57e-6, 1.73e-7);
 
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
-    const IMaterial *p_average_layer_material = MaterialManager::instance().addHomogeneousMaterial("Averagelayer", n_avg);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_average_layer_material = MaterialManager::getHomogeneousMaterial("Averagelayer", n_avg);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer avg_layer;
@@ -1147,8 +1140,8 @@ ISample *StandardSamples::FormFactor_Box()
     complex_t n_air(1.0, 0.0);
     complex_t n_substrate(1.0-6e-6, 2e-8);
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
@@ -1171,8 +1164,8 @@ ISample *StandardSamples::FormFactor_Cone()
     complex_t n_air(1.0, 0.0);
     complex_t n_substrate(1.0-6e-6, 2e-8);
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
@@ -1196,8 +1189,8 @@ ISample *StandardSamples::FormFactor_Sphere()
     complex_t n_air(1.0, 0.0);
     complex_t n_substrate(1.0-6e-6, 2e-8);
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
@@ -1220,8 +1213,8 @@ ISample *StandardSamples::FormFactor_Ellipsoid()
     complex_t n_air(1.0, 0.0);
     complex_t n_substrate(1.0-6e-6, 2e-8);
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
@@ -1245,8 +1238,8 @@ ISample *StandardSamples::FormFactor_FullSpheroid()
     complex_t n_air(1.0, 0.0);
     complex_t n_substrate(1.0-6e-5, 2e-8);
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
@@ -1270,8 +1263,8 @@ ISample *StandardSamples::FormFactor_HemiSpheroid()
     complex_t n_air(1.0, 0.0);
     complex_t n_substrate(1.0-6e-7, 2e-8);
     complex_t n_particle(1.0-6e-5, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
@@ -1294,7 +1287,7 @@ ISample *StandardSamples::FormFactor_Parallelpiped()
     complex_t n_air(1.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);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air11", n_air);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air11", n_air);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Particle shell_particle(n_particle_shell, new FormFactorParallelepiped(8*Units::nanometer, 8*Units::nanometer));
@@ -1319,7 +1312,7 @@ ISample *StandardSamples::FormFactor_Cylinder()
     complex_t n_air(1.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);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air11", n_air);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air11", n_air);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Particle shell_particle(n_particle_shell, new FormFactorCylinder(8*Units::nanometer, 8*Units::nanometer));
@@ -1343,8 +1336,8 @@ ISample *StandardSamples::FormFactor_Pyramid()
     complex_t n_air(1.0, 0.0);
     complex_t n_substrate(1.0-6e-6, 2e-8);
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
@@ -1369,8 +1362,8 @@ ISample *StandardSamples::FormFactor_Prism3()
     complex_t n_air(1.0, 0.0);
     complex_t n_substrate(1.0-7e-6, 2e-8);
     complex_t n_particle(1.0-8e-4, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
@@ -1393,8 +1386,8 @@ ISample *StandardSamples::FormFactor_Prism3()
      complex_t n_air(1.0, 0.0);
      complex_t n_substrate(1.0-6e-6, 2e-8);
      complex_t n_particle(1.0-6e-4, 2e-8);
-     const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
-     const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+     const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
+     const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate);
      Layer air_layer;
      air_layer.setMaterial(p_air_material);
      Layer substrate_layer;
diff --git a/App/src/TestConvolution.cpp b/App/src/TestConvolution.cpp
index 58015ed4bd8a9fc33ac9eea2fcbdcbb5e631701f..6dbcc36d78006c9356c99a4b98909398703d71c2 100644
--- a/App/src/TestConvolution.cpp
+++ b/App/src/TestConvolution.cpp
@@ -113,7 +113,7 @@ void TestConvolution::test_convolve1d()
     // drawing
     // --------------
     TCanvas *c1 = new TCanvas("c1_test_convolve1d","c1_test_convolve1d",1024, 768);
-    DrawHelper::instance().SetMagnifier(c1);
+    DrawHelper::SetMagnifier(c1);
     c1->Divide(3,3);
 
     // drawing signal
@@ -261,7 +261,7 @@ void TestConvolution::test_convolve2d()
 
     // drawing
     TCanvas *c1 = new TCanvas("c1_test_convolve2d","c1_test_convolve2d",1024, 768);
-    DrawHelper::instance().SetMagnifier(c1);
+    DrawHelper::SetMagnifier(c1);
     gStyle->SetPalette(1);
 
     c1->Divide(3,3);
diff --git a/App/src/TestDetectorResolution.cpp b/App/src/TestDetectorResolution.cpp
index 693ed06c9d7bf387d446e4d735c60a060fb38cab..2b15e1a348500d4c1554ad727f4b7e1bae3acd0e 100644
--- a/App/src/TestDetectorResolution.cpp
+++ b/App/src/TestDetectorResolution.cpp
@@ -58,8 +58,8 @@ void TestDetectorResolution::initializeSample()
     complex_t n_air(1.0, 0.0);
     complex_t n_substrate(1.0-5e-6, 2e-8);
     complex_t n_particle(1.0-5e-5, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
diff --git a/App/src/TestDiffuseReflection.cpp b/App/src/TestDiffuseReflection.cpp
index 05e487011dc23086074331fce037068101edfbbb..41a1c1bc38959701096e6530f28647d3f2bd3411 100644
--- a/App/src/TestDiffuseReflection.cpp
+++ b/App/src/TestDiffuseReflection.cpp
@@ -51,7 +51,7 @@ void TestDiffuseReflection::execute()
 
     std::vector<MultiLayer *> samples;
     for(size_t i_sample=0; i_sample<snames.size(); i_sample++){
-        samples.push_back( dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem(snames[i_sample])) );
+        samples.push_back( dynamic_cast<MultiLayer *>(SampleFactory::createSample(snames[i_sample])) );
     }
 
     kvector_t ki, kf;
@@ -200,7 +200,7 @@ void TestDiffuseReflection::draw()
     os << (ncall++) << std::endl;
     std::string cname = std::string("c1_test_diffuse_reflection");
     TCanvas *c1 = new TCanvas(cname.c_str(),"Diffuse reflection",1024,768);
-    DrawHelper::instance().SetMagnifier(c1);
+    DrawHelper::SetMagnifier(c1);
 
     c1->Divide(2,2);
     c1->cd(1);
diff --git a/App/src/TestFittingModule1.cpp b/App/src/TestFittingModule1.cpp
index 52b1171533fc0b9b23430321e295508af40fa1d8..261097fc72ce3cb0cf9a663454ecb719d9205860 100644
--- a/App/src/TestFittingModule1.cpp
+++ b/App/src/TestFittingModule1.cpp
@@ -97,7 +97,7 @@ void TestFittingModule1::initializeSample1()
     MultiLayer *p_multi_layer = new MultiLayer();
     complex_t n_air(1.0, 0.0);
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     ParticleDecoration particle_decoration( new Particle(n_particle, new FormFactorCylinder(5*Units::nanometer, 5*Units::nanometer)));
@@ -134,8 +134,8 @@ void TestFittingModule1::initializeSample2()
     complex_t n_air(1.0, 0.0);
     complex_t n_substrate(1.0-6e-6, 2e-8);
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
diff --git a/App/src/TestFittingModule2.cpp b/App/src/TestFittingModule2.cpp
index 9495c8a74287074e935f5ccc996aae5ecacf19dc..b545333a0ac6889000ab227c5a50bd6589944609 100644
--- a/App/src/TestFittingModule2.cpp
+++ b/App/src/TestFittingModule2.cpp
@@ -186,7 +186,7 @@ void TestFittingModule2::fit_example_mask()
     initializeRealData();
     mp_simulation->setDetectorResolutionFunction(new ResolutionFunction2DSimple(0.0002, 0.0002));
 
-    TCanvas *c1 = DrawHelper::instance().createAndRegisterCanvas("c1_test_meso_crystal", "mesocrystal");
+    TCanvas *c1 = DrawHelper::createAndRegisterCanvas("c1_test_meso_crystal", "mesocrystal");
     c1->cd(); gPad->SetLogz();
     c1->Divide(2,2);
 
@@ -296,8 +296,8 @@ ISample *TestFittingModule2::SampleBuilder::buildSample() const
     complex_t n_air(1.0, 0.0);
     complex_t n_substrate(1.0-6e-6, 2e-8);
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
diff --git a/App/src/TestFittingModule3.cpp b/App/src/TestFittingModule3.cpp
index aa13c00ca6636e903614bd1823bbc33e1165c5ce..d6d3008eaabd8bf8901adb724216825ed74e0a36 100644
--- a/App/src/TestFittingModule3.cpp
+++ b/App/src/TestFittingModule3.cpp
@@ -108,8 +108,8 @@ void TestFittingModule3::initializeSample()
     complex_t n_air(1.0, 0.0);
     complex_t n_substrate(1.0-6e-6, 2e-8);
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
diff --git a/App/src/TestFormFactors.cpp b/App/src/TestFormFactors.cpp
index 014719170d57d5c5eb3a64fa4bd365b2465ebdb9..16783e77260cab9ac48f8226720ec65c5137a345 100644
--- a/App/src/TestFormFactors.cpp
+++ b/App/src/TestFormFactors.cpp
@@ -12,7 +12,7 @@
 
 void TestFormFactors::execute()
 {
-    MultiLayer *sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("FormFactor_Box"));
+    MultiLayer *sample = dynamic_cast<MultiLayer *>(SampleFactory::createSample("FormFactor_Box"));
     Simulation simulation(mp_options);
     simulation.setSample(*sample);
     simulation.setDetectorParameters(100, 0.0*Units::degree, 2.0*Units::degree, 100, 0.0*Units::degree, 2.0*Units::degree, true);
@@ -22,55 +22,55 @@ void TestFormFactors::execute()
     OutputDataIOFactory::writeOutputData(*simulation.getOutputData(), Utils::FileSystem::GetHomePath()+"./Examples/FormFactors/this_Box.ima");
 
      //Cone
-     sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("FormFactor_Cone"));
+     sample = dynamic_cast<MultiLayer *>(SampleFactory::createSample("FormFactor_Cone"));
      simulation.setSample(*sample);
      simulation.runSimulation();
      OutputDataIOFactory::writeOutputData(*simulation.getOutputData(), Utils::FileSystem::GetHomePath()+"./Examples/FormFactors/this_Cone.ima");
 
      //Ellipsoid
-     sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("FormFactor_Ellipsoid"));
+     sample = dynamic_cast<MultiLayer *>(SampleFactory::createSample("FormFactor_Ellipsoid"));
      simulation.setSample(*sample);
      simulation.runSimulation();
      OutputDataIOFactory::writeOutputData(*simulation.getOutputData(), Utils::FileSystem::GetHomePath()+"./Examples/FormFactors/this_Ellipsoid.ima");
 
      //Sphere
-     sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("FormFactor_Sphere"));
+     sample = dynamic_cast<MultiLayer *>(SampleFactory::createSample("FormFactor_Sphere"));
      simulation.setSample(*sample);
      simulation.runSimulation();
      OutputDataIOFactory::writeOutputData(*simulation.getOutputData(), Utils::FileSystem::GetHomePath()+"./Examples/FormFactors/this_Sphere.ima");
 
      //Full Spheroid
-     sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("FormFactor_FullSpheroid"));
+     sample = dynamic_cast<MultiLayer *>(SampleFactory::createSample("FormFactor_FullSpheroid"));
      simulation.setSample(*sample);
      simulation.runSimulation();
      OutputDataIOFactory::writeOutputData(*simulation.getOutputData(), Utils::FileSystem::GetHomePath()+"./Examples/FormFactors/this_FullSpheroid.ima");
 
      //Hemi Spheroid
-     sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("FormFactor_HemiSpheroid"));
+     sample = dynamic_cast<MultiLayer *>(SampleFactory::createSample("FormFactor_HemiSpheroid"));
      simulation.setSample(*sample);
      simulation.runSimulation();
      OutputDataIOFactory::writeOutputData(*simulation.getOutputData(), Utils::FileSystem::GetHomePath()+"./Examples/FormFactors/this_HemiSpheroid.ima");
 
      //Pyramid
-     sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("FormFactor_Pyramid"));
+     sample = dynamic_cast<MultiLayer *>(SampleFactory::createSample("FormFactor_Pyramid"));
      simulation.setSample(*sample);
      simulation.runSimulation();
      OutputDataIOFactory::writeOutputData(*simulation.getOutputData(), Utils::FileSystem::GetHomePath()+"./Examples/FormFactors/this_Pyramid.ima");
 
      //Cylinder
-     sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("FormFactor_Cylinder"));
+     sample = dynamic_cast<MultiLayer *>(SampleFactory::createSample("FormFactor_Cylinder"));
      simulation.setSample(*sample);
      simulation.runSimulation();
      OutputDataIOFactory::writeOutputData(*simulation.getOutputData(), Utils::FileSystem::GetHomePath()+"./Examples/FormFactors/this_Cylinder.ima");
 
      //Full Sphere
-     sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("FormFactor_FullSphere"));
+     sample = dynamic_cast<MultiLayer *>(SampleFactory::createSample("FormFactor_FullSphere"));
      simulation.setSample(*sample);
      simulation.runSimulation();
      OutputDataIOFactory::writeOutputData(*simulation.getOutputData(), Utils::FileSystem::GetHomePath()+"./Examples/FormFactors/this_FullSphere.ima");
 
      //Prism3
-     sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("FormFactor_Prism3"));
+     sample = dynamic_cast<MultiLayer *>(SampleFactory::createSample("FormFactor_Prism3"));
      simulation.setSample(*sample);
      simulation.runSimulation();
      OutputDataIOFactory::writeOutputData(*simulation.getOutputData(), Utils::FileSystem::GetHomePath()+"./Examples/FormFactors/this_Prism3.ima");
@@ -92,7 +92,7 @@ void TestFormFactors::finalise()
 //    this_files.push_back(Utils::FileSystem::GetHomePath()+"./Examples/FormFactors/this_Prism3.ima");
 
     int ncomparison = (int)this_files.size();
-    TCanvas *c1 = DrawHelper::instance().createAndRegisterCanvas("Form Factors", "TestFormFactors");
+    TCanvas *c1 = DrawHelper::createAndRegisterCanvas("Form Factors", "TestFormFactors");
     c1->Divide(4,5);
 
     for(int i=0; i<ncomparison; i++) {
diff --git a/App/src/TestFresnelCoeff.cpp b/App/src/TestFresnelCoeff.cpp
index 671108d6276cfd03db2e05aa99d5b8a77b0f0d4f..cc9f1a87ccb26f27e46b2aaa82ed0e44df8155d1 100644
--- a/App/src/TestFresnelCoeff.cpp
+++ b/App/src/TestFresnelCoeff.cpp
@@ -146,7 +146,7 @@ void TestFresnelCoeff::draw_standard_samples()
     os << (ncall++) << std::endl;
     std::string cname = std::string("c1_test_fresnel_sample")+os.str();
     TCanvas *c1 = new TCanvas(cname.c_str(),"Fresnel Coefficients in Multilayer",1024,768);
-    DrawHelper::instance().SetMagnifier(c1);
+    DrawHelper::SetMagnifier(c1);
 
     // estimate subdivision of canvas (we need place for 'nlayers' and for one sample picture)
     int ndiv(2);
@@ -210,7 +210,7 @@ void TestFresnelCoeff::draw_standard_samples()
 
     // drawing sample geometry
     c1->cd((int)nlayers+1);
-    DrawHelper::instance().DrawMultilayer(mp_sample);
+    DrawHelper::DrawMultilayer(mp_sample);
 }
 
 /* ************************************************************************* */
@@ -305,7 +305,7 @@ void TestFresnelCoeff::draw_roughness_set()
     os << (ncall++) << std::endl;
     std::string cname = std::string("c1_test_fresnel_roughness")+os.str();
     TCanvas *c1 = new TCanvas(cname.c_str(),"Fresnel Coefficients in Multilayer",1024,768);
-    DrawHelper::instance().SetMagnifier(c1);
+    DrawHelper::SetMagnifier(c1);
 
     // estimate subdivision of canvas (we need place for 'nlayers' and for one sample picture)
     int ndiv(2);
@@ -360,6 +360,6 @@ void TestFresnelCoeff::draw_roughness_set()
 
     // drawing sample geometry
     c1->cd((int)nlayers+1);
-    DrawHelper::instance().DrawMultilayer(mp_sample);
+    DrawHelper::DrawMultilayer(mp_sample);
 }
 
diff --git a/App/src/TestIsGISAXS12.cpp b/App/src/TestIsGISAXS12.cpp
index ed64c18f319a7cae1b68660a4c9f6029377ee6fb..6126ea4642ed33d262871716d8decc1002e18a18 100644
--- a/App/src/TestIsGISAXS12.cpp
+++ b/App/src/TestIsGISAXS12.cpp
@@ -130,7 +130,7 @@ void TestIsGISAXS12::plot_isgisaxs_fit_results()
     print_axes(isgi_scans_smoothed);
     print_axes(isgi_results);
 
-    TCanvas *c1 = DrawHelper::instance().createAndRegisterCanvas("c1_isgisaxs_data", "Looking on IsGISAXS data and fit results", 768, 1024);
+    TCanvas *c1 = DrawHelper::createAndRegisterCanvas("c1_isgisaxs_data", "Looking on IsGISAXS data and fit results", 768, 1024);
     c1->Divide(2,3);
 
     // drawing real data with fine and coars granularity on top of each other
@@ -463,8 +463,8 @@ ISample *TestIsGISAXS12::TestSampleBuilder::buildSample() const
     MultiLayer *p_multi_layer = new MultiLayer();
 
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *air_material = MaterialManager::instance().addHomogeneousMaterial("Air", 1.0, 0.0);
-    const IMaterial *substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8);
+    const IMaterial *air_material = MaterialManager::getHomogeneousMaterial("Air", 1.0, 0.0);
+    const IMaterial *substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8);
 
     Layer air_layer(air_material);
 
diff --git a/App/src/TestIsGISAXS14.cpp b/App/src/TestIsGISAXS14.cpp
index b32eadc6135e3ea3517534149c260a3870f06ff6..de417835b81483aa93e1ee9e473a2009d9fcd3aa 100644
--- a/App/src/TestIsGISAXS14.cpp
+++ b/App/src/TestIsGISAXS14.cpp
@@ -19,7 +19,7 @@ TestIsGISAXS14::TestIsGISAXS14() : IFunctionalTest("TestIsGISAXS14")
 
 void TestIsGISAXS14::execute()
 {
-    MultiLayer *sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("IsGISAXS14_LayeredSpheresOnGradedInterface"));
+    MultiLayer *sample = dynamic_cast<MultiLayer *>(SampleFactory::createSample("IsGISAXS14_LayeredSpheresOnGradedInterface"));
 
     Simulation simulation(mp_options);
     simulation.setSample(*sample);
diff --git a/App/src/TestIsGISAXS5.cpp b/App/src/TestIsGISAXS5.cpp
index 330b6d3483dbb2c35a0fdaeb3bbf3c4d8cfcdaa1..ff4067bcc736245f90af2a06c629a80a5f062bb4 100644
--- a/App/src/TestIsGISAXS5.cpp
+++ b/App/src/TestIsGISAXS5.cpp
@@ -102,7 +102,7 @@ void TestIsGISAXS5::plot_isgisaxs_fit_results()
     IsGISAXSData::DataSet_t isgi_results;
     IsGISAXSData::read_outfile(getOutputPath()+"isgi_fitexample.out", isgi_results, IsGISAXSData::kSimResult);
 
-    TCanvas *c1 = DrawHelper::instance().createAndRegisterCanvas("c1_isgisaxs_data", "Looking on IsGISAXS data and fit results", 800, 500);
+    TCanvas *c1 = DrawHelper::createAndRegisterCanvas("c1_isgisaxs_data", "Looking on IsGISAXS data and fit results", 800, 500);
     c1->Divide(2,2);
 
     // drawing isgsaxs fit results on top of isgisaxs real data
@@ -272,8 +272,8 @@ ISample *TestIsGISAXS5::SampleBuilder::buildSample() const
     MultiLayer *p_multi_layer = new MultiLayer();
 
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *air_material = MaterialManager::instance().addHomogeneousMaterial("Air", 1.0, 0.0);
-    const IMaterial *substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8);
+    const IMaterial *air_material = MaterialManager::getHomogeneousMaterial("Air", 1.0, 0.0);
+    const IMaterial *substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8);
 
     Layer air_layer(air_material);
     double height = m_height_aspect_ratio*m_particle_radius;
diff --git a/App/src/TestMesoCrystal1.cpp b/App/src/TestMesoCrystal1.cpp
index 5c7da5c0df6faacf16a38f462d451ef1179ead36..5f025c7af960d27afc5b176965710bacd135439b 100644
--- a/App/src/TestMesoCrystal1.cpp
+++ b/App/src/TestMesoCrystal1.cpp
@@ -66,7 +66,7 @@ void TestMesoCrystal1::execute()
 
 //    IsGISAXSTools::drawLogOutputData(*mp_intensity_output, "c1_test_meso_crystal", "mesocrystal",
 //            "CONT4 Z", "mesocrystal");
-    TCanvas *c1 = DrawHelper::instance().createAndRegisterCanvas("sim_meso_crystal", "mesocrystal", 1024, 768);
+    TCanvas *c1 = DrawHelper::createAndRegisterCanvas("sim_meso_crystal", "mesocrystal", 1024, 768);
     c1->cd(); gPad->SetLogz();
     gPad->SetRightMargin(0.115);
     gPad->SetLeftMargin(0.13);
@@ -90,7 +90,7 @@ void TestMesoCrystal1::execute()
 
     std::string file_name = Utils::FileSystem::GetHomePath()+"Examples/MesoCrystals/ex02_fitspheres/004_230_P144_im_full_phitheta.txt.gz";
     OutputData<double > *real_data = OutputDataIOFactory::getOutputData(file_name);
-    TCanvas *c2 = DrawHelper::instance().createAndRegisterCanvas("exp_meso_crystal", "mesocrystal", 1024, 768);
+    TCanvas *c2 = DrawHelper::createAndRegisterCanvas("exp_meso_crystal", "mesocrystal", 1024, 768);
     c2->cd(); gPad->SetLogz();
     gPad->SetRightMargin(0.115);
     gPad->SetLeftMargin(0.13);
@@ -170,9 +170,9 @@ ISample* TestMesoCrystal1::SampleBuilder::buildSample() const
     complex_t n_air(1.0, 0.0);
     complex_t n_substrate(1.0-7.57e-6, 1.73e-7);
 
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
-    const IMaterial *p_average_layer_material = MaterialManager::instance().addHomogeneousMaterial("Averagelayer", n_avg);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_average_layer_material = MaterialManager::getHomogeneousMaterial("Averagelayer", n_avg);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer avg_layer;
diff --git a/App/src/TestMesoCrystal2.cpp b/App/src/TestMesoCrystal2.cpp
index 801d66e1f0a2f918087f6398c2aeafbb382222bf..f51bcc52b899d266032075106bf0d49333991578 100644
--- a/App/src/TestMesoCrystal2.cpp
+++ b/App/src/TestMesoCrystal2.cpp
@@ -137,7 +137,7 @@ void TestMesoCrystal2::run_fit()
 {
     initializeRealData();
 
-    TCanvas *c1 = DrawHelper::instance().createAndRegisterCanvas("c1_test_meso_crystal", "mesocrystal");
+    TCanvas *c1 = DrawHelper::createAndRegisterCanvas("c1_test_meso_crystal", "mesocrystal");
     c1->cd(); gPad->SetLogz();
     gPad->SetRightMargin(0.115);
     gPad->SetLeftMargin(0.115);
@@ -543,9 +543,9 @@ ISample* TestMesoCrystal2::SampleBuilder::buildSample() const
     complex_t n_air(1.0, 0.0);
     complex_t n_substrate(1.0-7.57e-6, 1.73e-7);
 
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
-    const IMaterial *p_average_layer_material = MaterialManager::instance().addHomogeneousMaterial("Averagelayer", n_avg);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_average_layer_material = MaterialManager::getHomogeneousMaterial("Averagelayer", n_avg);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer avg_layer;
diff --git a/App/src/TestMiscellaneous.cpp b/App/src/TestMiscellaneous.cpp
index 69af9966c93e580f38f6852d472f51c513dfa97c..8f963ec52a9a3971842760a322d6b23473eaac7b 100644
--- a/App/src/TestMiscellaneous.cpp
+++ b/App/src/TestMiscellaneous.cpp
@@ -194,8 +194,8 @@ void TestMiscellaneous::test_FastSin()
 /* ************************************************************************* */
 void TestMiscellaneous::test_DrawMesocrystal()
 {
-    MultiLayer *m_sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("MesoCrystal2"));
-    DrawHelper::instance().DrawMesoCrystal(m_sample);
+    MultiLayer *m_sample = dynamic_cast<MultiLayer *>(SampleFactory::createSample("MesoCrystal2"));
+    DrawHelper::DrawMesoCrystal(m_sample);
 }
 
 
@@ -290,7 +290,7 @@ void TestMiscellaneous::test_FormFactor()
     }
 
     TCanvas *c1_xy = new TCanvas("c1_xy","c1_xy",1024,768);
-    DrawHelper::instance().SetMagnifier(c1_xy);
+    DrawHelper::SetMagnifier(c1_xy);
     c1_xy->Divide(3,3);
     int ndiv=9;
     for(int i=0; i<ndiv; i++) {
@@ -301,7 +301,7 @@ void TestMiscellaneous::test_FormFactor()
     }
 
     TCanvas *c1_xz = new TCanvas("c1_xz","c1_xz",1024,768);
-    DrawHelper::instance().SetMagnifier(c1_xz);
+    DrawHelper::SetMagnifier(c1_xz);
     c1_xz->Divide(3,3);
     for(int i=0; i<ndiv; i++) {
         c1_xz->cd(i+1);
@@ -310,7 +310,7 @@ void TestMiscellaneous::test_FormFactor()
     }
 
     TCanvas *c1_yz = new TCanvas("c1_yz","c1_yz",1024,768);
-    DrawHelper::instance().SetMagnifier(c1_yz);
+    DrawHelper::SetMagnifier(c1_yz);
     c1_yz->Divide(3,3);
     for(int i=0; i<ndiv; i++) {
         c1_yz->cd(i+1);
@@ -327,7 +327,7 @@ void TestMiscellaneous::test_FormFactor()
 /* ************************************************************************* */
 void TestMiscellaneous::test_DoubleToComplexInterpolatingFunction()
 {
-    MultiLayer *sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("MultilayerOffspecTestcase1a"));
+    MultiLayer *sample = dynamic_cast<MultiLayer *>(SampleFactory::createSample("MultilayerOffspecTestcase1a"));
 
     OutputData<double > *data_alpha = new OutputData<double >;
     data_alpha->addAxis(NDetector2d::ALPHA_AXIS_NAME, 200, 0.0*Units::degree, 2.0*Units::degree);
diff --git a/App/src/TestMultiLayerRoughness.cpp b/App/src/TestMultiLayerRoughness.cpp
index 77af4a3248067033e886fa3b72e78da9c654c51c..a0fb0bc1c4628c2cf9215d115ff8e1ca7d86c7e9 100644
--- a/App/src/TestMultiLayerRoughness.cpp
+++ b/App/src/TestMultiLayerRoughness.cpp
@@ -22,7 +22,7 @@ TestMultiLayerRoughness::TestMultiLayerRoughness()
 void TestMultiLayerRoughness::execute()
 {
 
-    ISample *sample = SampleFactory::instance().createItem("MultilayerOffspecTestcase1a");
+    ISample *sample = SampleFactory::createSample("MultilayerOffspecTestcase1a");
 
     std::cout << *sample << std::endl;
     sample->print_structure();
diff --git a/App/src/TestPerformance.cpp b/App/src/TestPerformance.cpp
index e7e84e4eb9908a8d3e09578511e5e71b5c171589..865e4c1dc8171f2957350118f449877eecc65181 100644
--- a/App/src/TestPerformance.cpp
+++ b/App/src/TestPerformance.cpp
@@ -159,7 +159,7 @@ void PerfTest_FresnelCoeff::initialise(ProgramOptions *p_options)
 {
     IFunctionalTest::initialise(p_options);
     if(m_sample) delete m_sample;
-    m_sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("SimpleMultilayer"));
+    m_sample = dynamic_cast<MultiLayer *>(SampleFactory::createSample("SimpleMultilayer"));
 }
 
 void PerfTest_FresnelCoeff::execute()
@@ -182,7 +182,7 @@ void PerfTest_Pyramid::initialise(ProgramOptions *p_options)
     IFunctionalTest::initialise(p_options);
     // sample
     if(m_sample) delete m_sample;
-    m_sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("IsGISAXS9_Pyramid"));
+    m_sample = dynamic_cast<MultiLayer *>(SampleFactory::createSample("IsGISAXS9_Pyramid"));
 
     // simulation
     if(m_simulation) delete m_simulation;
@@ -206,7 +206,7 @@ void PerfTest_RotatedPyramid::initialise(ProgramOptions *p_options)
     IFunctionalTest::initialise(p_options);
     // sample
     if(m_sample) delete m_sample;
-    m_sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("IsGISAXS9_RotatedPyramid"));
+    m_sample = dynamic_cast<MultiLayer *>(SampleFactory::createSample("IsGISAXS9_RotatedPyramid"));
 
     // simulation
     if(m_simulation) delete m_simulation;
@@ -231,7 +231,7 @@ void PerfTest_MesoCrystal::initialise(ProgramOptions *p_options)
     IFunctionalTest::initialise(p_options);
     // sample
     if(m_sample) delete m_sample;
-    m_sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("MesoCrystal1"));
+    m_sample = dynamic_cast<MultiLayer *>(SampleFactory::createSample("MesoCrystal1"));
 
     // simulation
     m_simulation = new Simulation(p_options);
diff --git a/App/src/TestRootTree.cpp b/App/src/TestRootTree.cpp
index 84e6e88bc2bc445cc41d048af271765de667e34d..f19fbcdba80ac1d09d8ce03e423487c887d71ded 100644
--- a/App/src/TestRootTree.cpp
+++ b/App/src/TestRootTree.cpp
@@ -207,7 +207,7 @@ void TestRootTree::simple_write()
     delete mp_sample;
     delete mp_data;
 
-    mp_sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("IsGISAXS9_Pyramid"));
+    mp_sample = dynamic_cast<MultiLayer *>(SampleFactory::createSample("IsGISAXS9_Pyramid"));
 
     // setting simulation
     mp_simulation = new Simulation(mp_options);
@@ -382,9 +382,9 @@ void TestRootTree::initializeMesoCrystal(double meso_alpha, double meso_phi, dou
     complex_t n_air(1.0, 0.0);
     complex_t n_substrate(1.0-7.57e-6, 1.73e-7);
 
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
-    const IMaterial *p_average_layer_material = MaterialManager::instance().addHomogeneousMaterial("Averagelayer", n_avg);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_average_layer_material = MaterialManager::getHomogeneousMaterial("Averagelayer", n_avg);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer avg_layer;
diff --git a/App/src/main.cpp b/App/src/main.cpp
index dc358800fddd5a19d826f6d0b8b74e7e8ee55d59..99e6d56f298076f32a277803d5f927ce767433d1 100644
--- a/App/src/main.cpp
+++ b/App/src/main.cpp
@@ -47,20 +47,20 @@ int main(int argc, char **argv)
     // running functional tests
     if( command_line_options.find("all") ) {
         // running all registered tests
-        FunctionalTestFactory::instance().execute_all(&command_line_options);
+        FunctionalTestFactory::execute_all(&command_line_options);
 
     } else {
         // loop over functional tests, run test if it's name is present in command line
-        FunctionalTestFactory::iterator it = FunctionalTestFactory::instance().begin();
-        for(; it!= FunctionalTestFactory::instance().end(); ++it) {
+        FunctionalTestFactory::iterator it = FunctionalTestFactory::begin();
+        for(; it!= FunctionalTestFactory::end(); ++it) {
             if( command_line_options.find( (*it).first ) )
-                FunctionalTestFactory::instance().execute( (*it).first, &command_line_options );
+                FunctionalTestFactory::execute( (*it).first, &command_line_options );
         }
     }
 
     // saving report in pdf and root
     if( command_line_options.find("report") ) {
-        DrawHelper::instance().saveReport();
+        DrawHelper::saveReport();
     }
 
     // exit now if there is unrecognized options or plead for help
diff --git a/BornAgain.pro b/BornAgain.pro
index 3dd0f400bef1b0999e86a869bc093175431de517..6ed31fa1f10e4701bea9a7e0e1e0a16b1f925807 100644
--- a/BornAgain.pro
+++ b/BornAgain.pro
@@ -14,5 +14,3 @@ TestCore.depends = ThirdParty/gtest
 
 # means that compilation will be in the listed order
 CONFIG += ordered
-
-
diff --git a/BornAgain.pro.user b/BornAgain.pro.user
deleted file mode 100644
index bc4de7e19d00bc389e6e6436989aa19ba4ea11d9..0000000000000000000000000000000000000000
--- a/BornAgain.pro.user
+++ /dev/null
@@ -1,236 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE QtCreatorProject>
-<!-- Written by Qt Creator 2.5.0, 2013-03-20T16:50:00. -->
-<qtcreator>
- <data>
-  <variable>ProjectExplorer.Project.ActiveTarget</variable>
-  <value type="int">0</value>
- </data>
- <data>
-  <variable>ProjectExplorer.Project.EditorSettings</variable>
-  <valuemap type="QVariantMap">
-   <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
-   <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
-   <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
-   <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
-    <value type="QString" key="language">Cpp</value>
-    <valuemap type="QVariantMap" key="value">
-     <value type="QString" key="CurrentPreferences">CppGlobal</value>
-    </valuemap>
-   </valuemap>
-   <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
-    <value type="QString" key="language">QmlJS</value>
-    <valuemap type="QVariantMap" key="value">
-     <value type="QString" key="CurrentPreferences">QmlJSGlobal</value>
-    </valuemap>
-   </valuemap>
-   <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
-   <value type="QByteArray" key="EditorConfiguration.Codec">System</value>
-   <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
-   <value type="int" key="EditorConfiguration.IndentSize">4</value>
-   <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
-   <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
-   <value type="int" key="EditorConfiguration.PaddingMode">1</value>
-   <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
-   <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
-   <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
-   <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
-   <value type="int" key="EditorConfiguration.TabSize">8</value>
-   <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
-   <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
-   <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
-   <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
-   <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
-   <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
-  </valuemap>
- </data>
- <data>
-  <variable>ProjectExplorer.Project.PluginSettings</variable>
-  <valuemap type="QVariantMap"/>
- </data>
- <data>
-  <variable>ProjectExplorer.Project.Target.0</variable>
-  <valuemap type="QVariantMap">
-   <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
-   <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
-   <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Target.DesktopTarget</value>
-   <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
-   <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
-   <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
-   <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
-    <value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">ProjectExplorer.ToolChain.Gcc:{a8b05062-7041-4762-8d1a-f9db6c4b09b4}</value>
-    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
-     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
-      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
-      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
-      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
-      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
-      <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
-      <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">false</value>
-      <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
-      <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
-     </valuemap>
-     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
-      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
-      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
-      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
-      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
-      <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
-      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
-      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
-     </valuemap>
-     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
-     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
-     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
-     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
-    </valuemap>
-    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
-     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
-      <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
-      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
-      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
-      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
-      <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
-      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
-      <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
-     </valuemap>
-     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
-     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
-     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
-     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
-    </valuemap>
-    <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
-    <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
-    <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
-    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.2 (System) Release</value>
-    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
-    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
-    <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
-    <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/jwu/BornAgain</value>
-    <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">4</value>
-    <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value>
-   </valuemap>
-   <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
-   <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
-    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
-     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
-     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
-     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
-     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
-    </valuemap>
-    <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
-    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">No deployment</value>
-    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
-    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
-   </valuemap>
-   <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
-   <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
-    <value type="bool" key="Analyzer.Project.UseGlobal">true</value>
-    <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
-    <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
-    <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
-    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
-    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
-    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
-    <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
-    <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
-    <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
-    <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
-    <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
-    <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
-    <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
-    <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
-     <value type="int">0</value>
-     <value type="int">1</value>
-     <value type="int">2</value>
-     <value type="int">3</value>
-     <value type="int">4</value>
-     <value type="int">5</value>
-     <value type="int">6</value>
-     <value type="int">7</value>
-     <value type="int">8</value>
-     <value type="int">9</value>
-     <value type="int">10</value>
-     <value type="int">11</value>
-     <value type="int">12</value>
-     <value type="int">13</value>
-     <value type="int">14</value>
-    </valuelist>
-    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">App</value>
-    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
-    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration</value>
-    <value type="int" key="Qt4ProjectManager.Qt4RunConfiguration.BaseEnvironmentBase">2</value>
-    <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
-    <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">App/App.pro</value>
-    <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
-    <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
-    <valuelist type="QVariantList" key="Qt4ProjectManager.Qt4RunConfiguration.UserEnvironmentChanges"/>
-    <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
-    <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
-    <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
-    <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
-    <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
-   </valuemap>
-   <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.1">
-    <value type="bool" key="Analyzer.Project.UseGlobal">true</value>
-    <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
-    <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
-    <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
-    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
-    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
-    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
-    <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
-    <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
-    <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
-    <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
-    <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
-    <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
-    <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
-    <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
-     <value type="int">0</value>
-     <value type="int">1</value>
-     <value type="int">2</value>
-     <value type="int">3</value>
-     <value type="int">4</value>
-     <value type="int">5</value>
-     <value type="int">6</value>
-     <value type="int">7</value>
-     <value type="int">8</value>
-     <value type="int">9</value>
-     <value type="int">10</value>
-     <value type="int">11</value>
-     <value type="int">12</value>
-     <value type="int">13</value>
-     <value type="int">14</value>
-    </valuelist>
-    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">TestCore</value>
-    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
-    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration</value>
-    <value type="int" key="Qt4ProjectManager.Qt4RunConfiguration.BaseEnvironmentBase">2</value>
-    <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
-    <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">Tests/UnitTests/TestCore/TestCore.pro</value>
-    <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
-    <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
-    <valuelist type="QVariantList" key="Qt4ProjectManager.Qt4RunConfiguration.UserEnvironmentChanges"/>
-    <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
-    <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
-    <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
-    <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
-    <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
-   </valuemap>
-   <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">2</value>
-  </valuemap>
- </data>
- <data>
-  <variable>ProjectExplorer.Project.TargetCount</variable>
-  <value type="int">1</value>
- </data>
- <data>
-  <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
-  <value type="QString">{c4a6b95c-3b9c-4c72-843d-3448de28d0b7}</value>
- </data>
- <data>
-  <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
-  <value type="int">11</value>
- </data>
-</qtcreator>
diff --git a/Core/Algorithms/inc/DecouplingApproximationStrategy.h b/Core/Algorithms/inc/DecouplingApproximationStrategy.h
index 6a2a64ece468cd0483a32fc3d8a972b14f384582..88144dfc5d1c51eba085e7cd98bd0922a26e806d 100644
--- a/Core/Algorithms/inc/DecouplingApproximationStrategy.h
+++ b/Core/Algorithms/inc/DecouplingApproximationStrategy.h
@@ -21,15 +21,17 @@
 
 class DecouplingApproximationStrategy : public IInterferenceFunctionStrategy
 {
-public:
+  public:
     DecouplingApproximationStrategy(SimulationParameters sim_params);
     virtual ~DecouplingApproximationStrategy() {}
 
-    virtual void init(const SafePointerVector<FormFactorInfo> &form_factor_infos,
-            const SafePointerVector<IInterferenceFunction> &ifs);
-    virtual double evaluate(const cvector_t &k_i, const Bin1DCVector &k_f_bin,
-            double alpha_i, double alpha_f) const;
-private:
+    virtual void init(
+        const SafePointerVector<FormFactorInfo>& form_factor_infos,
+        const SafePointerVector<IInterferenceFunction> &ifs);
+    virtual double evaluate(
+        const cvector_t &k_i, const Bin1DCVector &k_f_bin,
+        double alpha_i, double alpha_f) const;
+  private:
     bool checkVectorSizes() const;
 };
 
diff --git a/Core/Algorithms/src/DecouplingApproximationStrategy.cpp b/Core/Algorithms/src/DecouplingApproximationStrategy.cpp
index f41d51c2b00bef133c19e2086f2b5d299266d64e..f57898ab6587a902f7036ce72cb0b90c77dde130 100644
--- a/Core/Algorithms/src/DecouplingApproximationStrategy.cpp
+++ b/Core/Algorithms/src/DecouplingApproximationStrategy.cpp
@@ -16,8 +16,9 @@
 #include "DecouplingApproximationStrategy.h"
 #include "Exceptions.h"
 
-DecouplingApproximationStrategy::DecouplingApproximationStrategy(SimulationParameters sim_params)
-: IInterferenceFunctionStrategy(sim_params)
+DecouplingApproximationStrategy::DecouplingApproximationStrategy(
+    SimulationParameters sim_params)
+  : IInterferenceFunctionStrategy(sim_params)
 {
 }
 
@@ -31,13 +32,15 @@ void DecouplingApproximationStrategy::init(
     }
 }
 
-double DecouplingApproximationStrategy::evaluate(const cvector_t& k_i,
-        const Bin1DCVector& k_f_bin, double alpha_i, double alpha_f) const
+double DecouplingApproximationStrategy::evaluate(
+    const cvector_t& k_i, const Bin1DCVector& k_f_bin,
+    double alpha_i, double alpha_f) const
 {
     double intensity = 0.0;
     complex_t amplitude = complex_t(0.0, 0.0);
     for (size_t i=0; i<m_ff_infos.size(); ++i) {
-        complex_t ff = m_ff_infos[i]->mp_ff->evaluate(k_i, k_f_bin, alpha_i, alpha_f);
+        complex_t ff =
+            m_ff_infos[i]->mp_ff->evaluate(k_i, k_f_bin, alpha_i, alpha_f);
         double fraction = m_ff_infos[i]->m_abundance;
         amplitude += fraction*ff;
         intensity += fraction*(std::norm(ff));
diff --git a/Core/Algorithms/src/MultiLayerRoughnessDWBASimulation.cpp b/Core/Algorithms/src/MultiLayerRoughnessDWBASimulation.cpp
index 22ba9f691d4941aca18f18036df7f8145f0f05b3..6a70a4b01c546280913c97f80c05283993d96b44 100644
--- a/Core/Algorithms/src/MultiLayerRoughnessDWBASimulation.cpp
+++ b/Core/Algorithms/src/MultiLayerRoughnessDWBASimulation.cpp
@@ -19,7 +19,8 @@
 #include "DWBADiffuseReflection.h"
 #include "ExperimentConstants.h"
 
-MultiLayerRoughnessDWBASimulation::MultiLayerRoughnessDWBASimulation(const MultiLayer *p_multi_layer)
+MultiLayerRoughnessDWBASimulation::MultiLayerRoughnessDWBASimulation(
+    const MultiLayer *p_multi_layer)
 {
     mp_multi_layer = p_multi_layer->clone();
     mp_RT_function.resize(mp_multi_layer->getNumberOfLayers(), 0);
@@ -31,7 +32,8 @@ MultiLayerRoughnessDWBASimulation::~MultiLayerRoughnessDWBASimulation()
     delete mp_multi_layer;
 }
 
-void MultiLayerRoughnessDWBASimulation::setReflectionTransmissionFunction(size_t i_layer, const IDoubleToPairOfComplexMap &RT_function)
+void MultiLayerRoughnessDWBASimulation::setReflectionTransmissionFunction(
+    size_t i_layer, const IDoubleToPairOfComplexMap &RT_function)
 {
     delete mp_RT_function[i_layer];
     mp_RT_function[i_layer] = RT_function.clone();
@@ -48,8 +50,10 @@ void MultiLayerRoughnessDWBASimulation::run()
     DWBASimulation::iterator it_intensity = begin();
     while ( it_intensity != m_dwba_intensity.end() )
     {
-        double phi_f = getDWBAIntensity().getValueOfAxis(s_phi_f, it_intensity.getIndex());
-        double alpha_f = getDWBAIntensity().getValueOfAxis(s_alpha_f, it_intensity.getIndex());
+        double phi_f = getDWBAIntensity().getValueOfAxis(
+            s_phi_f, it_intensity.getIndex());
+        double alpha_f = getDWBAIntensity().getValueOfAxis(
+            s_alpha_f, it_intensity.getIndex());
         cvector_t k_f;
         k_f.setLambdaAlphaPhi(lambda, alpha_f, phi_f);
         *it_intensity = evaluate(m_ki, k_f, -m_alpha_i, alpha_f);
@@ -57,8 +61,9 @@ void MultiLayerRoughnessDWBASimulation::run()
     }
 }
 
-double MultiLayerRoughnessDWBASimulation::evaluate(const cvector_t &k_i, const cvector_t &k_f,
-        double alpha_i, double alpha_f)
+double MultiLayerRoughnessDWBASimulation::evaluate(
+    const cvector_t &k_i, const cvector_t &k_f,
+    double alpha_i, double alpha_f)
 {
     kvector_t ki_real(k_i.x().real(), k_i.y().real(), k_i.z().real());
     kvector_t kf_real(k_f.x().real(), k_f.y().real(), k_f.z().real());
@@ -77,9 +82,11 @@ double MultiLayerRoughnessDWBASimulation::evaluate(const cvector_t &k_i, const c
     }
 
     for(size_t i=0; i<mp_multi_layer->getNumberOfLayers()-1; i++){
-        const LayerRoughness *rough = mp_multi_layer->getLayerBottomInterface(i)->getRoughness();
+        const LayerRoughness *rough =
+            mp_multi_layer->getLayerBottomInterface(i)->getRoughness();
         if(rough) {
-            autocorr += std::norm( rterm[i] ) * std::norm( sterm[i] ) * rough->getSpectralFun(q);
+            autocorr += std::norm( rterm[i] ) * std::norm( sterm[i] ) *
+                rough->getSpectralFun(q);
         } else {
         }
     }
@@ -89,23 +96,28 @@ double MultiLayerRoughnessDWBASimulation::evaluate(const cvector_t &k_i, const c
         for(size_t j=0; j<mp_multi_layer->getNumberOfLayers()-1; j++){
             for(size_t k=0; k<mp_multi_layer->getNumberOfLayers()-1; k++) {
                 if(j==k) continue;
-                crosscorr += rterm[j]*sterm[j]*rterm[k]*mp_multi_layer->getCrossCorrSpectralFun(q,j,k)*std::conj(sterm[k]);
+                crosscorr += rterm[j]*sterm[j]*rterm[k]*
+                    mp_multi_layer->getCrossCorrSpectralFun(q,j,k)*
+                    std::conj(sterm[k]);
             }
         }
     }
 
-    return (autocorr+crosscorr.real())*k_i.mag2()/16./M_PI;
+    //! @TODO clarify complex vs double
+    return (autocorr+crosscorr.real())*k_i.mag2().real()/16./M_PI;
 }
 
-complex_t MultiLayerRoughnessDWBASimulation::get_refractive_term(size_t ilayer) const
+complex_t MultiLayerRoughnessDWBASimulation::get_refractive_term(
+    size_t ilayer) const
 {
     complex_t n1 = mp_multi_layer->getLayer(ilayer)->getRefractiveIndex();
     complex_t n2 = mp_multi_layer->getLayer(ilayer+1)->getRefractiveIndex();
     return n1*n1-n2*n2;
 }
 
-complex_t MultiLayerRoughnessDWBASimulation::get_sum4terms(size_t ilayer, const cvector_t &k_i, const cvector_t &k_f,
-        double alpha_i, double alpha_f)
+complex_t MultiLayerRoughnessDWBASimulation::get_sum4terms(
+    size_t ilayer, const cvector_t &k_i, const cvector_t &k_f,
+    double alpha_i, double alpha_f)
 {
     complex_t qz1 =  k_i.z() + k_f.z();
     complex_t qz2 =  k_i.z() - k_f.z();
@@ -115,7 +127,8 @@ complex_t MultiLayerRoughnessDWBASimulation::get_sum4terms(size_t ilayer, const
     complexpair_t ai_RT = mp_RT_function[ilayer+1]->evaluate(alpha_i);
     complexpair_t af_RT = mp_RT_function[ilayer+1]->evaluate(alpha_f);
 
-    double sigma = mp_multi_layer->getLayerBottomInterface(ilayer)->getRoughness()->getSigma();
+    double sigma = mp_multi_layer->getLayerBottomInterface(ilayer)->
+        getRoughness()->getSigma();
     double sigma2 = -0.5*sigma*sigma;
     complex_t term1 = ai_RT.second * af_RT.second * std::exp( sigma2*qz1*qz1 );
     complex_t term2 = ai_RT.second * af_RT.first * std::exp( sigma2*qz2*qz2 );
diff --git a/Core/Algorithms/src/OpticalFresnel.cpp b/Core/Algorithms/src/OpticalFresnel.cpp
index fbbb77b7ca411a8431917fe858ea357339f56e86..be612b42084ac6e33fe7581968d04f22c6357f27 100644
--- a/Core/Algorithms/src/OpticalFresnel.cpp
+++ b/Core/Algorithms/src/OpticalFresnel.cpp
@@ -141,7 +141,8 @@ void OpticalFresnel::calculateX2(const MultiLayer &sample, MultiLayerCoeff_t &co
         }
         double d = i==0 ? 0.0 : sample.getLayerThickness(i);
         complex_t exp_factor;
-        if((coeff[i].kz*d*2.0).imag() >= -std::log(Numeric::double_min)) {
+        if((coeff[i].kz*d*2.0).imag() >=
+           -std::log(std::numeric_limits<double>::min())) {
             exp_factor = complex_t(0,0);
         }
         else {
@@ -204,7 +205,7 @@ void OpticalFresnel::calculateRT2(const MultiLayer &sample, MultiLayerCoeff_t &c
             coeff[i+1].R = complex_t(0,0);
         } else {
             complex_t log_R = std::log(numerator_R) - std::log(complex_t(1,0)+coeff[i].r*coeff[i+1].X) + log_prefactor;
-            if(log_R.real() < std::log(Numeric::double_min)) {
+            if(log_R.real() < std::log(std::numeric_limits<double>::min())) {
                 coeff[i+1].R = complex_t(0,0);
             } else {
                 coeff[i+1].R = std::exp(log_R);
@@ -217,7 +218,7 @@ void OpticalFresnel::calculateRT2(const MultiLayer &sample, MultiLayerCoeff_t &c
             coeff[i+1].T = complex_t(0,0);
         } else {
             complex_t log_T = std::log(numerator_T) - std::log(complex_t(1,0)+coeff[i].r*coeff[i+1].X) + log_prefactor;
-            if(log_T.real() < std::log(Numeric::double_min)) {
+            if(log_T.real() < std::log(std::numeric_limits<double>::min())) {
                 coeff[i+1].T = complex_t(0,0);
             } else {
                 coeff[i+1].T = std::exp(log_T);
diff --git a/Core/Core.pro b/Core/Core.pro
index b17ca306323d4a8252dac2617471458669638919..2f8a9a6dabac8dabbf23b1ee046cbf45ec608ae1 100644
--- a/Core/Core.pro
+++ b/Core/Core.pro
@@ -28,7 +28,6 @@ SOURCES += \
     Tools/src/IFactory.cpp \
     Tools/src/IObserver.cpp \
     Tools/src/IParameterized.cpp \
-    Tools/src/ISingleton.cpp \
     Tools/src/MathFunctions.cpp \
     Tools/src/MessageSvc.cpp \
     Tools/src/OutputData.cpp \
@@ -97,7 +96,6 @@ SOURCES += \
     \
     Samples/src/Crystal.cpp \
     Samples/src/DiffuseParticleInfo.cpp \
-    Samples/src/HomogeneousMaterial.cpp \
     Samples/src/ICompositeIterator.cpp \
     Samples/src/ICompositeSample.cpp \
     Samples/src/IMaterial.cpp \
diff --git a/Core/FormFactors/inc/FormFactorDecoratorDebyeWaller.h b/Core/FormFactors/inc/FormFactorDecoratorDebyeWaller.h
index 9201aa4bdd2f9844f128076696a857cf083a7df9..dcb1ca1acb3f394b5c1363d7a52be7e7bf35dc91 100644
--- a/Core/FormFactors/inc/FormFactorDecoratorDebyeWaller.h
+++ b/Core/FormFactors/inc/FormFactorDecoratorDebyeWaller.h
@@ -23,18 +23,24 @@
 class FormFactorDecoratorDebyeWaller : public IFormFactorDecorator
 {
 public:
-    FormFactorDecoratorDebyeWaller(IFormFactor *p_form_factor, double dw_factor);
-    FormFactorDecoratorDebyeWaller(IFormFactor *p_form_factor, double dw_h_factor, double dw_r_factor);
-    FormFactorDecoratorDebyeWaller(const IFormFactor &p_form_factor, double dw_h_factor, double dw_r_factor);
+    FormFactorDecoratorDebyeWaller(
+        IFormFactor *p_form_factor, double dw_factor);
+    FormFactorDecoratorDebyeWaller(
+        IFormFactor *p_form_factor, double dw_h_factor, double dw_r_factor);
+    FormFactorDecoratorDebyeWaller(
+        const IFormFactor &p_form_factor,
+        double dw_h_factor, double dw_r_factor);
     virtual FormFactorDecoratorDebyeWaller *clone() const;
     virtual ~FormFactorDecoratorDebyeWaller() {}
 
-    virtual complex_t evaluate(const cvector_t &k_i, const Bin1DCVector &k_f_bin, double alpha_i, double alpha_f) const;
+    virtual complex_t evaluate(
+        const cvector_t &k_i, const Bin1DCVector &k_f_bin,
+        double alpha_i, double alpha_f) const;
 
     virtual int getNumberOfStochasticParameters() const;
 
 protected:
-    //! initialize pool parameters, i.e. register some of class members for later access via parameter pool
+    //! register some class members for later access via parameter pool
     virtual void init_parameters() {
         getParameterPool()->clear();
         getParameterPool()->registerParameter("hfactor", &m_h_dw_factor);
@@ -67,22 +73,26 @@ inline FormFactorDecoratorDebyeWaller::FormFactorDecoratorDebyeWaller(
 }
 
 inline FormFactorDecoratorDebyeWaller::FormFactorDecoratorDebyeWaller(
-        const IFormFactor &p_form_factor, double dw_h_factor, double dw_r_factor)
-: IFormFactorDecorator(p_form_factor.clone())
-, m_h_dw_factor(dw_h_factor)
-, m_r_dw_factor(dw_r_factor)
+        const IFormFactor &p_form_factor,
+        double dw_h_factor, double dw_r_factor)
+  : IFormFactorDecorator(p_form_factor.clone())
+  , m_h_dw_factor(dw_h_factor)
+  , m_r_dw_factor(dw_r_factor)
 {
     setName("FormFactorDecoratorDebyeWaller");
     init_parameters();
 }
 
-inline FormFactorDecoratorDebyeWaller* FormFactorDecoratorDebyeWaller::clone() const
+inline FormFactorDecoratorDebyeWaller*
+FormFactorDecoratorDebyeWaller::clone() const
 {
-    return new FormFactorDecoratorDebyeWaller(mp_form_factor->clone(), m_h_dw_factor, m_r_dw_factor);
+    return new FormFactorDecoratorDebyeWaller(
+        mp_form_factor->clone(), m_h_dw_factor, m_r_dw_factor);
 }
 
-inline complex_t FormFactorDecoratorDebyeWaller::evaluate(const cvector_t& k_i,
-        const Bin1DCVector& k_f_bin, double alpha_i, double alpha_f) const
+inline complex_t FormFactorDecoratorDebyeWaller::evaluate(
+    const cvector_t& k_i, const Bin1DCVector& k_f_bin,
+    double alpha_i, double alpha_f) const
 {
     cvector_t q = k_i - k_f_bin.getMidPoint();
     double qr2 = std::norm(q.x()) + std::norm(q.y());
@@ -91,7 +101,8 @@ inline complex_t FormFactorDecoratorDebyeWaller::evaluate(const cvector_t& k_i,
     return dw*mp_form_factor->evaluate(k_i, k_f_bin, alpha_i, alpha_f);
 }
 
-inline int FormFactorDecoratorDebyeWaller::getNumberOfStochasticParameters() const
+inline int
+FormFactorDecoratorDebyeWaller::getNumberOfStochasticParameters() const
 {
     return mp_form_factor->getNumberOfStochasticParameters();
 }
diff --git a/Core/FormFactors/inc/IFormFactorBorn.h b/Core/FormFactors/inc/IFormFactorBorn.h
index 9bef405f94fc21855eef318f5ec778250d80a453..7ccfefa6eb989060fa79f40efd5da261edbd8b68 100644
--- a/Core/FormFactors/inc/IFormFactorBorn.h
+++ b/Core/FormFactors/inc/IFormFactorBorn.h
@@ -27,13 +27,15 @@ public:
     virtual ~IFormFactorBorn() {}
     virtual IFormFactorBorn *clone() const=0;
 
-    virtual complex_t evaluate(const cvector_t &k_i, const Bin1DCVector &k_f_bin, double alpha_i, double alpha_f) const;
+    virtual complex_t evaluate(
+        const cvector_t &k_i, const Bin1DCVector &k_f_bin,
+        double alpha_i, double alpha_f) const;
 
     //! evaluate scattering amplitude for complex wavevector
     //! @param q  wavevector transfer \f$q\equiv k_i-k_f\f$
     virtual complex_t evaluate_for_q(const cvector_t &q) const=0;
 
-    //! override volume getter to avoid infinite loop caused by big bin approximation
+    //! override volume getter to avoid endless loop caused by big bin approximation
     virtual double getVolume() const;
 
 protected:
@@ -47,14 +49,16 @@ private:
     //! determine if a large bin size approximation should be used
     bool useLargeBinApproximation(const Bin1DCVector &q_bin) const;
 
-    //! calculates an approximate intensity that does not contain rapid oscillations
+    //! approximate intensity that does not contain rapid oscillations
     double bigRadialIntegrand(double qR, void *params) const;
 
     //! calculates the integrated intensity along the z-direction
     double bigZPartIntegral(double qH2) const;
 };
 
-inline complex_t IFormFactorBorn::evaluate(const cvector_t& k_i, const Bin1DCVector& k_f_bin, double alpha_i, double alpha_f) const
+inline complex_t IFormFactorBorn::evaluate(
+    const cvector_t& k_i, const Bin1DCVector& k_f_bin,
+    double alpha_i, double alpha_f) const
 {
     (void)alpha_i;
     (void)alpha_f;
@@ -71,7 +75,8 @@ inline double IFormFactorBorn::getVolume() const
     return std::abs(evaluate_for_q(zero));
 }
 
-inline bool IFormFactorBorn::useLargeBinApproximation(const Bin1DCVector &q_bin) const
+inline bool IFormFactorBorn::useLargeBinApproximation(
+    const Bin1DCVector &q_bin) const
 {
     double delta_qr = std::abs( q_bin.getDelta().magxy() );
     double delta_qz = std::abs( q_bin.getDelta().z() );
diff --git a/Core/Geometry/inc/BasicVector3D.h b/Core/Geometry/inc/BasicVector3D.h
index 1fa97496eff920ac405075ee99ec8cd6312eb2c1..e497183ca85aa85a92c79994a188838f2a3938c7 100755
--- a/Core/Geometry/inc/BasicVector3D.h
+++ b/Core/Geometry/inc/BasicVector3D.h
@@ -30,7 +30,6 @@
 
 #include <cmath>
 #include <complex>
-#include "Exceptions.h"
 
 namespace Geometry {
 
@@ -130,20 +129,20 @@ template<class T> class BasicVector3D {
     // ----
 
     //! Return squared magnitude squared of the vector.
-    double mag2() const;
+    T mag2() const; //!< @TODO: return type always double
 
     //! Return magnitude of the vector.
-    double mag() const;
+    T mag() const; //!< @TODO: return type always double
 
     // --------------------------------------------
     // Cylindrical and spherical coordinate systems
     // --------------------------------------------
 
     //! Return squared distance from z axis.
-    double magxy2() const;
+    T magxy2() const; //!< @TODO: return type always double
 
     //! Return distance from z axis.
-    double magxy() const;
+    T magxy() const; //!< @TODO: return type always double
 
     //! Return azimuth angle.
     double phi() const;
@@ -152,7 +151,7 @@ template<class T> class BasicVector3D {
     double theta() const;
 
     //! Return cosine of polar angle.
-    double cosTheta() const;
+    T cosTheta() const; //!< @TODO: return type always double
 
     //! Scale to given magnitude.
     void setMag(double ma);
@@ -162,7 +161,7 @@ template<class T> class BasicVector3D {
     // -------------------
 
     //! Scalar product.
-    double dot(const BasicVector3D<T>& v) const;
+    T dot(const BasicVector3D<T>& v) const; //!< @TODO: return type always double
 
     //! Vector product.
     BasicVector3D<T> cross(const BasicVector3D<T>& v) const;
diff --git a/Core/Geometry/src/BasicVector3D.cpp b/Core/Geometry/src/BasicVector3D.cpp
index 54d55b7be2e286bc3c2eb50e075de5dd902407a3..93c60d6c9ece2489331e4f22173897c1dd8724ec 100755
--- a/Core/Geometry/src/BasicVector3D.cpp
+++ b/Core/Geometry/src/BasicVector3D.cpp
@@ -44,9 +44,23 @@ double BasicVector3D<double>::mag2() const
     return x()*x()+y()*y()+z()*z();
 }
 
+//! @TODO eliminate this, it is plain wrong
+template<>
+complex_t BasicVector3D<complex_t>::mag2() const
+{
+    return x()*x()+y()*y()+z()*z();
+}
+
 //! Return magnitude of the vector.
-template<class T>
-double BasicVector3D<T>::mag() const
+template<>
+double BasicVector3D<double>::mag() const
+{
+    return std::sqrt(mag2());
+}
+
+//! @TODO eliminate this, it is plain wrong
+template<>
+complex_t BasicVector3D<complex_t>::mag() const
 {
     return std::sqrt(mag2());
 }
@@ -62,9 +76,23 @@ double BasicVector3D<double>::magxy2() const
     return x()*x()+y()*y();
 }
 
+//! @TODO eliminate this, it is plain wrong
+template<>
+complex_t BasicVector3D<complex_t>::magxy2() const
+{
+    return x()*x()+y()*y();
+}
+
 //! Return distance from z axis.
-template<class T>
-double BasicVector3D<T>::magxy() const
+template<>
+double BasicVector3D<double>::magxy() const
+{
+    return std::sqrt(magxy2());
+}
+
+//! @TODO eliminate this, it is plain wrong
+template<>
+complex_t BasicVector3D<complex_t>::magxy() const
 {
     return std::sqrt(magxy2());
 }
@@ -92,6 +120,14 @@ double BasicVector3D<double>::cosTheta() const
     return std::abs(ma) == 0 ? 1 : z()/ma;
 }
 
+//! @TODO eliminate this, it is plain wrong
+template<>
+complex_t BasicVector3D<complex_t>::cosTheta() const
+{
+    complex_t ma = mag();
+    return std::abs(ma) == 0 ? 1 : z()/ma;
+}
+
 //! Scale to given magnitude.
 template<class T>
 void BasicVector3D<T>::setMag(double ma)
@@ -115,6 +151,14 @@ double BasicVector3D<double>::dot(
     return x()*v.x()+y()*v.y()+z()*v.z();
 }
 
+//! @TODO check usage: unlikely to be correct
+template<>
+complex_t BasicVector3D<complex_t>::dot(
+    const BasicVector3D<complex_t>& v) const
+{
+    return x()*v.x()+y()*v.y()+z()*v.z();
+}
+
 //! Vector product.
 template<>
 BasicVector3D<double> BasicVector3D<double>::cross(
@@ -125,6 +169,16 @@ BasicVector3D<double> BasicVector3D<double>::cross(
                                  x()*v.y()-v.x()*y());
 }
 
+//! @TODO check usage: unlikely to be correct
+template<>
+BasicVector3D<complex_t> BasicVector3D<complex_t>::cross(
+    const BasicVector3D<complex_t>& v) const
+{
+    return BasicVector3D<complex_t>(y()*v.z()-v.y()*z(),
+                                 z()*v.x()-v.z()*x(),
+                                 x()*v.y()-v.x()*y());
+}
+
 //! Return square of transverse component with respect to given axis.
 template<>
 double BasicVector3D<double>::perp2(const BasicVector3D<double>& v) const
diff --git a/Core/PythonAPI/inc/IndexVector3D.pypp.h b/Core/PythonAPI/inc/IndexVector3D.pypp.h
new file mode 100644
index 0000000000000000000000000000000000000000..46800856e6b72c22a372fab9b556a98241fdd7b2
--- /dev/null
+++ b/Core/PythonAPI/inc/IndexVector3D.pypp.h
@@ -0,0 +1,8 @@
+// This file has been generated by Py++.
+
+#ifndef IndexVector3D_hpp__pyplusplus_wrapper
+#define IndexVector3D_hpp__pyplusplus_wrapper
+
+void register_IndexVector3D_class();
+
+#endif//IndexVector3D_hpp__pyplusplus_wrapper
diff --git a/Core/PythonAPI/src/ISelectionRule.pypp.cpp b/Core/PythonAPI/src/ISelectionRule.pypp.cpp
index 78fd3b2b638c6caac80114f8f733dcf8d82dcbf9..d469269468f780b0939e355ce80e7d4290f91f09 100644
--- a/Core/PythonAPI/src/ISelectionRule.pypp.cpp
+++ b/Core/PythonAPI/src/ISelectionRule.pypp.cpp
@@ -91,7 +91,7 @@ struct ISelectionRule_wrapper : ISelectionRule, bp::wrapper< ISelectionRule > {
         return func_clone(  );
     }
 
-    virtual bool coordinateSelected( ::Coordinate3D< int > const & coordinate ) const {
+    virtual bool coordinateSelected( ::IndexVector3D const & coordinate ) const {
         bp::override func_coordinateSelected = this->get_override( "coordinateSelected" );
         return func_coordinateSelected( boost::ref(coordinate) );
     }
@@ -107,7 +107,7 @@ void register_ISelectionRule_class(){
             , bp::return_value_policy< bp::manage_new_object >() )    
         .def( 
             "coordinateSelected"
-            , bp::pure_virtual( (bool ( ::ISelectionRule::* )( ::Coordinate3D< int > const & ) const)(&::ISelectionRule::coordinateSelected) )
+            , bp::pure_virtual( (bool ( ::ISelectionRule::* )( ::IndexVector3D const & ) const)(&::ISelectionRule::coordinateSelected) )
             , ( bp::arg("coordinate") ) );
 
 }
diff --git a/Core/PythonAPI/src/IndexVector3D.pypp.cpp b/Core/PythonAPI/src/IndexVector3D.pypp.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d20c1039258ea7b3695ca7d7ce9baf431de5faef
--- /dev/null
+++ b/Core/PythonAPI/src/IndexVector3D.pypp.cpp
@@ -0,0 +1,218 @@
+// This file has been generated by Py++.
+
+#include "Macros.h"
+GCC_DIAG_OFF(unused-parameter);
+GCC_DIAG_OFF(missing-field-initializers);
+#include "boost/python.hpp"
+#include "boost/python/suite/indexing/vector_indexing_suite.hpp"
+GCC_DIAG_ON(unused-parameter);
+GCC_DIAG_ON(missing-field-initializers);
+#include "BasicVector3D.h"
+#include "Bin.h"
+#include "Crystal.h"
+#include "DiffuseParticleInfo.h"
+#include "FTDistributions.h"
+#include "FormFactorBox.h"
+#include "FormFactorCrystal.h"
+#include "FormFactorCylinder.h"
+#include "FormFactorDecoratorDebyeWaller.h"
+#include "FormFactorFullSphere.h"
+#include "FormFactorGauss.h"
+#include "FormFactorLorentz.h"
+#include "FormFactorParallelepiped.h"
+#include "FormFactorPrism3.h"
+#include "FormFactorPyramid.h"
+#include "FormFactorSphereGaussianRadius.h"
+#include "HomogeneousMaterial.h"
+#include "ICloneable.h"
+#include "IClusteredParticles.h"
+#include "ICompositeSample.h"
+#include "IDecoration.h"
+#include "IFormFactor.h"
+#include "IFormFactorBorn.h"
+#include "IFormFactorDecorator.h"
+#include "IInterferenceFunction.h"
+#include "IMaterial.h"
+#include "IParameterized.h"
+#include "ISample.h"
+#include "ISampleBuilder.h"
+#include "ISelectionRule.h"
+#include "ISingleton.h"
+#include "Instrument.h"
+#include "InterferenceFunction1DParaCrystal.h"
+#include "InterferenceFunction2DLattice.h"
+#include "InterferenceFunction2DParaCrystal.h"
+#include "InterferenceFunctionNone.h"
+#include "Lattice.h"
+#include "Lattice2DIFParameters.h"
+#include "LatticeBasis.h"
+#include "Layer.h"
+#include "LayerDecorator.h"
+#include "LayerRoughness.h"
+#include "Lattice2DIFParameters.h"
+#include "MaterialManager.h"
+#include "MesoCrystal.h"
+#include "MultiLayer.h"
+#include "OpticalFresnel.h"
+#include "ParameterPool.h"
+#include "Particle.h"
+#include "ParticleBuilder.h"
+#include "ParticleCoreShell.h"
+#include "ParticleDecoration.h"
+#include "ParticleInfo.h"
+#include "PositionParticleInfo.h"
+#include "PythonOutputData.h"
+#include "PythonPlusplusHelper.h"
+#include "RealParameterWrapper.h"
+#include "Simulation.h"
+#include "SimulationParameters.h"
+#include "IStochasticParameter.h"
+#include "StochasticGaussian.h"
+#include "StochasticSampledParameter.h"
+#include "StochasticDoubleGate.h"
+#include "Transform3D.h"
+#include "Types.h"
+#include "Units.h"
+#include "IndexVector3D.pypp.h"
+
+namespace bp = boost::python;
+
+void register_IndexVector3D_class(){
+
+    { //::Geometry::BasicVector3D< int >
+        typedef bp::class_< Geometry::BasicVector3D< int > > IndexVector3D_exposer_t;
+        IndexVector3D_exposer_t IndexVector3D_exposer = IndexVector3D_exposer_t( "IndexVector3D", bp::init< >() );
+        bp::scope IndexVector3D_scope( IndexVector3D_exposer );
+        bp::scope().attr("X") = (int)Geometry::BasicVector3D<int>::X;
+        bp::scope().attr("Y") = (int)Geometry::BasicVector3D<int>::Y;
+        bp::scope().attr("Z") = (int)Geometry::BasicVector3D<int>::Z;
+        bp::scope().attr("NUM_COORDINATES") = (int)Geometry::BasicVector3D<int>::NUM_COORDINATES;
+        bp::scope().attr("SIZE") = (int)Geometry::BasicVector3D<int>::SIZE;
+        IndexVector3D_exposer.def( bp::init< int const &, int const &, int const & >(( bp::arg("x1"), bp::arg("y1"), bp::arg("z1") )) );
+        IndexVector3D_exposer.def( bp::self *= bp::other< double >() );
+        IndexVector3D_exposer.def( bp::self += bp::self );
+        IndexVector3D_exposer.def( bp::self -= bp::self );
+        IndexVector3D_exposer.def( bp::self /= bp::other< double >() );
+        { //::Geometry::BasicVector3D< int >::operator=
+        
+            typedef Geometry::BasicVector3D< int > exported_class_t;
+            typedef ::Geometry::BasicVector3D< int > & ( exported_class_t::*assign_function_type )( ::Geometry::BasicVector3D< int > const & ) ;
+            
+            IndexVector3D_exposer.def( 
+                "assign"
+                , assign_function_type( &::Geometry::BasicVector3D< int >::operator= )
+                , ( bp::arg("v") )
+                , bp::return_self< >() );
+        
+        }
+        { //::Geometry::BasicVector3D< int >::operator[]
+        
+            typedef Geometry::BasicVector3D< int > exported_class_t;
+            typedef int ( exported_class_t::*__getitem___function_type )( int ) const;
+            
+            IndexVector3D_exposer.def( 
+                "__getitem__"
+                , __getitem___function_type( &::Geometry::BasicVector3D< int >::operator[] )
+                , ( bp::arg("i") ) );
+        
+        }
+        { //::Geometry::BasicVector3D< int >::operator[]
+        
+            typedef Geometry::BasicVector3D< int > exported_class_t;
+            typedef int & ( exported_class_t::*__getitem___function_type )( int ) ;
+            
+            IndexVector3D_exposer.def( 
+                "__getitem__"
+                , __getitem___function_type( &::Geometry::BasicVector3D< int >::operator[] )
+                , ( bp::arg("i") )
+                , bp::return_value_policy< bp::copy_non_const_reference >() );
+        
+        }
+        { //::Geometry::BasicVector3D< int >::setLambdaAlphaPhi
+        
+            typedef Geometry::BasicVector3D< int > exported_class_t;
+            typedef void ( exported_class_t::*setLambdaAlphaPhi_function_type )( int const &,int const &,int const & ) ;
+            
+            IndexVector3D_exposer.def( 
+                "setLambdaAlphaPhi"
+                , setLambdaAlphaPhi_function_type( &::Geometry::BasicVector3D< int >::setLambdaAlphaPhi )
+                , ( bp::arg("_lambda"), bp::arg("_alpha"), bp::arg("_phi") ) );
+        
+        }
+        { //::Geometry::BasicVector3D< int >::setX
+        
+            typedef Geometry::BasicVector3D< int > exported_class_t;
+            typedef void ( exported_class_t::*setX_function_type )( int const & ) ;
+            
+            IndexVector3D_exposer.def( 
+                "setX"
+                , setX_function_type( &::Geometry::BasicVector3D< int >::setX )
+                , ( bp::arg("a") ) );
+        
+        }
+        { //::Geometry::BasicVector3D< int >::setXYZ
+        
+            typedef Geometry::BasicVector3D< int > exported_class_t;
+            typedef void ( exported_class_t::*setXYZ_function_type )( int const &,int const &,int const & ) ;
+            
+            IndexVector3D_exposer.def( 
+                "setXYZ"
+                , setXYZ_function_type( &::Geometry::BasicVector3D< int >::setXYZ )
+                , ( bp::arg("x1"), bp::arg("y1"), bp::arg("z1") ) );
+        
+        }
+        { //::Geometry::BasicVector3D< int >::setY
+        
+            typedef Geometry::BasicVector3D< int > exported_class_t;
+            typedef void ( exported_class_t::*setY_function_type )( int const & ) ;
+            
+            IndexVector3D_exposer.def( 
+                "setY"
+                , setY_function_type( &::Geometry::BasicVector3D< int >::setY )
+                , ( bp::arg("a") ) );
+        
+        }
+        { //::Geometry::BasicVector3D< int >::setZ
+        
+            typedef Geometry::BasicVector3D< int > exported_class_t;
+            typedef void ( exported_class_t::*setZ_function_type )( int const & ) ;
+            
+            IndexVector3D_exposer.def( 
+                "setZ"
+                , setZ_function_type( &::Geometry::BasicVector3D< int >::setZ )
+                , ( bp::arg("a") ) );
+        
+        }
+        { //::Geometry::BasicVector3D< int >::x
+        
+            typedef Geometry::BasicVector3D< int > exported_class_t;
+            typedef int ( exported_class_t::*x_function_type )(  ) const;
+            
+            IndexVector3D_exposer.def( 
+                "x"
+                , x_function_type( &::Geometry::BasicVector3D< int >::x ) );
+        
+        }
+        { //::Geometry::BasicVector3D< int >::y
+        
+            typedef Geometry::BasicVector3D< int > exported_class_t;
+            typedef int ( exported_class_t::*y_function_type )(  ) const;
+            
+            IndexVector3D_exposer.def( 
+                "y"
+                , y_function_type( &::Geometry::BasicVector3D< int >::y ) );
+        
+        }
+        { //::Geometry::BasicVector3D< int >::z
+        
+            typedef Geometry::BasicVector3D< int > exported_class_t;
+            typedef int ( exported_class_t::*z_function_type )(  ) const;
+            
+            IndexVector3D_exposer.def( 
+                "z"
+                , z_function_type( &::Geometry::BasicVector3D< int >::z ) );
+        
+        }
+    }
+
+}
diff --git a/Core/PythonAPI/src/MaterialManager.pypp.cpp b/Core/PythonAPI/src/MaterialManager.pypp.cpp
index 3d21b05957f78442a1c418a3b53ac34d8d3b7508..726c5f087cd974e2cfec7c9fcbec54b864307cbd 100644
--- a/Core/PythonAPI/src/MaterialManager.pypp.cpp
+++ b/Core/PythonAPI/src/MaterialManager.pypp.cpp
@@ -81,23 +81,22 @@ void register_MaterialManager_class(){
 
     bp::class_< MaterialManager, bp::bases< ISingleton< MaterialManager > >, boost::noncopyable >( "MaterialManager", bp::no_init )    
         .def( 
-            "addHomogeneousMaterial"
-            , (::IMaterial const * ( ::MaterialManager::* )( ::std::string const &,::complex_t const & ) )( &::MaterialManager::addHomogeneousMaterial )
+            "getHomogeneousMaterial"
+            , (::IMaterial const * (*)( ::std::string const &,::complex_t const & ))( &::MaterialManager::getHomogeneousMaterial )
             , ( bp::arg("name"), bp::arg("refractive_index") )
             , bp::return_value_policy< bp::reference_existing_object >() )    
         .def( 
-            "addHomogeneousMaterial"
-            , (::IMaterial const * ( ::MaterialManager::* )( ::std::string const &,double,double ) )( &::MaterialManager::addHomogeneousMaterial )
+            "getHomogeneousMaterial"
+            , (::IMaterial const * (*)( ::std::string const &,double,double ))( &::MaterialManager::getHomogeneousMaterial )
             , ( bp::arg("name"), bp::arg("refractive_index_real"), bp::arg("refractive_index_imag") )
             , bp::return_value_policy< bp::reference_existing_object >() )    
-        .def( 
-            "clear"
-            , (void ( ::MaterialManager::* )(  ) )( &::MaterialManager::clear ) )    
         .def( 
             "getMaterial"
-            , (::IMaterial const * ( ::MaterialManager::* )( ::std::string const & ) )( &::MaterialManager::getMaterial )
+            , (::IMaterial const * (*)( ::std::string const & ))( &::MaterialManager::getMaterial )
             , ( bp::arg("name") )
             , bp::return_value_policy< bp::reference_existing_object >() )    
+        .staticmethod( "getHomogeneousMaterial" )    
+        .staticmethod( "getMaterial" )    
         .def( bp::self_ns::str( bp::self ) );
 
 }
diff --git a/Core/PythonAPI/src/PythonInterface_free_functions.pypp.cpp b/Core/PythonAPI/src/PythonInterface_free_functions.pypp.cpp
index 402e4bbf9b0274a62748d96d83a1e465767f08e3..29ea6cdd2800ace6baba417787464fd3c2be56af 100644
--- a/Core/PythonAPI/src/PythonInterface_free_functions.pypp.cpp
+++ b/Core/PythonAPI/src/PythonInterface_free_functions.pypp.cpp
@@ -86,7 +86,7 @@ void register_free_functions(){
         bp::def( 
             "CrossProduct"
             , CrossProduct_function_type( &::Geometry::CrossProduct )
-            , ( bp::arg("vectorLeft"), bp::arg("vectorRight") ) );
+            , ( bp::arg("left"), bp::arg("right") ) );
     
     }
 
@@ -97,17 +97,6 @@ void register_free_functions(){
         bp::def( 
             "CrossProduct"
             , CrossProduct_function_type( &::Geometry::CrossProduct )
-            , ( bp::arg("vectorLeft"), bp::arg("vectorRight") ) );
-    
-    }
-
-    { //::Geometry::DotProduct
-    
-        typedef ::std::complex< double > ( *DotProduct_function_type )( ::Geometry::BasicVector3D< std::complex< double > > const &,::Geometry::BasicVector3D< std::complex< double > > const & );
-        
-        bp::def( 
-            "DotProduct"
-            , DotProduct_function_type( &::Geometry::DotProduct )
             , ( bp::arg("left"), bp::arg("right") ) );
     
     }
diff --git a/Core/PythonAPI/src/PythonModule.cpp b/Core/PythonAPI/src/PythonModule.cpp
index 35afc18e51542021f1141bf7c37927dcf7671a13..8ff7048b275d6379a7c28723cf24f43730911ddd 100644
--- a/Core/PythonAPI/src/PythonModule.cpp
+++ b/Core/PythonAPI/src/PythonModule.cpp
@@ -1,18 +1,3 @@
-// ************************************************************************** //
-//
-//  BornAgain: simulate and fit scattering at grazing incidence
-//
-//! @file      PythonAPI/src/PythonModule.cpp
-//! @brief     calls BOOST_PYTHON_MODULE to register many functions
-//!
-//! @homepage  http://apps.jcns.fz-juelich.de/BornAgain
-//! @license   GNU General Public License v3 or higher (see COPYING)
-//! @copyright Forschungszentrum Jülich GmbH 2013
-//! @authors   Scientific Computing Group at MLZ Garching
-//! @authors   C. Durniak, G. Pospelov, W. Van Herck, J. Wuttke 
-//
-// ************************************************************************** //
-
 #include "Python.h"
 #define PY_ARRAY_UNIQUE_SYMBOL BORNAGAIN_PYTHONAPI_ARRAY 
 #include "numpy/arrayobject.h"
@@ -48,6 +33,7 @@
 #include "IFTDistribution2D.pypp.h" 
 #include "IInterferenceFunction.pypp.h" 
 #include "IMaterial.pypp.h" 
+#include "IndexVector3D.pypp.h" 
 #include "Instrument.pypp.h" 
 #include "InterferenceFunction1DParaCrystal.pypp.h" 
 #include "InterferenceFunction2DLattice.pypp.h" 
@@ -152,6 +138,7 @@ BOOST_PYTHON_MODULE(libBornAgainCore){
     register_FormFactorPyramid_class();
     register_FormFactorSphereGaussianRadius_class();
     register_kvector_t_class();
+    register_IndexVector3D_class();
     register_cvector_t_class();
     register_Reflect3D_class();
     register_ReflectX3D_class();
diff --git a/Core/PythonAPI/src/Rotate3D.pypp.cpp b/Core/PythonAPI/src/Rotate3D.pypp.cpp
index 49f2f4fe6936eca043af2a4b72ff7a29321101a4..78e67b1db190ba03f97dd586fb905a0eb10cf27a 100644
--- a/Core/PythonAPI/src/Rotate3D.pypp.cpp
+++ b/Core/PythonAPI/src/Rotate3D.pypp.cpp
@@ -79,6 +79,7 @@ namespace bp = boost::python;
 
 void register_Rotate3D_class(){
 
-    bp::class_< Geometry::Rotate3D, bp::bases< Geometry::Transform3D > >( "Rotate3D", bp::init< >() );
+    bp::class_< Geometry::Rotate3D, bp::bases< Geometry::Transform3D > >( "Rotate3D", bp::init< >() )    
+        .def( bp::init< double, Geometry::Vector3D< double > const & >(( bp::arg("a"), bp::arg("v") )) );
 
 }
diff --git a/Core/PythonAPI/src/SimpleSelectionRule.pypp.cpp b/Core/PythonAPI/src/SimpleSelectionRule.pypp.cpp
index 53373d4006232a587b6c1bee62850fa0500572b0..cfcbf8400f8b30416080013b89a06711a82caf39 100644
--- a/Core/PythonAPI/src/SimpleSelectionRule.pypp.cpp
+++ b/Core/PythonAPI/src/SimpleSelectionRule.pypp.cpp
@@ -105,7 +105,7 @@ struct SimpleSelectionRule_wrapper : SimpleSelectionRule, bp::wrapper< SimpleSel
         return SimpleSelectionRule::clone( );
     }
 
-    virtual bool coordinateSelected( ::Coordinate3D< int > const & coordinate ) const  {
+    virtual bool coordinateSelected( ::IndexVector3D const & coordinate ) const  {
         if( bp::override func_coordinateSelected = this->get_override( "coordinateSelected" ) )
             return func_coordinateSelected( boost::ref(coordinate) );
         else{
@@ -113,7 +113,7 @@ struct SimpleSelectionRule_wrapper : SimpleSelectionRule, bp::wrapper< SimpleSel
         }
     }
     
-    bool default_coordinateSelected( ::Coordinate3D< int > const & coordinate ) const  {
+    bool default_coordinateSelected( ::IndexVector3D const & coordinate ) const  {
         return SimpleSelectionRule::coordinateSelected( boost::ref(coordinate) );
     }
 
@@ -129,8 +129,8 @@ void register_SimpleSelectionRule_class(){
             , bp::return_value_policy< bp::manage_new_object >() )    
         .def( 
             "coordinateSelected"
-            , (bool ( ::SimpleSelectionRule::* )( ::Coordinate3D< int > const & ) const)(&::SimpleSelectionRule::coordinateSelected)
-            , (bool ( SimpleSelectionRule_wrapper::* )( ::Coordinate3D< int > const & ) const)(&SimpleSelectionRule_wrapper::default_coordinateSelected)
+            , (bool ( ::SimpleSelectionRule::* )( ::IndexVector3D const & ) const)(&::SimpleSelectionRule::coordinateSelected)
+            , (bool ( SimpleSelectionRule_wrapper::* )( ::IndexVector3D const & ) const)(&SimpleSelectionRule_wrapper::default_coordinateSelected)
             , ( bp::arg("coordinate") ) );
 
 }
diff --git a/Core/PythonAPI/src/Transform3D.pypp.cpp b/Core/PythonAPI/src/Transform3D.pypp.cpp
index 4bb2e75a9ca430a792e95c3636c74f5fcc0e46a7..4021e8f5c9c0634c1950ad172edc11faf6d4e291 100644
--- a/Core/PythonAPI/src/Transform3D.pypp.cpp
+++ b/Core/PythonAPI/src/Transform3D.pypp.cpp
@@ -83,7 +83,11 @@ void register_Transform3D_class(){
         typedef bp::class_< Geometry::Transform3D > Transform3D_exposer_t;
         Transform3D_exposer_t Transform3D_exposer = Transform3D_exposer_t( "Transform3D", bp::init< >() );
         bp::scope Transform3D_scope( Transform3D_exposer );
-        bp::class_< Geometry::Transform3D::Transform3D_row, boost::noncopyable >( "Transform3D_row", bp::no_init );
+        bp::class_< Geometry::Transform3D::Transform3D_row, boost::noncopyable >( "Transform3D_row", bp::init< Geometry::Transform3D const &, int >(( bp::arg("r"), bp::arg("i") )) )    
+            .def( 
+                "__getitem__"
+                , (double ( ::Geometry::Transform3D::Transform3D_row::* )( int ) const)( &::Geometry::Transform3D::Transform3D_row::operator[] )
+                , ( bp::arg("jj") ) );
         Transform3D_exposer.def( bp::init< Geometry::Transform3D const & >(( bp::arg("m") )) );
         { //::Geometry::Transform3D::dx
         
@@ -165,6 +169,16 @@ void register_Transform3D_class(){
         
         }
         Transform3D_exposer.def( bp::self == bp::self );
+        { //::Geometry::Transform3D::operator[]
+        
+            typedef ::Geometry::Transform3D::Transform3D_row const ( ::Geometry::Transform3D::*__getitem___function_type )( int ) const;
+            
+            Transform3D_exposer.def( 
+                "__getitem__"
+                , __getitem___function_type( &::Geometry::Transform3D::operator[] )
+                , ( bp::arg("i") ) );
+        
+        }
         { //::Geometry::Transform3D::setIdentity
         
             typedef void ( ::Geometry::Transform3D::*setIdentity_function_type )(  ) ;
diff --git a/Core/PythonAPI/src/cvector_t.pypp.cpp b/Core/PythonAPI/src/cvector_t.pypp.cpp
index 93159c32d1db62b35d9306b885e77af2840481f2..be59e9aae0fb8844c9d719c01cba2dc9c71ace4e 100644
--- a/Core/PythonAPI/src/cvector_t.pypp.cpp
+++ b/Core/PythonAPI/src/cvector_t.pypp.cpp
@@ -189,26 +189,6 @@ void register_cvector_t_class(){
                 , ( bp::arg("i") )
                 , bp::return_internal_reference< >() );
         
-        }
-        { //::Geometry::BasicVector3D< std::complex< double > >::r
-        
-            typedef Geometry::BasicVector3D< std::complex< double > > exported_class_t;
-            typedef ::std::complex< double > ( exported_class_t::*r_function_type )(  ) const;
-            
-            cvector_t_exposer.def( 
-                "r"
-                , r_function_type( &::Geometry::BasicVector3D< std::complex< double > >::mag ) );
-        
-        }
-        { //::Geometry::BasicVector3D< std::complex< double > >::rho
-        
-            typedef Geometry::BasicVector3D< std::complex< double > > exported_class_t;
-            typedef ::std::complex< double > ( exported_class_t::*rho_function_type )(  ) const;
-            
-            cvector_t_exposer.def( 
-                "rho"
-                , rho_function_type( &::Geometry::BasicVector3D< std::complex< double > >::magxy ) );
-        
         }
         { //::Geometry::BasicVector3D< std::complex< double > >::setLambdaAlphaPhi
         
@@ -308,7 +288,6 @@ void register_cvector_t_class(){
         
         }
         cvector_t_exposer.def( bp::self != bp::self );
-        cvector_t_exposer.def( bp::self * bp::self );
         cvector_t_exposer.def( bp::self + bp::self );
         cvector_t_exposer.def( +bp::self );
         cvector_t_exposer.def( bp::self - bp::self );
diff --git a/Core/PythonAPI/src/kvector_t.pypp.cpp b/Core/PythonAPI/src/kvector_t.pypp.cpp
index c57276aae1902eaec75f5d695890e08c78c585e8..2f8e8e6b28c0bffab42975f99437f7aa9f5248bb 100644
--- a/Core/PythonAPI/src/kvector_t.pypp.cpp
+++ b/Core/PythonAPI/src/kvector_t.pypp.cpp
@@ -89,27 +89,6 @@ void register_kvector_t_class(){
         bp::scope().attr("NUM_COORDINATES") = (int)Geometry::BasicVector3D<double>::NUM_COORDINATES;
         bp::scope().attr("SIZE") = (int)Geometry::BasicVector3D<double>::SIZE;
         kvector_t_exposer.def( bp::init< double const &, double const &, double const & >(( bp::arg("x1"), bp::arg("y1"), bp::arg("z1") )) );
-        { //::Geometry::BasicVector3D< double >::angle
-        
-            typedef Geometry::BasicVector3D< double > exported_class_t;
-            typedef double ( exported_class_t::*angle_function_type )( ::Geometry::BasicVector3D< double > const & ) const;
-            
-            kvector_t_exposer.def( 
-                "angle"
-                , angle_function_type( &::Geometry::BasicVector3D< double >::angle )
-                , ( bp::arg("v") ) );
-        
-        }
-        { //::Geometry::BasicVector3D< double >::cosTheta
-        
-            typedef Geometry::BasicVector3D< double > exported_class_t;
-            typedef double ( exported_class_t::*cosTheta_function_type )(  ) const;
-            
-            kvector_t_exposer.def( 
-                "cosTheta"
-                , cosTheta_function_type( &::Geometry::BasicVector3D< double >::cosTheta ) );
-        
-        }
         { //::Geometry::BasicVector3D< double >::cross
         
             typedef Geometry::BasicVector3D< double > exported_class_t;
@@ -210,116 +189,6 @@ void register_kvector_t_class(){
                 , ( bp::arg("i") )
                 , bp::return_value_policy< bp::copy_non_const_reference >() );
         
-        }
-        { //::Geometry::BasicVector3D< double >::orthogonal
-        
-            typedef Geometry::BasicVector3D< double > exported_class_t;
-            typedef ::Geometry::BasicVector3D< double > ( exported_class_t::*orthogonal_function_type )(  ) const;
-            
-            kvector_t_exposer.def( 
-                "orthogonal"
-                , orthogonal_function_type( &::Geometry::BasicVector3D< double >::orthogonal ) );
-        
-        }
-        { //::Geometry::BasicVector3D< double >::perp
-        
-            typedef Geometry::BasicVector3D< double > exported_class_t;
-            typedef double ( exported_class_t::*perp_function_type )( ::Geometry::BasicVector3D< double > const & ) const;
-            
-            kvector_t_exposer.def( 
-                "perp"
-                , perp_function_type( &::Geometry::BasicVector3D< double >::perp )
-                , ( bp::arg("v") ) );
-        
-        }
-        { //::Geometry::BasicVector3D< double >::perp2
-        
-            typedef Geometry::BasicVector3D< double > exported_class_t;
-            typedef double ( exported_class_t::*perp2_function_type )( ::Geometry::BasicVector3D< double > const & ) const;
-            
-            kvector_t_exposer.def( 
-                "perp2"
-                , perp2_function_type( &::Geometry::BasicVector3D< double >::perp2 )
-                , ( bp::arg("v") ) );
-        
-        }
-        { //::Geometry::BasicVector3D< double >::phi
-        
-            typedef Geometry::BasicVector3D< double > exported_class_t;
-            typedef double ( exported_class_t::*phi_function_type )(  ) const;
-            
-            kvector_t_exposer.def( 
-                "phi"
-                , phi_function_type( &::Geometry::BasicVector3D< double >::phi ) );
-        
-        }
-        { //::Geometry::BasicVector3D< double >::r
-        
-            typedef Geometry::BasicVector3D< double > exported_class_t;
-            typedef double ( exported_class_t::*r_function_type )(  ) const;
-            
-            kvector_t_exposer.def( 
-                "r"
-                , r_function_type( &::Geometry::BasicVector3D< double >::mag ) );
-        
-        }
-        { //::Geometry::BasicVector3D< double >::rho
-        
-            typedef Geometry::BasicVector3D< double > exported_class_t;
-            typedef double ( exported_class_t::*rho_function_type )(  ) const;
-            
-            kvector_t_exposer.def( 
-                "rho"
-                , rho_function_type( &::Geometry::BasicVector3D< double >::magxy ) );
-        
-        }
-        { //::Geometry::BasicVector3D< double >::rotate
-        
-            typedef Geometry::BasicVector3D< double > exported_class_t;
-            typedef ::Geometry::BasicVector3D< double > & ( exported_class_t::*rotate_function_type )( double,::Geometry::BasicVector3D< double > const & ) ;
-            
-            kvector_t_exposer.def( 
-                "rotate"
-                , rotate_function_type( &::Geometry::BasicVector3D< double >::rotate )
-                , ( bp::arg("a"), bp::arg("v") )
-                , bp::return_value_policy< bp::reference_existing_object >() );
-        
-        }
-        { //::Geometry::BasicVector3D< double >::rotateX
-        
-            typedef Geometry::BasicVector3D< double > exported_class_t;
-            typedef ::Geometry::BasicVector3D< double > & ( exported_class_t::*rotateX_function_type )( double ) ;
-            
-            kvector_t_exposer.def( 
-                "rotateX"
-                , rotateX_function_type( &::Geometry::BasicVector3D< double >::rotateX )
-                , ( bp::arg("a") )
-                , bp::return_value_policy< bp::reference_existing_object >() );
-        
-        }
-        { //::Geometry::BasicVector3D< double >::rotateY
-        
-            typedef Geometry::BasicVector3D< double > exported_class_t;
-            typedef ::Geometry::BasicVector3D< double > & ( exported_class_t::*rotateY_function_type )( double ) ;
-            
-            kvector_t_exposer.def( 
-                "rotateY"
-                , rotateY_function_type( &::Geometry::BasicVector3D< double >::rotateY )
-                , ( bp::arg("a") )
-                , bp::return_value_policy< bp::reference_existing_object >() );
-        
-        }
-        { //::Geometry::BasicVector3D< double >::rotateZ
-        
-            typedef Geometry::BasicVector3D< double > exported_class_t;
-            typedef ::Geometry::BasicVector3D< double > & ( exported_class_t::*rotateZ_function_type )( double ) ;
-            
-            kvector_t_exposer.def( 
-                "rotateZ"
-                , rotateZ_function_type( &::Geometry::BasicVector3D< double >::rotateZ )
-                , ( bp::arg("a") )
-                , bp::return_value_policy< bp::reference_existing_object >() );
-        
         }
         { //::Geometry::BasicVector3D< double >::setLambdaAlphaPhi
         
@@ -331,50 +200,6 @@ void register_kvector_t_class(){
                 , setLambdaAlphaPhi_function_type( &::Geometry::BasicVector3D< double >::setLambdaAlphaPhi )
                 , ( bp::arg("_lambda"), bp::arg("_alpha"), bp::arg("_phi") ) );
         
-        }
-        { //::Geometry::BasicVector3D< double >::setMag
-        
-            typedef Geometry::BasicVector3D< double > exported_class_t;
-            typedef void ( exported_class_t::*setMag_function_type )( double ) ;
-            
-            kvector_t_exposer.def( 
-                "setMag"
-                , setMag_function_type( &::Geometry::BasicVector3D< double >::setMag )
-                , ( bp::arg("ma") ) );
-        
-        }
-        { //::Geometry::BasicVector3D< double >::setPhi
-        
-            typedef Geometry::BasicVector3D< double > exported_class_t;
-            typedef void ( exported_class_t::*setPhi_function_type )( double ) ;
-            
-            kvector_t_exposer.def( 
-                "setPhi"
-                , setPhi_function_type( &::Geometry::BasicVector3D< double >::setPhi )
-                , ( bp::arg("ph") ) );
-        
-        }
-        { //::Geometry::BasicVector3D< double >::setR
-        
-            typedef Geometry::BasicVector3D< double > exported_class_t;
-            typedef void ( exported_class_t::*setR_function_type )( double ) ;
-            
-            kvector_t_exposer.def( 
-                "setR"
-                , setR_function_type( &::Geometry::BasicVector3D< double >::setR )
-                , ( bp::arg("ma") ) );
-        
-        }
-        { //::Geometry::BasicVector3D< double >::setTheta
-        
-            typedef Geometry::BasicVector3D< double > exported_class_t;
-            typedef void ( exported_class_t::*setTheta_function_type )( double ) ;
-            
-            kvector_t_exposer.def( 
-                "setTheta"
-                , setTheta_function_type( &::Geometry::BasicVector3D< double >::setTheta )
-                , ( bp::arg("th") ) );
-        
         }
         { //::Geometry::BasicVector3D< double >::setX
         
@@ -419,16 +244,6 @@ void register_kvector_t_class(){
                 , setZ_function_type( &::Geometry::BasicVector3D< double >::setZ )
                 , ( bp::arg("a") ) );
         
-        }
-        { //::Geometry::BasicVector3D< double >::theta
-        
-            typedef Geometry::BasicVector3D< double > exported_class_t;
-            typedef double ( exported_class_t::*theta_function_type )(  ) const;
-            
-            kvector_t_exposer.def( 
-                "theta"
-                , theta_function_type( &::Geometry::BasicVector3D< double >::theta ) );
-        
         }
         { //::Geometry::BasicVector3D< double >::transform
         
@@ -441,16 +256,6 @@ void register_kvector_t_class(){
                 , ( bp::arg("m") )
                 , bp::return_value_policy< bp::reference_existing_object >() );
         
-        }
-        { //::Geometry::BasicVector3D< double >::unit
-        
-            typedef Geometry::BasicVector3D< double > exported_class_t;
-            typedef ::Geometry::BasicVector3D< double > ( exported_class_t::*unit_function_type )(  ) const;
-            
-            kvector_t_exposer.def( 
-                "unit"
-                , unit_function_type( &::Geometry::BasicVector3D< double >::unit ) );
-        
         }
         { //::Geometry::BasicVector3D< double >::x
         
@@ -483,8 +288,8 @@ void register_kvector_t_class(){
         
         }
         kvector_t_exposer.def( bp::self != bp::self );
-        kvector_t_exposer.def( bp::other< double >() * bp::self );
         kvector_t_exposer.def( bp::self * bp::self );
+        kvector_t_exposer.def( bp::other< double >() * bp::self );
         kvector_t_exposer.def( bp::self * bp::other< double >() );
         kvector_t_exposer.def( bp::self + bp::self );
         kvector_t_exposer.def( +bp::self );
diff --git a/Core/Samples/inc/Crystal.h b/Core/Samples/inc/Crystal.h
index 3e42545902acd4a2bb195a44ada55b6c04a3eea4..481d9c14242e25a4c18ddeaeb7fcdaeb525b1b5f 100644
--- a/Core/Samples/inc/Crystal.h
+++ b/Core/Samples/inc/Crystal.h
@@ -21,26 +21,22 @@
 #include "Lattice.h"
 #include "LatticeBasis.h"
 
-//! A crystal structure with a form factor as a basis
+//! A crystal structure with a form factor as a basis.
 
 class Crystal : public IClusteredParticles
 {
-public:
-     //! @brief constructor
-     //! @param lattice_basis  the basis which is repeated in the lattice structure
-     //! @param lattice  the crystal lattice, described by its basis vectors
+  public:
     Crystal(const LatticeBasis &lattice_basis, const Lattice &lattice);
     ~Crystal();
 
     virtual Crystal *clone() const;
 
     virtual void setAmbientRefractiveIndex(complex_t refractive_index)
-    {
-        mp_lattice_basis->setAmbientRefractiveIndex(refractive_index);
-    }
+    { mp_lattice_basis->setAmbientRefractiveIndex(refractive_index); }
 
-    virtual IFormFactor *createTotalFormFactor(const IFormFactor &meso_crystal_form_factor
-            , complex_t ambient_refractive_index) const;
+    virtual IFormFactor *createTotalFormFactor(
+        const IFormFactor &meso_crystal_form_factor,
+        complex_t ambient_refractive_index) const;
 
     Lattice getLattice() const { return m_lattice; }
     Particle *createBasis() const { return mp_lattice_basis->clone(); }
@@ -52,7 +48,7 @@ public:
     virtual std::vector<DiffuseParticleInfo *> *createDiffuseParticleInfo(
             const ParticleInfo &parent_info) const;
 
-private:
+  private:
     Lattice m_lattice;
     LatticeBasis *mp_lattice_basis;
     double m_dw_factor;
diff --git a/Core/Samples/inc/DiffuseParticleInfo.h b/Core/Samples/inc/DiffuseParticleInfo.h
index 2471e47fc17274e4d480fabe85622597ad0b7b83..83d4a18f4ee5c119de20d25892d66791702b24a8 100644
--- a/Core/Samples/inc/DiffuseParticleInfo.h
+++ b/Core/Samples/inc/DiffuseParticleInfo.h
@@ -22,8 +22,10 @@
 
 class DiffuseParticleInfo: public ParticleInfo
 {
-public:
-    DiffuseParticleInfo(Particle *p_particle, Geometry::Transform3D *transform=0, double depth=0, double abundance=0);
+  public:
+    DiffuseParticleInfo(
+        Particle *p_particle, Geometry::Transform3D *transform=0,
+        double depth=0, double abundance=0);
     virtual ~DiffuseParticleInfo();
 
     //! scale abundance
@@ -38,14 +40,17 @@ public:
     //! get number of particles per containing mesocrystal
     double getNumberPerMeso() const { return m_number_per_meso; }
 
-    DiffuseParticleInfo *clone() const { throw NotImplementedException("DiffuseParticleInfo::clone() -> Error: not implemented"); }
+    DiffuseParticleInfo *clone() const
+    { throw NotImplementedException(
+            "DiffuseParticleInfo::clone() -> Error: not implemented");
+    }
 
     //! set the range of height
     void setHeightRange(double height_range) { m_height_range = height_range; }
 
     //! get the range of height
     double getHeightRange() const { return m_height_range; }
-protected:
+  protected:
     double m_number_per_meso;
     double m_height_range;
 };
diff --git a/Core/Samples/inc/HomogeneousMaterial.h b/Core/Samples/inc/HomogeneousMaterial.h
index 17b9de932a915427e90e1c9658eabbed3bdc8449..cd7190605b61fd0fc40549f0bce247205db01c83 100644
--- a/Core/Samples/inc/HomogeneousMaterial.h
+++ b/Core/Samples/inc/HomogeneousMaterial.h
@@ -3,7 +3,7 @@
 //  BornAgain: simulate and fit scattering at grazing incidence
 //
 //! @file      Samples/inc/HomogeneousMaterial.h
-//! @brief     Defines class HomogeneousMaterial.
+//! @brief     Defines and fully implements class HomogeneousMaterial.
 //!
 //! @homepage  http://apps.jcns.fz-juelich.de/BornAgain
 //! @license   GNU General Public License v3 or higher (see COPYING)
@@ -19,32 +19,54 @@
 #include "IMaterial.h"
 #include "Types.h"
 
-//! A homogeneous material with refraction index
+//! A homogeneous material with refraction index.
 
 class HomogeneousMaterial : public IMaterial
 {
 public:
     HomogeneousMaterial();
-    HomogeneousMaterial(const complex_t &refractive_index);
-    HomogeneousMaterial(const std::string &name, const complex_t &refractive_index);
-    HomogeneousMaterial(const std::string &name, double refractive_index_real, double refractive_index_imag );
-    HomogeneousMaterial(const HomogeneousMaterial &other);
-    HomogeneousMaterial &operator=(const HomogeneousMaterial &other);
+    HomogeneousMaterial(const complex_t &refractive_index)
+        : IMaterial("noname"), m_refractive_index(refractive_index) {}
+    HomogeneousMaterial(const std::string &name,
+                        const complex_t &refractive_index)
+        : IMaterial(name), m_refractive_index(refractive_index) {}
+    HomogeneousMaterial(const std::string &name,
+                        double refractive_index_real,
+                        double refractive_index_imag )
+        : IMaterial(name),
+        m_refractive_index(complex_t(refractive_index_real,
+                                     refractive_index_imag)) {}
+    // Copy constructor.
+    HomogeneousMaterial(const HomogeneousMaterial &other)
+        : IMaterial(other), m_refractive_index(other.m_refractive_index) {}
     virtual ~HomogeneousMaterial() {}
 
-    /// return refractive index of the material
+    HomogeneousMaterial &operator=(const HomogeneousMaterial &other)
+        {
+            if(this != &other)
+            {
+                IMaterial::operator=(other);
+                m_refractive_index = other.m_refractive_index;
+            }
+            return *this;
+        }
+    
+    //! Return refractive index.
     complex_t getRefractiveIndex() const { return m_refractive_index; }
 
-    /// set refractive index of he material
-    void setRefractiveIndex(complex_t refractive_index) { m_refractive_index = refractive_index; }
+    //! Set refractive index.
+    void setRefractiveIndex(complex_t refractive_index)
+        { m_refractive_index = refractive_index; }
 
 protected:
-    //! print material class
-    virtual void print(std::ostream &ostr) const {
-        ostr  << "  " << getName() << " " << this << " R" << m_refractive_index;
-    }
+    //! Dump contents to stream.
+    virtual void print(std::ostream &ostr) const
+        {
+            ostr  << "  " << getName() << " " << this <<
+                " R" << m_refractive_index;
+        }
 
-    complex_t m_refractive_index; ///< complex index of refraction
+    complex_t m_refractive_index; //!< complex index of refraction
 };
 
 #endif // HOMOGENEOUSMATERIAL_H
diff --git a/Core/Samples/inc/ISelectionRule.h b/Core/Samples/inc/ISelectionRule.h
index 56027b97b48c5da3914c22675a5b18d7e124515c..bbfa6e9fff0ca26fc11b8b9697af8e444f75d314 100644
--- a/Core/Samples/inc/ISelectionRule.h
+++ b/Core/Samples/inc/ISelectionRule.h
@@ -25,7 +25,7 @@ public:
 
     virtual ISelectionRule *clone() const=0;
 
-    virtual bool coordinateSelected(const Coordinate3D<int> &coordinate) const=0;
+    virtual bool coordinateSelected(const IndexVector3D &coordinate) const=0;
 };
 
 class SimpleSelectionRule : public ISelectionRule
@@ -36,7 +36,7 @@ public:
 
     virtual SimpleSelectionRule *clone() const;
 
-    virtual bool coordinateSelected(const Coordinate3D<int> &coordinate) const;
+    virtual bool coordinateSelected(const IndexVector3D &coordinate) const;
 private:
     int m_a, m_b, m_c;
     int m_mod;
@@ -55,7 +55,7 @@ inline SimpleSelectionRule* SimpleSelectionRule::clone() const
 }
 
 inline bool SimpleSelectionRule::coordinateSelected(
-        const Coordinate3D<int> &coordinate) const
+        const IndexVector3D &coordinate) const
 {
     return (m_a*coordinate[0]+m_b*coordinate[1]+m_c*coordinate[2])%m_mod == 0;
 }
diff --git a/Core/Samples/inc/Lattice.h b/Core/Samples/inc/Lattice.h
index a471df6f37e08abe2f40b3c684e93737cd27984a..d80f03bf5c457f8d7b930132a323cf1e631383e1 100644
--- a/Core/Samples/inc/Lattice.h
+++ b/Core/Samples/inc/Lattice.h
@@ -52,10 +52,10 @@ public:
     void getReciprocalLatticeBasis(kvector_t &b1, kvector_t &b2, kvector_t &b3) const;
 
     //! get the nearest lattice point from a given vector
-    Coordinate3D<int> getNearestLatticeVectorCoordinates(const kvector_t &vector_in) const;
+    IndexVector3D getNearestLatticeVectorCoordinates(const kvector_t &vector_in) const;
 
     //! get the nearest reciprocal lattice point from a given vector
-    Coordinate3D<int> getNearestReciprocalLatticeVectorCoordinates(const kvector_t &vector_in) const;
+    IndexVector3D getNearestReciprocalLatticeVectorCoordinates(const kvector_t &vector_in) const;
 
     //! get a list of lattice vectors within a specified distance of a given vector
 //    std::vector<kvector_t> getLatticeVectorsWithinRadius(
@@ -92,12 +92,12 @@ public:
 private:
     Lattice &operator=(const Lattice &lattice);
 //    std::vector<kvector_t> getVectorsWithinRadius(const kvector_t &input_vector,
-//            const Coordinate3D<int> &nearest_coords, double radius,
+//            const IndexVector3D &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 computeVectorsWithinRadius(const kvector_t &input_vector,
-            const Coordinate3D<int> &nearest_coords, double radius,
+            const IndexVector3D &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;
 
diff --git a/Core/Samples/inc/Layer.h b/Core/Samples/inc/Layer.h
index d37ddc91cf5d64e8466507eb504df5fa38d23358..178f7aa247fe589b9b12aed1a69ae852fa91a998 100644
--- a/Core/Samples/inc/Layer.h
+++ b/Core/Samples/inc/Layer.h
@@ -18,7 +18,6 @@
 
 #include "ICompositeSample.h"
 #include "IMaterial.h"
-#include "Types.h"
 #include "HomogeneousMaterial.h"
 #include "LayerDWBASimulation.h"
 
@@ -40,9 +39,13 @@ public:
     //! return layer thickness in _angstrom_
     virtual double getThickness() const { return m_thickness; }
 
-    //! @brief set material to the layer
-    //! @param p_material   pointer to the material
-    virtual void setMaterial(const IMaterial* p_material) { p_material ? mp_material = p_material : throw NullPointerException("The material doesn't exist"); }
+    //! set material of the layer
+    virtual void setMaterial(const IMaterial* p_material)
+    { 
+        p_material ?
+            mp_material = p_material :
+            throw NullPointerException("The material doesn't exist");
+    }
 
     //! @brief set material of given thickness to the layer
     //! @param p_material   pointer to the material of layer
@@ -53,7 +56,11 @@ public:
     virtual const IMaterial* getMaterial() const { return mp_material; }
 
     //! return refractive index of the layer's material
-    virtual complex_t getRefractiveIndex() const { return (dynamic_cast<const HomogeneousMaterial *>(mp_material))->getRefractiveIndex(); }
+    virtual complex_t getRefractiveIndex() const
+    {
+        return (dynamic_cast<const HomogeneousMaterial *>(mp_material))->
+            getRefractiveIndex();
+    }
 
     //! return false (override is important for polymorphism of LayerDecorator)
     virtual bool hasDWBASimulation() const { return false; }
@@ -64,7 +71,7 @@ public:
 protected:
     Layer(const Layer &other);
 
-    //! initialize pool parameters, i.e. register some of class members for later access via parameter pool
+    //! register some class members for later access via parameter pool
     virtual void init_parameters();
 
 private:
diff --git a/Core/Samples/inc/MaterialManager.h b/Core/Samples/inc/MaterialManager.h
index 83b6cc6623b086ea90d96a9b3590b0b2498321b6..21bf01911856334eae2de89fac1a3cf8140e9850 100644
--- a/Core/Samples/inc/MaterialManager.h
+++ b/Core/Samples/inc/MaterialManager.h
@@ -20,46 +20,59 @@
 #include <string>
 #include <map>
 #include "Exceptions.h"
-#include "IMaterial.h"
 #include "ISingleton.h"
 #include "HomogeneousMaterial.h"
 
 //! Manager of materials used in simulation.
-//!
-//! It is a singleton which provides common and unique interface for
-//! material creation and access. No thread safety.
 
+//! A singleton that maintains a database of materials, and
+//! provides a common and unique interface for material creation and access.
+//!
 class MaterialManager: public ISingleton<MaterialManager>
 {
-public:
+  public:
     virtual ~MaterialManager() { clear(); }
 
-    //! definition of materials container
-    typedef std::map<std::string, IMaterial *> materials_t;
+    //! Return material from database.
+    static const IMaterial *getMaterial(const std::string &name)
+    { return instance().this_getMaterial(name); }
 
-    //! return material from database
-    const IMaterial *getMaterial(const std::string &name);
+    //! Add material to database.
+    static const IMaterial *getHomogeneousMaterial(
+        const std::string &name, const complex_t &refractive_index)
+    { return instance().this_getHomogeneousMaterial(name, refractive_index); }
 
-    //! add material to the database
-    const IMaterial *addHomogeneousMaterial(const std::string &name, const complex_t &refractive_index);
+    //! Add material to database.
+    static const IMaterial *getHomogeneousMaterial(
+        const std::string &name,
+        double refractive_index_real,
+        double refractive_index_imag)
+    { return instance().this_getHomogeneousMaterial(
+            name, refractive_index_real, refractive_index_imag); }
 
-    //! add material to the database
-    const IMaterial *addHomogeneousMaterial(const std::string &name, double refractive_index_real, double refractive_index_imag);
-
-    //! clean collection of material
-    void clear();
+    //! Wrap print.
+    friend std::ostream &operator<<(
+        std::ostream &ostr, const MaterialManager &m)
+    { m.print(ostr); return ostr; }
 
-    //! print material class
-    friend std::ostream &operator<<(std::ostream &ostr, const MaterialManager &m) { m.print(ostr); return ostr; }
-
-protected:
+  protected:
     MaterialManager(){}
     friend class ISingleton<MaterialManager >;
 
-    //! print material class
+    //! Clear database.
+    void clear();
+
+    //! Dump this to stream.
     virtual void print(std::ostream &ostr) const;
 
-    materials_t m_materials; //! container with defined materials
+    std::map<std::string, IMaterial*> m_materials; //!< our database
+  private:
+    const IMaterial *this_getMaterial(const std::string &name);
+    const IMaterial *this_getHomogeneousMaterial(
+        const std::string &name, const complex_t &refractive_index);
+    const IMaterial *this_getHomogeneousMaterial(
+        const std::string &name,
+        double refractive_index_real, double refractive_index_imag);
 };
 
-#endif // MATERIALMANAGER_H
+#endif /* MATERIALMANAGER_H */
diff --git a/Core/Samples/inc/ParticleInfo.h b/Core/Samples/inc/ParticleInfo.h
index c785c144b825f32407f5d9bf313a95cbd4181818..1d84f797764dcf415ff1c74006559e88b5be519a 100644
--- a/Core/Samples/inc/ParticleInfo.h
+++ b/Core/Samples/inc/ParticleInfo.h
@@ -24,45 +24,43 @@
 
 class ParticleInfo : public ICompositeSample
 {
-public:
-    //! constructor for particle info having transformation property and abundance
-    ParticleInfo(Particle *p_particle, Geometry::Transform3D *transform=0, double depth=0, double abundance=0);
-    ParticleInfo(const Particle &p_particle, const Geometry::Transform3D &transform, double depth=0, double abundance=0);
-
+  public:
+    ParticleInfo(Particle *p_particle,
+                 Geometry::Transform3D *transform=0,
+                 double depth=0, double abundance=0);
+    ParticleInfo(const Particle& p_particle,
+                 const Geometry::Transform3D& transform,
+                 double depth=0, double abundance=0);
     virtual ~ParticleInfo();
 
-    //! clone particle info
     virtual ParticleInfo *clone() const;
 
-    //! return particle
+    //! Return particle.
     const Particle *getParticle() const { return mp_particle; }
 
-    //! return particle transformation
+    //! Return transformation.
     const Geometry::Transform3D *getTransform3D() const { return mp_transform; }
 
-    //! set particle transformation
+    //! Set transformation.
     void setTransform(const Geometry::Transform3D &transform) {
         delete mp_transform;
         mp_transform = new Geometry::Transform3D(transform);
     }
 
-    //! return particle depth
+    //! Return depth.
     double getDepth() const { return m_depth;}
 
-    //! set particle depth
+    //! Set depth.
     void setDepth(double depth) { m_depth = depth; }
 
-    //! return particle abundance
+    //! Return abundance.
     double getAbundance() const { return m_abundance; }
 
-    //! set particle abundance
+    //! Set abundance.
     void setAbundance(double abundance) { m_abundance = abundance; }
 
 protected:
-//    ParticleInfo &operator=(const ParticleInfo &right);
-//    ParticleInfo(const ParticleInfo &source);
-
-    //! initialize pool parameters, i.e. register some of class members for later access via parameter pool
+    //! register some class members for later access via parameter pool
     virtual void init_parameters();
 
     Particle *mp_particle;
@@ -71,4 +69,4 @@ protected:
     double m_abundance;
 };
 
-#endif // PARTICLEINFO_H
+#endif /* PARTICLEINFO_H */
diff --git a/Core/Samples/inc/Samples.h b/Core/Samples/inc/Samples.h
index 9f5a459c259b89dbd7454641e63c501d54308769..72246a9fc34012996c0281e33c09654dfb76be70 100644
--- a/Core/Samples/inc/Samples.h
+++ b/Core/Samples/inc/Samples.h
@@ -18,7 +18,6 @@
 
 #include "Crystal.h"
 #include "MaterialManager.h"
-#include "Lattice.h"
 #include "Layer.h"
 #include "LayerDecorator.h"
 #include "LayerInterface.h"
diff --git a/Core/Samples/src/HomogeneousMaterial.cpp b/Core/Samples/src/HomogeneousMaterial.cpp
deleted file mode 100644
index a99ecdd947d8e94a517143e229f0c8affe60f038..0000000000000000000000000000000000000000
--- a/Core/Samples/src/HomogeneousMaterial.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-// ************************************************************************** //
-//
-//  BornAgain: simulate and fit scattering at grazing incidence
-//
-//! @file      Samples/src/HomogeneousMaterial.cpp
-//! @brief     Implements class HomogeneousMaterial.
-//!
-//! @homepage  http://apps.jcns.fz-juelich.de/BornAgain
-//! @license   GNU General Public License v3 or higher (see COPYING)
-//! @copyright Forschungszentrum Jülich GmbH 2013
-//! @authors   Scientific Computing Group at MLZ Garching
-//! @authors   C. Durniak, G. Pospelov, W. Van Herck, J. Wuttke 
-//
-// ************************************************************************** //
-
-#include "HomogeneousMaterial.h"
-
-HomogeneousMaterial::HomogeneousMaterial()
-{
-}
-
-HomogeneousMaterial::HomogeneousMaterial(const complex_t &refractive_index)
-    : IMaterial("noname"), m_refractive_index(refractive_index)
-{
-}
-
-HomogeneousMaterial::HomogeneousMaterial(const std::string &name, const complex_t &refractive_index)
-    : IMaterial(name), m_refractive_index(refractive_index)
-{
-}
-
-HomogeneousMaterial::HomogeneousMaterial(const std::string &name, double refractive_index_real, double refractive_index_imag)
-    : IMaterial(name), m_refractive_index(refractive_index_real, refractive_index_imag)
-{
-}
-
-HomogeneousMaterial::HomogeneousMaterial(const HomogeneousMaterial &other) : IMaterial(other)
-{
-    m_refractive_index = other.m_refractive_index;
-}
-
-HomogeneousMaterial &HomogeneousMaterial::operator=(const HomogeneousMaterial &other)
-{
-    if(this != &other)
-    {
-        IMaterial::operator=(other);
-        m_refractive_index = other.m_refractive_index;
-    }
-    return *this;
-}
diff --git a/Core/Samples/src/InterferenceFunction2DParaCrystal.cpp b/Core/Samples/src/InterferenceFunction2DParaCrystal.cpp
index 571e5d06f381eb4f200ae11603fe9b513aecf167..828582d5ccddbb741763852c6ca17b4a1888d044 100644
--- a/Core/Samples/src/InterferenceFunction2DParaCrystal.cpp
+++ b/Core/Samples/src/InterferenceFunction2DParaCrystal.cpp
@@ -147,17 +147,15 @@ double InterferenceFunction2DParaCrystal::interference1D(double qx, double qy, d
     complex_t fp = FTPDF(qx, qy, xi, index);
     if (n<1) {
         result = ((1.0 + fp)/(1.0 - fp)).real();
-    }
-    else {
+    } else {
         if (std::abs(1.0-fp) < Numeric::double_epsilon) {
             result = nd;
-        }
-        else {
+        } else {
             complex_t tmp;
-            if (std::log(std::abs(fp)+Numeric::double_min)*nd < std::log(Numeric::double_min)) {
+            double double_min = std::numeric_limits<double>::min();
+            if (std::log(std::abs(fp)+double_min)*nd < std::log(double_min)) {
                 tmp = complex_t(0.0, 0.0);
-            }
-            else {
+            } else {
                 tmp = std::pow(fp,n-1);
             }
             double intermediate = ((1.0-1.0/nd)*fp/(1.0-fp) - fp*fp*(1.0-tmp)/nd/(1.0-fp)/(1.0-fp)).real();
@@ -169,7 +167,8 @@ double InterferenceFunction2DParaCrystal::interference1D(double qx, double qy, d
 
 complex_t InterferenceFunction2DParaCrystal::FTPDF(double qx, double qy, double xi, size_t index) const
 {
-    double qa = qx*m_lattice_lengths[index]*std::cos(xi) + qy*m_lattice_lengths[index]*std::sin(xi);
+    double qa = qx*m_lattice_lengths[index]*std::cos(xi) +
+        qy*m_lattice_lengths[index]*std::sin(xi);
     complex_t phase = std::exp(complex_t(0.0, 1.0)*qa);
     // transform q to principal axes:
     double qp1, qp2;
diff --git a/Core/Samples/src/Lattice.cpp b/Core/Samples/src/Lattice.cpp
index 2f43c92a8cdd3b51431d2586cad54be8784e38f9..2ebdd83f79f349d715e2c6f3e8be92d520db2a5f 100644
--- a/Core/Samples/src/Lattice.cpp
+++ b/Core/Samples/src/Lattice.cpp
@@ -82,22 +82,22 @@ void Lattice::getReciprocalLatticeBasis(kvector_t& b1, kvector_t& b2,
     return;
 }
 
-Coordinate3D<int> Lattice::getNearestLatticeVectorCoordinates(const kvector_t &vector_in) const
+IndexVector3D Lattice::getNearestLatticeVectorCoordinates(const kvector_t &vector_in) const
 {
     kvector_t coordinate_vector = vector_in.x()*m_amin1 + vector_in.y()*m_amin2 + vector_in.z()*m_amin3;
     int c1 = (int)std::floor(coordinate_vector.x() + 0.5);
     int c2 = (int)std::floor(coordinate_vector.y() + 0.5);
     int c3 = (int)std::floor(coordinate_vector.z() + 0.5);
-    return Coordinate3D<int>(c1, c2, c3);
+    return IndexVector3D(c1, c2, c3);
 }
 
-Coordinate3D<int> Lattice::getNearestReciprocalLatticeVectorCoordinates(const kvector_t &vector_in) const
+IndexVector3D Lattice::getNearestReciprocalLatticeVectorCoordinates(const kvector_t &vector_in) const
 {
     kvector_t coordinate_vector = vector_in.x()*m_bmin1 + vector_in.y()*m_bmin2 + vector_in.z()*m_bmin3;
     int c1 = (int)std::floor(coordinate_vector.x() + 0.5);
     int c2 = (int)std::floor(coordinate_vector.y() + 0.5);
     int c3 = (int)std::floor(coordinate_vector.z() + 0.5);
-    return Coordinate3D<int>(c1, c2, c3);
+    return IndexVector3D(c1, c2, c3);
 }
 
 void Lattice::computeReciprocalLatticeVectorsWithinRadius(
@@ -106,7 +106,7 @@ void Lattice::computeReciprocalLatticeVectorsWithinRadius(
     if (!m_cache_ok) {
         initialize();
     }
-    Coordinate3D<int> nearest_coords = getNearestReciprocalLatticeVectorCoordinates(input_vector);
+    IndexVector3D nearest_coords = getNearestReciprocalLatticeVectorCoordinates(input_vector);
     computeVectorsWithinRadius(input_vector, nearest_coords, radius, m_b1, m_b2, m_b3, m_a1, m_a2, m_a3);
 }
 
@@ -164,7 +164,7 @@ void Lattice::computeReciprocalVectors() const
 }
 
 void Lattice::computeVectorsWithinRadius(const kvector_t &input_vector,
-        const Coordinate3D<int> &nearest_coords, double radius, const kvector_t& v1,
+        const IndexVector3D &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
 {
@@ -179,7 +179,7 @@ void Lattice::computeVectorsWithinRadius(const kvector_t &input_vector,
         {
             for (int index_Z = -max_Z; index_Z <= max_Z; ++index_Z)
             {
-                Coordinate3D<int> coords(index_X + nearest_coords[0],
+                IndexVector3D 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;
diff --git a/Core/Samples/src/MaterialManager.cpp b/Core/Samples/src/MaterialManager.cpp
index d31bd50f76f8ee59757e9ad9ffbf9233635f5816..83f6ae63521a510b1a6fb950065b4726aec51b77 100644
--- a/Core/Samples/src/MaterialManager.cpp
+++ b/Core/Samples/src/MaterialManager.cpp
@@ -15,20 +15,32 @@
 
 #include "MaterialManager.h"
 #include "Exceptions.h"
+#include "MessageSvc.h"
+#include <boost/thread.hpp>
 
-//! clean material database
+//! Materials database type.
+
+typedef std::map<std::string, IMaterial*> materials_t;
+
+//! Clear database.
 
 void MaterialManager::clear() {
-    for(materials_t::iterator it = m_materials.begin(); it!= m_materials.end(); ++it) {
-        if( (*it).second ) delete (*it).second;
+    static boost::mutex single_mutex;
+    boost::unique_lock<boost::mutex> single_lock( single_mutex );
+    for(materials_t::iterator
+            it = m_materials.begin(); it!= m_materials.end(); ++it) {
+        if( (*it).second )
+            delete (*it).second;
     }
     m_materials.clear();
 }
 
-//! get material
+//! Get material.
 
-const IMaterial *MaterialManager::getMaterial(const std::string &name)
+const IMaterial *MaterialManager::this_getMaterial(const std::string &name)
 {
+    static boost::mutex single_mutex;
+    boost::unique_lock<boost::mutex> single_lock( single_mutex );
     materials_t::const_iterator pos = m_materials.find(name);
     if( pos != m_materials.end()) {
         return pos->second;
@@ -37,21 +49,25 @@ const IMaterial *MaterialManager::getMaterial(const std::string &name)
     }
 }
 
-/* ************************************************************************* */
-// Create material and add into database. The name of material serve as unique
-// identifier. If such material already exists, return it. If such material
-// already exist, but its propery are different from users order, throw exception
-/* ************************************************************************* */
-const IMaterial *MaterialManager::addHomogeneousMaterial(const std::string &name, const complex_t &refractive_index)
+//! Create material, and add into database using name of material as identifier.
+
+const IMaterial *MaterialManager::this_getHomogeneousMaterial(
+    const std::string &name, const complex_t &refractive_index)
 {
+    static boost::mutex single_mutex;
+    boost::unique_lock<boost::mutex> single_lock( single_mutex );
     const IMaterial *mat = getMaterial(name);
     if( mat ) {
-        // check if user is trying to create material with same name but different parameters
-        const HomogeneousMaterial *old = dynamic_cast<const HomogeneousMaterial *>(mat);
+        // check if user is trying to create material
+        // with same name but different parameters
+        const HomogeneousMaterial *old =
+            dynamic_cast<const HomogeneousMaterial *>(mat);
         if(old->getRefractiveIndex() != refractive_index) {
-            HomogeneousMaterial *non_const_mat = const_cast<HomogeneousMaterial *>(old);
+            HomogeneousMaterial *non_const_mat =
+                const_cast<HomogeneousMaterial *>(old);
             non_const_mat->setRefractiveIndex(refractive_index);
-//            throw LogicErrorException("MaterialManager::addHomogeneousMaterial() -> Error! Attempt to create material with same name but different refractive index");
+            log(MSG::WARNING) << "MaterialManager::addHomogeneousMaterial()" <<
+                "-> Redefining refractive index for material '" << name << "'";
         }
         return mat;
     } else {
@@ -61,16 +77,25 @@ const IMaterial *MaterialManager::addHomogeneousMaterial(const std::string &name
     }
 }
 
+//! Create material, and add into database using name of material as identifier.
 
-const IMaterial *MaterialManager::addHomogeneousMaterial(const std::string &name, double refractive_index_real, double refractive_index_imag)
+const IMaterial *MaterialManager::this_getHomogeneousMaterial(
+    const std::string &name,
+    double refractive_index_real,
+    double refractive_index_imag)
 {
-    return addHomogeneousMaterial(name, complex_t(refractive_index_real, refractive_index_imag));
+    return getHomogeneousMaterial(
+        name, complex_t(refractive_index_real, refractive_index_imag));
 }
 
+//! Dump this to stream.
+
 void MaterialManager::print(std::ostream &ostr) const
 {
-    ostr << typeid(*this).name() << " " << this << " nmaterials:" << m_materials.size() << std::endl;
-    for(materials_t::const_iterator it = m_materials.begin(); it!= m_materials.end(); ++it) {
+    ostr << typeid(*this).name() << " " << this <<
+        " nmaterials:" << m_materials.size() << std::endl;
+    for(materials_t::const_iterator
+            it = m_materials.begin(); it!= m_materials.end(); ++it) {
         const IMaterial *mat = (*it).second;
         ostr << *mat << std::endl;
     }
diff --git a/Core/Tools/inc/Coordinate3D.h b/Core/Tools/inc/Coordinate3D.h
index 1cc3f2d62faa7f44e63545654b3a40a568a73928..6deec9972b6fcb8d5ee9514506dd54692113d906 100644
--- a/Core/Tools/inc/Coordinate3D.h
+++ b/Core/Tools/inc/Coordinate3D.h
@@ -3,7 +3,7 @@
 //  BornAgain: simulate and fit scattering at grazing incidence
 //
 //! @file      Tools/inc/Coordinate3D.h
-//! @brief     Defines template class Coordinate3D.
+//! @brief     TODO: This file should be eliminated.
 //!
 //! @homepage  http://apps.jcns.fz-juelich.de/BornAgain
 //! @license   GNU General Public License v3 or higher (see COPYING)
@@ -16,122 +16,8 @@
 #ifndef COORDINATE3D_H_
 #define COORDINATE3D_H_
 
-#include <cmath>
+#include "BasicVector3D.h"
 
-template <class T> class Coordinate3D
-{
-public:
-    Coordinate3D(T x, T y, T z)
-    {
-        m_coords[0] = x;
-        m_coords[1] = y;
-        m_coords[2] = z;
-    }
-    Coordinate3D(const Coordinate3D& source)
-    {
-        m_coords[0] = source[0];
-        m_coords[1] = source[1];
-        m_coords[2] = source[2];
-    }
-    template <class U> Coordinate3D(const Coordinate3D<U>& source)
-    {
-        m_coords[0] = (T)source[0];
-        m_coords[1] = (T)source[1];
-        m_coords[2] = (T)source[2];
-    }
-    virtual ~Coordinate3D() {}
-
-    inline T& operator[](const int index)
-    {
-        return m_coords[index%3];
-    }
-    inline const T& operator[](const int index) const
-    {
-        return m_coords[index%3];
-    }
-    inline Coordinate3D<T> &operator+=(const Coordinate3D<T> &right);
-    inline Coordinate3D<T> &operator-=(const Coordinate3D<T> &right);
-    inline Coordinate3D<T> &operator=(const Coordinate3D<T> &right);
-    inline T norm()
-    {
-        return std::sqrt(m_coords[0]*m_coords[0]+m_coords[1]*m_coords[1]+m_coords[2]*m_coords[2]);
-    }
-protected:
-private:
-    T m_coords[3];
-};
-
-template <class T> inline Coordinate3D<T>& Coordinate3D<T>::operator+=(const Coordinate3D<T> &right)
-{
-    m_coords[0] += right[0];
-    m_coords[1] += right[1];
-    m_coords[2] += right[2];
-    return *this;
-}
-
-template <class T> inline Coordinate3D<T>& Coordinate3D<T>::operator-=(const Coordinate3D<T> &right)
-{
-    m_coords[0] -= right[0];
-    m_coords[1] -= right[1];
-    m_coords[2] -= right[2];
-    return *this;
-}
-
-template <class T> inline Coordinate3D<T> &Coordinate3D<T>::operator=(const Coordinate3D<T> &right)
-{
-    m_coords[0] = right[0];
-    m_coords[1] = right[1];
-    m_coords[2] = right[2];
-    return *this;
-}
-
-template <class T> inline Coordinate3D<T> operator+(const Coordinate3D<T>& left, const Coordinate3D<T>& right)
-{
-    Coordinate3D<T> result = left;
-    result += right;
-    return result;
-}
-
-template <class T> inline Coordinate3D<T> operator-(const Coordinate3D<T>& vectorLeft, const Coordinate3D<T>& vectorRight)
-{
-    Coordinate3D<T> result = vectorLeft;
-    result -= vectorRight;
-    return result;
-}
-
-template <class T> Coordinate3D<T> CrossProduct(const Coordinate3D<T> &left, const Coordinate3D<T> &right)
-{
-    T x = left[1]*right[2] - left[2]*right[1];
-    T y = left[2]*right[0] - left[0]*right[2];
-    T z = left[0]*right[1] - left[1]*right[0];
-    return Coordinate3D<T>(x, y, z);
-}
-
-template <class T> T operator*(const Coordinate3D<T> &left, const Coordinate3D<T> &right)
-{
-    T x = left[0]*right[0];
-    T y = left[1]*right[1];
-    T z = left[2]*right[2];
-    return x+y+z;
-}
-
-template <class T> Coordinate3D<T> operator*(const Coordinate3D<T> &left, const T &factor)
-{
-    T x = left[0]*factor;
-    T y = left[1]*factor;
-    T z = left[2]*factor;
-    return Coordinate3D<T>(x, y, z);
-}
-
-template <class T> Coordinate3D<T> operator*(const T &factor, const Coordinate3D<T> &right)
-{
-    return right*factor;
-}
-
-template <class T> T GetDistanceBetweenPoints(const Coordinate3D<T> &left, const Coordinate3D<T> &right)
-{
-    Coordinate3D<T> connectingVector = left - right;
-    return connectingVector.norm();
-}
+typedef Geometry::BasicVector3D<int> IndexVector3D;
 
 #endif /* COORDINATE3D_H_ */
diff --git a/Core/Tools/inc/FastVector.h b/Core/Tools/inc/FastVector.h
index 2643a76273f4b37d725bf067d2eae1769a8dfaf2..6cacce702340b7d7dec743f7378f9551f1e7e076 100644
--- a/Core/Tools/inc/FastVector.h
+++ b/Core/Tools/inc/FastVector.h
@@ -19,16 +19,18 @@
 #include "Types.h"
 #include <iostream>
 
-//! container for holding kvectors with optimised location/deallocation
+//! A Vector of kvector_t's with optimised location/deallocation.
 
 class KVectorContainer {
-public:
+  public:
     typedef std::vector<kvector_t > container_t;
     typedef container_t::const_iterator const_iterator;
-    KVectorContainer(int buff_size = 3) : m_current_position(0), m_max_buff_size(buff_size), m_buffer()
+    KVectorContainer(int buff_size = 3)
+        : m_current_position(0), m_max_buff_size(buff_size), m_buffer()
     {
         m_buffer.reserve(m_max_buff_size);
-        for(size_t i=0; i<m_max_buff_size; ++i) m_buffer.push_back(kvector_t(0.0, 0.0, 0.0));
+        for(size_t i=0; i<m_max_buff_size; ++i)
+            m_buffer.push_back(kvector_t(0.0, 0.0, 0.0));
     }
 
     inline void push_back(const kvector_t &k) {
@@ -49,14 +51,15 @@ public:
     inline size_t size() { return m_current_position; }
 
     void print() {
-        for(size_t i=0; i<m_max_buff_size; ++i) std::cout << i << " " << m_buffer[i] << std::endl;
+        for(size_t i=0; i<m_max_buff_size; ++i)
+            std::cout << i << " " << m_buffer[i] << std::endl;
         std::cout << "size:" << size() << std::endl;
     }
 
     const_iterator begin() const { return m_buffer.begin(); }
     const_iterator end() const { return m_buffer.begin()+m_current_position; }
 
-private:
+  private:
     size_t m_current_position;
     size_t m_max_buff_size;
     container_t m_buffer;
diff --git a/Core/Tools/inc/IFactory.h b/Core/Tools/inc/IFactory.h
index f01182cff3cb3653041394bd043cca49f0405fae..09345e19443ca3a9b8293c9f9d22258810abdb0a 100644
--- a/Core/Tools/inc/IFactory.h
+++ b/Core/Tools/inc/IFactory.h
@@ -27,14 +27,16 @@ template<class IdentifierType, class AbstractProduct >
 class IFactory
 {
 public:
-    //! pointer to function which will be used to create object of AbstractProduct base type
+    //! function which will be used to create object of AbstractProduct base type
     typedef AbstractProduct* (*CreateItemCallback) ();
 
-    //! typedef for map which stores correspondance between object identifier and object creation function
+    //! map for correspondance between object identifier and object creation function
     typedef std::map<IdentifierType, CreateItemCallback> CallbackMap_t;
 
-    //! typedef for map which stores correspondance between object identifier and object description
+    //! map for correspondance between object identifier and object description
     typedef std::map<IdentifierType, IdentifierType> DescriptionMap_t;
+    typedef typename DescriptionMap_t::iterator iterator;
+    typedef typename DescriptionMap_t::const_iterator const_iterator;
 
     IFactory() : m_own_objects(false) { }
 
diff --git a/Core/Tools/inc/ISingleton.h b/Core/Tools/inc/ISingleton.h
index 7ec81a8f725700be952079ca93989b8c5728f1b7..ff1b556a8f01a850d077403b8fb4690e691a74a6 100644
--- a/Core/Tools/inc/ISingleton.h
+++ b/Core/Tools/inc/ISingleton.h
@@ -19,6 +19,7 @@
 #include <stdexcept>
 #include <iostream>
 #include <typeinfo>
+#include <boost/thread.hpp>
 
 template <class T>
 class ISingleton
@@ -27,17 +28,15 @@ public:
 
     static T &instance()
     {
-        // check if exists, if not, then initialise
+        static boost::mutex single_mutex;
+        boost::unique_lock<boost::mutex> single_lock( single_mutex );
         if( !m_instance) {
-            // check for dead reference (i.e. object has been initialised but then somebody managed to delete it)
             if( m_destroyed ) {
                 onDeadReference();
             } else {
-                // first call initalise
-                create_singleton();
+                CreateSingleton();
             }
         }
-        //std::cout << "ISingleton::instance() -> Info. Accesing instance... " << m_instance << std::endl;
         return *m_instance;
     }
 
@@ -45,26 +44,20 @@ protected:
     ISingleton(){}
     virtual ~ISingleton()
     {
-        //std::cout << "ISingleton::~ISingleton() -> Deleting singleton" << std::endl;
         m_instance = 0;
         m_destroyed = true;
     }
 
-    static void create_singleton()
+    static void CreateSingleton()
     {
         static T theInstance;
         m_instance = &theInstance;
-        //std::cout << "ISingleton::create_singleton() -> Info. Creating singleton " << m_instance << " of type '" << (typeid(theInstance).name()) << "'." << std::endl;
     }
 
-    static void onDeadReference()
-    {
-        throw std::runtime_error("ISingleton::onDeadReference()");
-    }
+    static void onDeadReference() { throw std::runtime_error("ISingleton::onDeadReference()"); }
 
     typedef T* T_Pointer;
 
-
 private:
     ISingleton(const ISingleton<T> &) {}
     ISingleton &operator=(const ISingleton<T> &) { throw std::runtime_error("ISingleton::operator=()"); }
diff --git a/Core/Tools/inc/MemberFunctionIntegrator.h b/Core/Tools/inc/MemberFunctionIntegrator.h
index 094e5e42357ee7f6d9cb78d126cb711c8662d129..b7f9b1022f5409fb56c274ced2421d99cea2dff4 100644
--- a/Core/Tools/inc/MemberFunctionIntegrator.h
+++ b/Core/Tools/inc/MemberFunctionIntegrator.h
@@ -19,6 +19,8 @@
 #include "gsl/gsl_integration.h"
 #include <cassert>
 
+//! Wrap integrator from GNU Scientific Library.
+
 template <class C> class MemberFunctionIntegrator
 {
 public:
@@ -32,17 +34,20 @@ public:
         void *m_data;
     };
 
-    //! constructor taking a member function and the object whose member function to integrate
     MemberFunctionIntegrator();
-    MemberFunctionIntegrator(mem_function p_member_function, const C *const p_object);
+    //! to integrate p_member_function, which must belong to p_object
+    MemberFunctionIntegrator(
+        mem_function p_member_function, const C *const p_object);
     ~MemberFunctionIntegrator();
 
     //! perform the actual integration over the range [lmin, lmax]
     double integrate(double lmin, double lmax, void *params);
 
     //! set integrand
-    void setIntegrand(mem_function member_function) { m_member_function = member_function; }
-    void setIntegrand(mem_function member_function, const C *const p_object) { m_member_function = member_function; mp_object = p_object; }
+    void setIntegrand(mem_function member_function)
+    { m_member_function = member_function; }
+    void setIntegrand(mem_function member_function, const C *const p_object)
+    { m_member_function = member_function; mp_object = p_object; }
 
 private:
     //! static function that can be passed to gsl integrator
@@ -90,13 +95,9 @@ template<class C> double MemberFunctionIntegrator<C>::integrate(
     f.function = StaticCallBack;
     f.params = &cb;
 
-//    gsl_integration_workspace *ws = gsl_integration_workspace_alloc(200);
-//    double result, error;
-//    gsl_integration_qag(&f, lmin, lmax, 1e-10, 1e-8, 50, 1, ws, &result, &error);
-//    gsl_integration_workspace_free(ws);
-
     double result, error;
-    gsl_integration_qag(&f, lmin, lmax, 1e-10, 1e-8, 50, 1, m_gsl_workspace, &result, &error);
+    gsl_integration_qag(&f, lmin, lmax, 1e-10, 1e-8, 50, 1,
+                        m_gsl_workspace, &result, &error);
 
     return result;
 }
diff --git a/Core/Tools/inc/Numeric.h b/Core/Tools/inc/Numeric.h
index b07249fffa76f86435b4e16ea07661e15bd9bd7d..e1da93834e8097a38d42985e18084d1b2553a6be 100644
--- a/Core/Tools/inc/Numeric.h
+++ b/Core/Tools/inc/Numeric.h
@@ -26,7 +26,6 @@ namespace Numeric {
 static const double required_precision = 1.e-4;
 
 static const double double_epsilon = std::numeric_limits<double>::epsilon();
-static const double double_min = std::numeric_limits<double>::min();
 
 //! threshold on probability value during calculation of weighted form factor
 static const double probthreshold = 0.0000000001; 
diff --git a/Core/Tools/inc/TRange.h b/Core/Tools/inc/TRange.h
index 3fa58bbe649f0b1c05c2f4d82fd4b0e93487985e..7e86be8ba471584df758e1d0b4cccff6f028047d 100644
--- a/Core/Tools/inc/TRange.h
+++ b/Core/Tools/inc/TRange.h
@@ -3,7 +3,7 @@
 //  BornAgain: simulate and fit scattering at grazing incidence
 //
 //! @file      Tools/inc/TRange.h
-//! @brief     Defines and implements template class TRange.
+//! @brief     Defines and implements template classes TRange and TSampledRange.
 //!
 //! @homepage  http://apps.jcns.fz-juelich.de/BornAgain
 //! @license   GNU General Public License v3 or higher (see COPYING)
@@ -16,9 +16,11 @@
 #ifndef TRANGE_H_
 #define TRANGE_H_
 
+//! An interval [min..max[.
+
 template <class T> class TRange
 {
-public:
+  public:
     TRange(T min, T max) : m_min(min), m_max(max) {}
     virtual ~TRange(){}
 
@@ -27,17 +29,20 @@ public:
     T getDifference() const { return m_max-m_min; }
 
     bool inRange(T value) const { return value >= m_min && value < m_max; }
-private:
+  private:
     T m_min, m_max;
 };
 
+//! An interval [min..max[, and a number of samples.
+
 template <class T> class TSampledRange : public TRange<T>
 {
-public:
-    TSampledRange(size_t n_samples, T min, T max) : TRange<T>(min, max), m_n_samples(n_samples) {}
+  public:
+    TSampledRange(size_t n_samples, T min, T max)
+        : TRange<T>(min, max), m_n_samples(n_samples) {}
 
     size_t getNSamples() const { return m_n_samples; }
-private:
+  private:
     size_t m_n_samples;
 };
 
diff --git a/Core/Tools/inc/Types.h b/Core/Tools/inc/Types.h
index 899d7143d739ac3b22d20504814925494ece2818..7df8e92e21185ef6c9b66cc7db78901e97c9a53f 100644
--- a/Core/Tools/inc/Types.h
+++ b/Core/Tools/inc/Types.h
@@ -22,10 +22,12 @@
 using std::size_t;
 
 typedef std::complex<double > complex_t;
+
 typedef Geometry::BasicVector3D<double> kvector_t;
 typedef Geometry::BasicVector3D<complex_t> cvector_t;
-typedef std::vector<double > vdouble1d_t;
-typedef std::vector<vdouble1d_t > vdouble2d_t;
-typedef std::pair<complex_t, complex_t > complexpair_t;
+
+typedef std::vector<double> vdouble1d_t;
+typedef std::vector<vdouble1d_t> vdouble2d_t;
+typedef std::pair<complex_t, complex_t> complexpair_t;
 
 #endif // TYPES_H
diff --git a/Core/Tools/inc/Utils.h b/Core/Tools/inc/Utils.h
index 2c082b2d166d93d62084de7cf7c4468119eb484c..710ec5ef90fa6926bdedfb661d8c7a0fa6f810a5 100644
--- a/Core/Tools/inc/Utils.h
+++ b/Core/Tools/inc/Utils.h
@@ -17,12 +17,7 @@
 #define UTILS_H
 
 #include "Types.h"
-//#include <string>
-//#include <vector>
-//#include <map>
-//#include <iostream>
-//#include <sstream>
-//#include "Exceptions.h"
+#include "Exceptions.h"
 #include <boost/unordered_map.hpp>
 
 namespace Utils {
diff --git a/Core/Tools/src/ISingleton.cpp b/Core/Tools/src/ISingleton.cpp
deleted file mode 100644
index ef95395ee94e3547cc9503b0a1c0cbdff573a240..0000000000000000000000000000000000000000
--- a/Core/Tools/src/ISingleton.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-// ************************************************************************** //
-//
-//  BornAgain: simulate and fit scattering at grazing incidence
-//
-//! @file      Tools/src/ISingleton.cpp
-//! @brief     Just include ISingleton.h
-//!
-//! @homepage  http://apps.jcns.fz-juelich.de/BornAgain
-//! @license   GNU General Public License v3 or higher (see COPYING)
-//! @copyright Forschungszentrum Jülich GmbH 2013
-//! @authors   Scientific Computing Group at MLZ Garching
-//! @authors   C. Durniak, G. Pospelov, W. Van Herck, J. Wuttke 
-//
-// ************************************************************************** //
-
-#include "ISingleton.h"
diff --git a/Core/Tools/src/ProgramOptions.cpp b/Core/Tools/src/ProgramOptions.cpp
index 494629116cb27dd024a0f891689907f62591a0f1..b7dea35c41d3e02f0f8d4cbb6d51f7bb71b9bf4a 100644
--- a/Core/Tools/src/ProgramOptions.cpp
+++ b/Core/Tools/src/ProgramOptions.cpp
@@ -15,7 +15,6 @@
 
 #include "ProgramOptions.h"
 #include "Utils.h"
-#include "Exceptions.h"
 #include "MessageSvc.h"
 
 #include <boost/program_options/config.hpp>
diff --git a/Core/python_module.pri b/Core/python_module.pri
index e0b336e257e510d260eaaef0556dfe26f03aa394..28add69f087cd2409a19ce076ea0bcba986e991b 100644
--- a/Core/python_module.pri
+++ b/Core/python_module.pri
@@ -33,6 +33,7 @@ HEADERS +=  \
     PythonAPI/inc/IFTDistribution2D.pypp.h \
     PythonAPI/inc/IInterferenceFunction.pypp.h \
     PythonAPI/inc/IMaterial.pypp.h \
+    PythonAPI/inc/IndexVector3D.pypp.h \
     PythonAPI/inc/Instrument.pypp.h \
     PythonAPI/inc/InterferenceFunction1DParaCrystal.pypp.h \
     PythonAPI/inc/InterferenceFunction2DLattice.pypp.h \
@@ -134,6 +135,7 @@ SOURCES +=  \
     PythonAPI/src/IFTDistribution2D.pypp.cpp \
     PythonAPI/src/IInterferenceFunction.pypp.cpp \
     PythonAPI/src/IMaterial.pypp.cpp \
+    PythonAPI/src/IndexVector3D.pypp.cpp \
     PythonAPI/src/Instrument.pypp.cpp \
     PythonAPI/src/InterferenceFunction1DParaCrystal.pypp.cpp \
     PythonAPI/src/InterferenceFunction2DLattice.pypp.cpp \
diff --git a/Examples/Performance/perf_history.txt b/Examples/Performance/perf_history.txt
index 838228a0d1bd70b4d87702754f6cedbe54a50629..0e45b1216f9e7431179f770dbb8a1e08fff8ec98 100644
--- a/Examples/Performance/perf_history.txt
+++ b/Examples/Performance/perf_history.txt
@@ -191,5 +191,10 @@
 # Release-0.6 clang -O2
 2013-03-20 15:51:38 | jcnsopc73  | macosx64, 2800 MHz      | 281690  | 24.6914 | 24.3902 | 5.88235 | 
 # after implementing logging system, it is slower, but it must be fluctuations
+# (and ./App --mesocrystal2 gives  25.57 (4 threads), 51.53 (1 thread))
 2013-03-20 16:50:02 | jcnsopc73  | macosx64, 2800 MHz      | 270270  | 22.9885 | 22.2222 | 5.71429 | 
+ 
+# after changes in BasicVector3D from Joachim 
+# (and ./App --mesocrystal2 gives  24.77 (4 threads), 54.66 (1 thread))
+2013-03-21 10:19:28 | jcnsopc73  | macosx64, 2800 MHz      | 285714  | 24.0964 | 22.9885 | 5.71429 | 
 
diff --git a/GUI/coregui/Views/Components/SampleEditor/SampleEditorScene.cpp b/GUI/coregui/Views/Components/SampleEditor/SampleEditorScene.cpp
index 6c17c16b1d86edd344cacf149836450906bbffb8..64c0e84765257a306d6a94e2da6dfc716a5365ac 100644
--- a/GUI/coregui/Views/Components/SampleEditor/SampleEditorScene.cpp
+++ b/GUI/coregui/Views/Components/SampleEditor/SampleEditorScene.cpp
@@ -50,8 +50,8 @@ SampleEditorScene::SampleEditorScene(QObject *parent)
 //    complex_t n_air(1.0, 0.0);
 //    complex_t n_substrate(1.0-6e-6, 2e-8);
 //    complex_t n_particle(1.0-6e-4, 2e-8);
-//    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
-//    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+//    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
+//    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate);
 //    Layer air_layer;
 //    air_layer.setMaterial(p_air_material);
 //    Layer substrate_layer;
diff --git a/GUI/coregui/Views/Components/SampleEditor/SampleFactory.h b/GUI/coregui/Views/Components/SampleEditor/SampleFactory.h
index 4700d3912df3bd1c0ad9d41a236105463038c05d..864aa36023153062cf930e96ea844797f64c8038 100644
--- a/GUI/coregui/Views/Components/SampleEditor/SampleFactory.h
+++ b/GUI/coregui/Views/Components/SampleEditor/SampleFactory.h
@@ -25,8 +25,8 @@ public:
         complex_t n_air(1.0, 0.0);
         complex_t n_substrate(1.0-6e-6, 2e-8);
         complex_t n_particle(1.0-6e-4, 2e-8);
-        const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
-        const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+        const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
+        const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate);
         Layer air_layer;
         air_layer.setMaterial(p_air_material);
         Layer substrate_layer;
diff --git a/GUI/coregui/mainwindow/mainwindow.cpp b/GUI/coregui/mainwindow/mainwindow.cpp
index 6919abe1e10de57c16661d12cc32c0609c4f177f..0e2f0189f52a085754f7d51f3c6af14f157c3cfd 100644
--- a/GUI/coregui/mainwindow/mainwindow.cpp
+++ b/GUI/coregui/mainwindow/mainwindow.cpp
@@ -114,8 +114,8 @@ ISample *MainWindow::createDefaultSample()
     complex_t n_air(1.0, 0.0);
     complex_t n_substrate(1.0-6e-6, 2e-8);
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", n_air);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", n_substrate);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", n_air);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", n_substrate);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
diff --git a/Macros/BoostPythonGenerator/InstallPyFit.py b/Macros/BoostPythonGenerator/InstallPyFit.py
index ff2b1ec1a4fbf97f3b83d738841bb4482d054072..1cbd6e7121f2e86c748bcb094564fab09a6ff42f 100644
--- a/Macros/BoostPythonGenerator/InstallPyFit.py
+++ b/Macros/BoostPythonGenerator/InstallPyFit.py
@@ -66,7 +66,6 @@ def GenerateModuleFile(OutputTempDir, files_inc, files_src, PatternsToExclude):
   for line in fin:
       skip_this = False
       for pattern in PatternsToExclude:
-        print "XXX",pattern,line
         if pattern in line:
           skip_this = True
           break
diff --git a/Macros/BoostPythonGenerator/MakePyCore.py b/Macros/BoostPythonGenerator/MakePyCore.py
index 59858c943d584dbe359fb372a6b1bef0208733f0..d78c61c143a4e0bbb92a72493fbc8bde0ae51199 100644
--- a/Macros/BoostPythonGenerator/MakePyCore.py
+++ b/Macros/BoostPythonGenerator/MakePyCore.py
@@ -111,7 +111,7 @@ def AdditionalRules(mb):
         "rotate","rotateX","rotateY","rotateZ"
     ]
     for cl in classes:
-      if "BasicVector3D<std::complex<double> >" in cl.decl_string:
+      if "BasicVector3D<std::complex<double> >" in cl.decl_string or "BasicVector3D<double>" in cl.decl_string or "BasicVector3D<int>" in cl.decl_string:
         for fun in cl.member_functions(allow_empty=True):
           MethodIsBad = False
           for x in MethodsWhichAreNotSuitable:
@@ -120,6 +120,17 @@ def AdditionalRules(mb):
           if MethodIsBad:
             fun.exclude()
 
+    MethodsWhichAreNotUsed=["dot","mag","mag2","cross","magxy","magxy2","transform"]
+    for cl in classes:
+      if "BasicVector3D<int>" in cl.decl_string:
+        for fun in cl.member_functions(allow_empty=True):
+          MethodIsBad = False
+          for x in MethodsWhichAreNotUsed:
+            if fun.name == x:
+              MethodIsBad = True
+          if MethodIsBad:
+            fun.exclude()
+
   #if "FTDistributions.h" in myFiles:
       #cl = mb.class_("IFTDistribution2D")
       #cl = mb.class_("FTDistribution2DCauchy")
diff --git a/Tests/FunctionalTests/TestCore/IsGISAXS01/IsGISAXS01.cpp b/Tests/FunctionalTests/TestCore/IsGISAXS01/IsGISAXS01.cpp
index 2276d0af0d089b593621e32d5bf18825b5bd7215..8450b76d5c371153892b7c7b85a02cf42a14bb89 100644
--- a/Tests/FunctionalTests/TestCore/IsGISAXS01/IsGISAXS01.cpp
+++ b/Tests/FunctionalTests/TestCore/IsGISAXS01/IsGISAXS01.cpp
@@ -30,8 +30,8 @@ void FunctionalTests::IsGISAXS01::run()
     // building sample
     // ---------------------
     MultiLayer multi_layer;
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", 1.0, 0.0);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", 1.0, 0.0);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
diff --git a/Tests/FunctionalTests/TestCore/IsGISAXS02/IsGISAXS02.cpp b/Tests/FunctionalTests/TestCore/IsGISAXS02/IsGISAXS02.cpp
index bf77ce76b3d7be10c3d923e020a6d4ba29a855e5..c2609a2e41354d382f6914be070d149358f55d81 100644
--- a/Tests/FunctionalTests/TestCore/IsGISAXS02/IsGISAXS02.cpp
+++ b/Tests/FunctionalTests/TestCore/IsGISAXS02/IsGISAXS02.cpp
@@ -29,7 +29,7 @@ void FunctionalTests::IsGISAXS02::run()
     // ---------------------
     MultiLayer multi_layer;
 
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", 1.0, 0.0);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", 1.0, 0.0);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
 
diff --git a/Tests/FunctionalTests/TestCore/IsGISAXS03/IsGISAXS03.cpp b/Tests/FunctionalTests/TestCore/IsGISAXS03/IsGISAXS03.cpp
index 0e4cf5a4b7eee309f638911727183247b43394e8..f1c479bc705cf0d0318a3eaaf83b7a6671530933 100644
--- a/Tests/FunctionalTests/TestCore/IsGISAXS03/IsGISAXS03.cpp
+++ b/Tests/FunctionalTests/TestCore/IsGISAXS03/IsGISAXS03.cpp
@@ -35,8 +35,8 @@ void FunctionalTests::IsGISAXS03::runDWBA()
 {
     // building sample
     MultiLayer multi_layer;
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", 1.0, 0.0);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", 1.0, 0.0);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
@@ -66,8 +66,8 @@ void FunctionalTests::IsGISAXS03::runBA()
 {
     // building sample
     MultiLayer multi_layer;
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", 1.0, 0.0);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", 1.0, 0.0);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
@@ -96,8 +96,8 @@ void FunctionalTests::IsGISAXS03::runBA_Size()
 {
     // building sample
     MultiLayer multi_layer;
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", 1.0, 0.0);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", 1.0, 0.0);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
diff --git a/Tests/FunctionalTests/TestCore/IsGISAXS04/IsGISAXS04.cpp b/Tests/FunctionalTests/TestCore/IsGISAXS04/IsGISAXS04.cpp
index e890045d0b236a27b991b20e35edd2b1c547855a..964bd16f77e2ebdb28191ccb4051f9d62cb93006 100644
--- a/Tests/FunctionalTests/TestCore/IsGISAXS04/IsGISAXS04.cpp
+++ b/Tests/FunctionalTests/TestCore/IsGISAXS04/IsGISAXS04.cpp
@@ -35,8 +35,8 @@ void FunctionalTests::IsGISAXS04::run1DDL()
     // building sample
     MultiLayer multi_layer;
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", 1.0, 0.0);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", 1.0, 0.0);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
@@ -69,8 +69,8 @@ void FunctionalTests::IsGISAXS04::run2DDL()
     // building sample
     MultiLayer multi_layer;
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", 1.0, 0.0);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", 1.0, 0.0);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
diff --git a/Tests/FunctionalTests/TestCore/IsGISAXS06/IsGISAXS06.cpp b/Tests/FunctionalTests/TestCore/IsGISAXS06/IsGISAXS06.cpp
index d3ef6ac5de051c432275cad14b0c18e7563589d7..5ebb9499e3e42a0c014f9303514fb8afa72fc248 100644
--- a/Tests/FunctionalTests/TestCore/IsGISAXS06/IsGISAXS06.cpp
+++ b/Tests/FunctionalTests/TestCore/IsGISAXS06/IsGISAXS06.cpp
@@ -37,8 +37,8 @@ void FunctionalTests::IsGISAXS06::runlattice()
     // building sample
     MultiLayer multi_layer;
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", 1.0, 0.0);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", 1.0, 0.0);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
@@ -95,8 +95,8 @@ void FunctionalTests::IsGISAXS06::runcentered()
     // building sample
     MultiLayer multi_layer;
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air",  1.0, 0.0);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air",  1.0, 0.0);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
@@ -156,8 +156,8 @@ void FunctionalTests::IsGISAXS06::runrotated()
 {
     MultiLayer multi_layer;
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", 1.0, 0.0);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", 1.0, 0.0);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
@@ -251,8 +251,8 @@ ISample* FunctionalTests::IsGISAXS06::LatticeVariantBuilder::buildSample() const
 {
     MultiLayer *p_multi_layer = new MultiLayer();
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", 1.0,0.0);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", 1.0,0.0);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
diff --git a/Tests/FunctionalTests/TestCore/IsGISAXS07/IsGISAXS07.cpp b/Tests/FunctionalTests/TestCore/IsGISAXS07/IsGISAXS07.cpp
index 7e76e4ce34b53c086f5b9578a9e2e9397805b5ae..e1f94991866660594a613f2d67552184c9d1a93b 100644
--- a/Tests/FunctionalTests/TestCore/IsGISAXS07/IsGISAXS07.cpp
+++ b/Tests/FunctionalTests/TestCore/IsGISAXS07/IsGISAXS07.cpp
@@ -23,7 +23,7 @@ void FunctionalTests::IsGISAXS07::run()
 {
     // building sample
     MultiLayer multi_layer;
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", 1.0, 0.0);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", 1.0, 0.0);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
 
diff --git a/Tests/FunctionalTests/TestCore/IsGISAXS08/IsGISAXS08.cpp b/Tests/FunctionalTests/TestCore/IsGISAXS08/IsGISAXS08.cpp
index a79f2bcf86a4dcf28583c66132c4d06f1ff8a585..2e401aef47b5db01b05aea3388b1725c731f4dd1 100644
--- a/Tests/FunctionalTests/TestCore/IsGISAXS08/IsGISAXS08.cpp
+++ b/Tests/FunctionalTests/TestCore/IsGISAXS08/IsGISAXS08.cpp
@@ -35,8 +35,8 @@ void FunctionalTests::IsGISAXS08::run2DDL()
     // building sample
     MultiLayer multi_layer;
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", 1.0, 0.0);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", 1.0, 0.0);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
@@ -72,8 +72,8 @@ void FunctionalTests::IsGISAXS08::run2DDL2()
     // building sample
     MultiLayer multi_layer;
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", 1.0, 0.0);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", 1.0, 0.0);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
diff --git a/Tests/FunctionalTests/TestCore/IsGISAXS09/IsGISAXS09.cpp b/Tests/FunctionalTests/TestCore/IsGISAXS09/IsGISAXS09.cpp
index ff1db4404f91e8115584496df0e838cb4d658e21..48fdcb7f46b3c745001cacf80aa59e5dbc0776dd 100644
--- a/Tests/FunctionalTests/TestCore/IsGISAXS09/IsGISAXS09.cpp
+++ b/Tests/FunctionalTests/TestCore/IsGISAXS09/IsGISAXS09.cpp
@@ -38,8 +38,8 @@ void FunctionalTests::IsGISAXS09::runpyramidZ0()
 {
     // building sample
     MultiLayer multi_layer;
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", 1.0, 0.0);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", 1.0, 0.0);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
@@ -70,8 +70,8 @@ void FunctionalTests::IsGISAXS09::runpyramidZ45()
 {
     // building sample
     MultiLayer multi_layer;
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", 1.0, 0.0);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", 1.0, 0.0);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
diff --git a/Tests/FunctionalTests/TestCore/IsGISAXS10/IsGISAXS10.cpp b/Tests/FunctionalTests/TestCore/IsGISAXS10/IsGISAXS10.cpp
index de406df8bf4efb645df5656a4b037f661e06c2e2..a3436eba9161edebe9d89e3e3b07c8ff2bf655a1 100644
--- a/Tests/FunctionalTests/TestCore/IsGISAXS10/IsGISAXS10.cpp
+++ b/Tests/FunctionalTests/TestCore/IsGISAXS10/IsGISAXS10.cpp
@@ -25,8 +25,8 @@ void FunctionalTests::IsGISAXS10::run()
 {
     // building sample
     MultiLayer multi_layer;
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air10", 1.0, 0.0);
-    const IMaterial *p_substrate_material = MaterialManager::instance().addHomogeneousMaterial("Substrate10", 1.0-5e-6, 2e-8);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air10", 1.0, 0.0);
+    const IMaterial *p_substrate_material = MaterialManager::getHomogeneousMaterial("Substrate10", 1.0-5e-6, 2e-8);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     Layer substrate_layer;
diff --git a/Tests/FunctionalTests/TestCore/IsGISAXS11/IsGISAXS11.cpp b/Tests/FunctionalTests/TestCore/IsGISAXS11/IsGISAXS11.cpp
index 4245b3289c743e3c1241ac269b46386d9659ea44..e57a83616cf0076e3ba8ccd310f134f87824ce0f 100644
--- a/Tests/FunctionalTests/TestCore/IsGISAXS11/IsGISAXS11.cpp
+++ b/Tests/FunctionalTests/TestCore/IsGISAXS11/IsGISAXS11.cpp
@@ -29,7 +29,7 @@ void FunctionalTests::IsGISAXS11::run()
     // building sample
     MultiLayer multi_layer;
 
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", 1.0, 0.0);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", 1.0, 0.0);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
 
diff --git a/Tests/FunctionalTests/TestCore/IsGISAXS15/IsGISAXS15.cpp b/Tests/FunctionalTests/TestCore/IsGISAXS15/IsGISAXS15.cpp
index ec31e210dcc7a991881843e4e0e0fca14c8a22fd..b1d0f119bbbd222c0448c93ded95a103c777796c 100644
--- a/Tests/FunctionalTests/TestCore/IsGISAXS15/IsGISAXS15.cpp
+++ b/Tests/FunctionalTests/TestCore/IsGISAXS15/IsGISAXS15.cpp
@@ -29,7 +29,7 @@ void FunctionalTests::IsGISAXS15::run()
     // building sample
     MultiLayer multi_layer;
     complex_t n_particle(1.0-6e-4, 2e-8);
-    const IMaterial *p_air_material = MaterialManager::instance().addHomogeneousMaterial("Air", 1.0, 0.0);
+    const IMaterial *p_air_material = MaterialManager::getHomogeneousMaterial("Air", 1.0, 0.0);
     Layer air_layer;
     air_layer.setMaterial(p_air_material);
     InterferenceFunction1DParaCrystal *p_interference_function = new InterferenceFunction1DParaCrystal(15.0*Units::nanometer,5*Units::nanometer, 1e3*Units::nanometer);
diff --git a/Tests/FunctionalTests/TestPyCore/isgisaxs01.py b/Tests/FunctionalTests/TestPyCore/isgisaxs01.py
index 7330ef1a18afea0227a7630ae8a2a82b6b78cc41..d7165c0cc61874b0cc72ad3a6653c80b788674c6 100644
--- a/Tests/FunctionalTests/TestPyCore/isgisaxs01.py
+++ b/Tests/FunctionalTests/TestPyCore/isgisaxs01.py
@@ -16,9 +16,8 @@ from libBornAgainCore import *
 # ----------------------------------
 def RunSimulation():
     # defining materials
-    matMng = MaterialManager.instance()
-    mAmbience = matMng.addHomogeneousMaterial("Air", 1.0, 0.0 )
-    mSubstrate = matMng.addHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8 )
+    mAmbience = MaterialManager.getHomogeneousMaterial("Air", 1.0, 0.0 )
+    mSubstrate = MaterialManager.getHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8 )
     # collection of particles
     n_particle = complex(1.0-6e-4, 2e-8)
     cylinder_ff = FormFactorCylinder(5*nanometer, 5*nanometer)
diff --git a/Tests/FunctionalTests/TestPyCore/isgisaxs02.py b/Tests/FunctionalTests/TestPyCore/isgisaxs02.py
index 3d2c7e180cc92d7399bf4c14226c142b0fddc1fc..2926f8a0f87fc05d99cc242add9f1db88e3fd513 100644
--- a/Tests/FunctionalTests/TestPyCore/isgisaxs02.py
+++ b/Tests/FunctionalTests/TestPyCore/isgisaxs02.py
@@ -16,8 +16,7 @@ from libBornAgainCore import *
 # ----------------------------------
 def RunSimulation():
     # defining materials
-    matMng = MaterialManager.instance()
-    mAmbience = matMng.addHomogeneousMaterial("Air", 1.0, 0.0 )
+    mAmbience = MaterialManager.getHomogeneousMaterial("Air", 1.0, 0.0 )
     # collection of particles
     n_particle = complex(1.0-6e-4, 2e-8)
     radius1 = 5.0*nanometer
diff --git a/Tests/FunctionalTests/TestPyCore/isgisaxs03.py b/Tests/FunctionalTests/TestPyCore/isgisaxs03.py
index 9da3180f5c46ac15870ad906a0f308ecbf8c4059..24b29a51651d41b1becf8eb2a191c114161e4572 100644
--- a/Tests/FunctionalTests/TestPyCore/isgisaxs03.py
+++ b/Tests/FunctionalTests/TestPyCore/isgisaxs03.py
@@ -16,9 +16,8 @@ from libBornAgainCore import *
 def RunSimulationDWBA():
     
     # defining materials
-    matMng = MaterialManager.instance()
-    mAmbience = matMng.addHomogeneousMaterial("Air", 1.0, 0.0 )
-    mSubstrate = matMng.addHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8 )    
+    mAmbience = MaterialManager.getHomogeneousMaterial("Air", 1.0, 0.0 )
+    mSubstrate = MaterialManager.getHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8 )    
     # collection of particles
     n_particle = complex(1.0-6e-4, 2e-8)    
     cylinder_ff = FormFactorCylinder(5*nanometer, 5*nanometer)
@@ -51,9 +50,8 @@ def RunSimulationDWBA():
 # ----------------------------------
 def RunSimulationBA():
      # defining materials
-    matMng = MaterialManager.instance()
-    mAmbience = matMng.addHomogeneousMaterial("Air", 1.0, 0.0 )
-    mSubstrate = matMng.addHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8 )
+    mAmbience = MaterialManager.getHomogeneousMaterial("Air", 1.0, 0.0 )
+    mSubstrate = MaterialManager.getHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8 )
     # collection of particles
     n_particle = complex(1.0-6e-4, 2e-8)
     cylinder_ff = FormFactorCylinder(5*nanometer, 5*nanometer)
@@ -83,9 +81,8 @@ def RunSimulationBA():
 # ----------------------------------
 def RunSimulationBA_Size():
     # defining materials
-    matMng = MaterialManager.instance()
-    mAmbience = matMng.addHomogeneousMaterial("Air", 1.0, 0.0 )
-    mSubstrate = matMng.addHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8 )
+    mAmbience = MaterialManager.getHomogeneousMaterial("Air", 1.0, 0.0 )
+    mSubstrate = MaterialManager.getHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8 )
 
     multi_layer = MultiLayer()
 
diff --git a/Tests/FunctionalTests/TestPyCore/isgisaxs04.py b/Tests/FunctionalTests/TestPyCore/isgisaxs04.py
index e27d05b787e6ad2c9feff5e5b75fdf96894de96f..4b7a38087505b4d88cbab70c94b16355cfb3a463 100644
--- a/Tests/FunctionalTests/TestPyCore/isgisaxs04.py
+++ b/Tests/FunctionalTests/TestPyCore/isgisaxs04.py
@@ -15,9 +15,8 @@ from libBornAgainCore import *
 # ----------------------------------
 def RunSimulation1():
     # defining materials
-    matMng = MaterialManager.instance()
-    mAmbience = matMng.addHomogeneousMaterial("Air", 1.0, 0.0 )
-    mSubstrate = matMng.addHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8 )
+    mAmbience = MaterialManager.getHomogeneousMaterial("Air", 1.0, 0.0 )
+    mSubstrate = MaterialManager.getHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8 )
     # collection of particles
     n_particle = complex(1.0-6e-4, 2e-8)   
     cylinder_ff = FormFactorCylinder(5*nanometer, 5*nanometer)
@@ -49,9 +48,8 @@ def RunSimulation1():
 # ----------------------------------
 def RunSimulation2():
 #    # defining materials
-    matMng = MaterialManager.instance()
-    mAmbience = matMng.addHomogeneousMaterial("Air", 1.0, 0.0 )
-    mSubstrate = matMng.addHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8 )
+    mAmbience = MaterialManager.getHomogeneousMaterial("Air", 1.0, 0.0 )
+    mSubstrate = MaterialManager.getHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8 )
     # collection of particles
     n_particle = complex(1.0-6e-4, 2e-8)
     
diff --git a/Tests/FunctionalTests/TestPyCore/isgisaxs06.py b/Tests/FunctionalTests/TestPyCore/isgisaxs06.py
index c732716393cbf0ed97d47ba3b972ffb5f2d555e0..e2e4f037449fbb8e51e0da628c48851edf33c47c 100644
--- a/Tests/FunctionalTests/TestPyCore/isgisaxs06.py
+++ b/Tests/FunctionalTests/TestPyCore/isgisaxs06.py
@@ -17,9 +17,8 @@ M_PI = numpy.pi
 # ----------------------------------
 def RunSimulation_lattice():
 # defining materials
-    matMng = MaterialManager.instance()
-    mAmbience = matMng.addHomogeneousMaterial("Air", 1.0, 0.0 )
-    mSubstrate = matMng.addHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8 )
+    mAmbience = MaterialManager.getHomogeneousMaterial("Air", 1.0, 0.0 )
+    mSubstrate = MaterialManager.getHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8 )
     # collection of particles
     lattice_params = Lattice2DIFParameters()
     lattice_params.m_length_1 = 10.0*nanometer
@@ -71,9 +70,8 @@ def RunSimulation_lattice():
 # ----------------------------------
 def RunSimulation_centered():
     # defining materials
-    matMng = MaterialManager.instance()
-    mAmbience = matMng.addHomogeneousMaterial("Air", 1.0, 0.0 )
-    mSubstrate = matMng.addHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8 )
+    mAmbience = MaterialManager.getHomogeneousMaterial("Air", 1.0, 0.0 )
+    mSubstrate = MaterialManager.getHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8 )
     # collection of particles
     lattice_params = Lattice2DIFParameters()
     lattice_params.m_length_1 = 10.0*nanometer
@@ -130,9 +128,8 @@ def RunSimulation_centered():
 # ----------------------------------
 def RunSimulation_rotated():
 # defining materials
-    matMng = MaterialManager.instance()
-    mAmbience = matMng.addHomogeneousMaterial("Air", 1.0, 0.0 )
-    mSubstrate = matMng.addHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8 )
+    mAmbience = MaterialManager.getHomogeneousMaterial("Air", 1.0, 0.0 )
+    mSubstrate = MaterialManager.getHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8 )
     # collection of particles
     lattice_params = Lattice2DIFParameters()
     lattice_params.m_length_1 = 10.0*nanometer
@@ -219,9 +216,8 @@ def RunSimulation_variants():
 # IsGISAXS6 functional test sample builder for varying xi angle
 def buildSample(xi_value):
     n_particle = complex(1.0-6e-4, 2e-8)
-    matMng = MaterialManager.instance()
-    mAmbience = matMng.addHomogeneousMaterial("Air", 1.0, 0.0 )
-    mSubstrate = matMng.addHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8 )
+    mAmbience = MaterialManager.getHomogeneousMaterial("Air", 1.0, 0.0 )
+    mSubstrate = MaterialManager.getHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8 )
     air_layer = Layer(mAmbience)
     substrate_layer = Layer(mSubstrate)
     
diff --git a/Tests/FunctionalTests/TestPyCore/isgisaxs07.py b/Tests/FunctionalTests/TestPyCore/isgisaxs07.py
index 10091a66f3f23739d08d4dc26ee200aaad35d7bb..92f27abb483f70f1c4bebce60f1cabe3c9a22d8b 100644
--- a/Tests/FunctionalTests/TestPyCore/isgisaxs07.py
+++ b/Tests/FunctionalTests/TestPyCore/isgisaxs07.py
@@ -16,8 +16,7 @@ from libBornAgainCore import *
 # ----------------------------------
 def RunSimulation():
     # defining materials
-    matMng = MaterialManager.instance()
-    mAmbience = matMng.addHomogeneousMaterial("Air", 1.0, 0.0 )
+    mAmbience = MaterialManager.getHomogeneousMaterial("Air", 1.0, 0.0 )
     # collection of particles
     n_particle = complex(1.0-6e-4, 2e-8)   
     particle_decoration = ParticleDecoration()
diff --git a/Tests/FunctionalTests/TestPyCore/isgisaxs08.py b/Tests/FunctionalTests/TestPyCore/isgisaxs08.py
index cb8274ee1d89e1ed86d678bb76137dd96a1c7321..9a0c71a9fbd1759e992867c83e7502bb50239afc 100644
--- a/Tests/FunctionalTests/TestPyCore/isgisaxs08.py
+++ b/Tests/FunctionalTests/TestPyCore/isgisaxs08.py
@@ -16,9 +16,8 @@ M_PI = numpy.pi
 # ----------------------------------
 def RunSimulation1():
     # defining materials
-    matMng = MaterialManager.instance()
-    mAmbience = matMng.addHomogeneousMaterial("Air", 1.0, 0.0 )
-    mSubstrate = matMng.addHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8 )
+    mAmbience = MaterialManager.getHomogeneousMaterial("Air", 1.0, 0.0 )
+    mSubstrate = MaterialManager.getHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8 )
     # collection of particles
     n_particle = complex(1.0-6e-4, 2e-8)   
     cylinder_ff = FormFactorCylinder(5*nanometer, 5*nanometer)
@@ -55,9 +54,8 @@ def RunSimulation1():
 # ----------------------------------
 def RunSimulation2():
     # defining materials
-    matMng = MaterialManager.instance()
-    mAmbience = matMng.addHomogeneousMaterial("Air", 1.0, 0.0 )
-    mSubstrate = matMng.addHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8 )
+    mAmbience = MaterialManager.getHomogeneousMaterial("Air", 1.0, 0.0 )
+    mSubstrate = MaterialManager.getHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8 )
     # collection of particles
     n_particle = complex(1.0-6e-4, 2e-8)
     cylinder_ff = FormFactorCylinder(5*nanometer, 5*nanometer)
diff --git a/Tests/FunctionalTests/TestPyCore/isgisaxs09.py b/Tests/FunctionalTests/TestPyCore/isgisaxs09.py
index 80b78fa5283c32223b10870904c0e666398d9396..010534e2010613fbe317a3eccf81fef2079e3219 100644
--- a/Tests/FunctionalTests/TestPyCore/isgisaxs09.py
+++ b/Tests/FunctionalTests/TestPyCore/isgisaxs09.py
@@ -15,9 +15,8 @@ from libBornAgainCore import *
 # ----------------------------------
 def RunSimulation1():
     # defining materials
-    matMng = MaterialManager.instance()
-    mAmbience = matMng.addHomogeneousMaterial("Air", 1.0, 0.0 )
-    mSubstrate = matMng.addHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8 )
+    mAmbience = MaterialManager.getHomogeneousMaterial("Air", 1.0, 0.0 )
+    mSubstrate = MaterialManager.getHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8 )
     # collection of particles
     n_particle = complex(1.0-6e-4, 2e-8)   
     pyramid_ff = FormFactorPyramid(5*nanometer, 5*nanometer, deg2rad(54.73 ) )
@@ -49,9 +48,8 @@ def RunSimulation1():
 # ----------------------------------
 def RunSimulation2():
    # defining materials
-    matMng = MaterialManager.instance()
-    mAmbience = matMng.addHomogeneousMaterial("Air", 1.0, 0.0 )
-    mSubstrate = matMng.addHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8 )
+    mAmbience = MaterialManager.getHomogeneousMaterial("Air", 1.0, 0.0 )
+    mSubstrate = MaterialManager.getHomogeneousMaterial("Substrate", 1.0-6e-6, 2e-8 )
     # collection of particles
     n_particle = complex(1.0-6e-4, 2e-8)   
     pyramid_ff = FormFactorPyramid(5*nanometer, 5*nanometer, deg2rad(54.73 ) )
diff --git a/Tests/FunctionalTests/TestPyCore/isgisaxs10.py b/Tests/FunctionalTests/TestPyCore/isgisaxs10.py
index 630e64ed08cdd6a9ea5f49e0096221542d2ccbb2..81fcd94dfe683c89289fbacda2ecf9dcc971dbce 100644
--- a/Tests/FunctionalTests/TestPyCore/isgisaxs10.py
+++ b/Tests/FunctionalTests/TestPyCore/isgisaxs10.py
@@ -16,9 +16,8 @@ from libBornAgainCore import *
 # ----------------------------------
 def RunSimulation():
     # defining materials
-    matMng = MaterialManager.instance()
-    mAmbience = matMng.addHomogeneousMaterial("Air", 1.0, 0.0 )
-    mSubstrate = matMng.addHomogeneousMaterial("Substrate", 1.0-5e-6, 2e-8 )
+    mAmbience = MaterialManager.getHomogeneousMaterial("Air", 1.0, 0.0 )
+    mSubstrate = MaterialManager.getHomogeneousMaterial("Substrate", 1.0-5e-6, 2e-8 )
     # collection of particles
     n_particle = complex(1.0-5e-5, 2e-8)
     cylinder_ff = FormFactorCylinder(5*nanometer, 5*nanometer)
diff --git a/Tests/FunctionalTests/TestPyCore/isgisaxs11.py b/Tests/FunctionalTests/TestPyCore/isgisaxs11.py
index 1d4e4782a5472c35baca10bdf551ff31e202f818..629c5031c49f0bdf863e6955dce0a26d9188af69 100644
--- a/Tests/FunctionalTests/TestPyCore/isgisaxs11.py
+++ b/Tests/FunctionalTests/TestPyCore/isgisaxs11.py
@@ -16,8 +16,7 @@ from libBornAgainCore import *
 # ----------------------------------
 def RunSimulation():
     # defining materials
-    matMng = MaterialManager.instance()
-    mAmbience = matMng.addHomogeneousMaterial("Air", 1.0, 0.0 )
+    mAmbience = MaterialManager.getHomogeneousMaterial("Air", 1.0, 0.0 )
 
     # collection of particles
     n_particle_shell = complex(1.0-1e-4, 2e-8)
diff --git a/Tests/FunctionalTests/TestPyCore/isgisaxs15.py b/Tests/FunctionalTests/TestPyCore/isgisaxs15.py
index dc77f4639ce8d3918ae03659728a8dcaa4d83839..74816e7906535fc47c08160065502f6604437022 100644
--- a/Tests/FunctionalTests/TestPyCore/isgisaxs15.py
+++ b/Tests/FunctionalTests/TestPyCore/isgisaxs15.py
@@ -15,8 +15,7 @@ from libBornAgainCore import *
 # ----------------------------------
 def RunSimulation():
     # defining materials
-    matMng = MaterialManager.instance()
-    mAmbience = matMng.addHomogeneousMaterial("Air", 1.0, 0.0 )
+    mAmbience = MaterialManager.getHomogeneousMaterial("Air", 1.0, 0.0 )
     
     # collection of particles
     n_particle = complex(1.0-6e-4, 2e-8)
diff --git a/pub/core/Tools/ISingleton.cpp b/pub/core/Tools/ISingleton.cpp
deleted file mode 120000
index 198a75313aada5912d19856d455ee1ea9f2c9dea..0000000000000000000000000000000000000000
--- a/pub/core/Tools/ISingleton.cpp
+++ /dev/null
@@ -1 +0,0 @@
-../../../Core/Tools//src/ISingleton.cpp
\ No newline at end of file