diff --git a/App/inc/TestToyExperiment.h b/App/inc/TestToyExperiment.h
index c57cdae56879ce892d9db493c592f513b788929e..e2ceb4172b5a4a30659f1664f2dadbcfde5cce83 100644
--- a/App/inc/TestToyExperiment.h
+++ b/App/inc/TestToyExperiment.h
@@ -40,10 +40,8 @@ public:
 protected:
     virtual void init_parameters();
 private:
-    ToyExperiment(const ToyExperiment &other) : Experiment(other)
+    ToyExperiment(const ToyExperiment &other) : Experiment(other), m_func(other.m_func), pars(other.pars)
     {
-        m_func = other.m_func;
-        pars = other.pars;
         setName("ToyExperiment");
         init_parameters();
     }
diff --git a/App/src/DrawHelper.cpp b/App/src/DrawHelper.cpp
index 8b8387ab48ddef7c568fbdec332175de406a530f..9d8eb4b3c5431289dbe6a7f9b29d1ae8a189f820 100644
--- a/App/src/DrawHelper.cpp
+++ b/App/src/DrawHelper.cpp
@@ -63,11 +63,11 @@ void DrawHelper::ExecuteMagnifier(int event, int px, int py, TObject *sel)
 {
   (void)sel;
   if ( event == kButton1Double ) {
-    TCanvas *c = (TCanvas *) gTQSender;
+    TCanvas *c = (TCanvas *)gTQSender;
     char cname[256];
     sprintf(cname,"%s_%d",c->GetTitle(),(int)time(0));
     TPad *pad = c->Pick(px, py, 0);
-    TPad *pad_new = (TPad *) pad->Clone();
+    TPad *pad_new = dynamic_cast<TPad *>(pad->Clone());
     pad_new->SetPad(0.0, 0.0, 1.0, 1.0);
     TCanvas *c1 = new TCanvas(cname, cname, 1024, 768);
     c1->cd();
@@ -274,11 +274,10 @@ void DrawHelper::DrawMultilayer(const MultiLayer *sample)
         double thickness = layer->getThickness();
 
         //calculating size of box representing layer
-        double x1(0), x2(0), y1(0), y2(0);
-        x1 = -size*0.5;
-        x2 = size*0.5;
-        y1 = z;
-        y2 = z+thickness;
+        double x1 = -size*0.5;
+        double x2 = size*0.5;
+        double y1 = z;
+        double y2 = z+thickness;
         // but top and bottom layers need special treatment, since they thickness==0
         if(i_layer==0) { // ambience normally doesn't have thickness
             y1=z;
@@ -358,7 +357,7 @@ void DrawHelper::saveReport()
     std::string stmpname = pdffilename + "[";
     cmaster->Print(stmpname.c_str()); // create new file
 
-    for(std::vector<TCanvas *>::iterator it=m_registered_canvases.begin(); it!=m_registered_canvases.end(); it++) {
+    for(std::vector<TCanvas *>::iterator it=m_registered_canvases.begin(); it!=m_registered_canvases.end(); ++it) {
         TCanvas *c1 = (*it);
 
         double xlow(0.05), ylow(0), xup(0.95), yup(0.95);
@@ -391,7 +390,7 @@ void DrawHelper::saveReport()
     //std::string rootfilename(Utils::FileSystem::GetHomePath()+std::string("./Examples/Reports/report_")+datime+std::string(".root"));
     std::string rootfilename(std::string("./report_")+datime+std::string(".root"));
     TFile *top = new TFile(rootfilename.c_str(), "RECREATE");
-    for(std::vector<TCanvas *>::iterator it=m_registered_canvases.begin(); it!=m_registered_canvases.end(); it++) {
+    for(std::vector<TCanvas *>::iterator it=m_registered_canvases.begin(); it!=m_registered_canvases.end(); ++it) {
         TCanvas *c1 = (*it);
         c1->Write();
     }
diff --git a/App/src/FunctionalTestFactory.cpp b/App/src/FunctionalTestFactory.cpp
index dedf8e321045b2ac2c76c44c272c6d825a2c3c37..7b887622b105e0c6ebdda2e449ef7aac1b63cd8e 100644
--- a/App/src/FunctionalTestFactory.cpp
+++ b/App/src/FunctionalTestFactory.cpp
@@ -166,7 +166,7 @@ void FunctionalTestFactory::profile(std::string name, ProgramOptions *p_options)
 void FunctionalTestFactory::execute_all(ProgramOptions *p_options)
 {
     CallbackMap_t::const_iterator it;
-    for(it=m_callbacks.begin(); it != m_callbacks.end(); it++ ) {
+    for(it=m_callbacks.begin(); it != m_callbacks.end(); ++it ) {
         execute( it->first , p_options);
         //createItem( it->first )->execute();
     }
@@ -185,7 +185,7 @@ void FunctionalTestFactory::print_testnames()
     help += "List of available tests are below:";
     std::cout << help << std::endl;
     CallbackMap_t::const_iterator it;
-    for(it=m_callbacks.begin(); it != m_callbacks.end(); it++ ) {
+    for(it=m_callbacks.begin(); it != m_callbacks.end(); ++it ) {
         std::cout << it->first << std::endl;
     }
 }
diff --git a/App/src/IsGISAXSTools.cpp b/App/src/IsGISAXSTools.cpp
index 50f2192ec813c4acaaaee4abddb618d203887780..3a979480e9bf842dbf6138d1045b8cd3a675444b 100644
--- a/App/src/IsGISAXSTools.cpp
+++ b/App/src/IsGISAXSTools.cpp
@@ -426,9 +426,9 @@ OutputData<double> *IsGISAXSTools::readOutputDataFromFile(const std::string &fil
         double1d_t buff_1d;
         std::istringstream iss(sline);
         std::copy(std::istream_iterator<double>(iss), std::istream_iterator<double>(), back_inserter(buff_1d));
-        if( !buff_1d.size() ) {
+        if( buff_1d.empty() ) {
             std::cout << "'" << sline << "'" << std::endl;
-            LogicErrorException("IsGISAXSTools::readOutputDataFromFile() -> Error. Null size of vector; file: "+filename);
+            throw LogicErrorException("IsGISAXSTools::readOutputDataFromFile() -> Error. Null size of vector; file: "+filename);
         }
         buff_2d.push_back(buff_1d);
     }
@@ -467,8 +467,8 @@ void IsGISAXSTools::exportOutputDataInVectors2D(const OutputData<double> &output
 
     const AxisDouble *p_axis0 = output_data.getAxis(0);
     const AxisDouble *p_axis1 = output_data.getAxis(1);
-    std::string axis0_name = p_axis0->getName();
-    std::string axis1_name = p_axis1->getName();
+    //std::string axis0_name = p_axis0->getName();
+    //std::string axis1_name = p_axis1->getName();
     size_t axis0_size = p_axis0->getSize();
     size_t axis1_size = p_axis1->getSize();
 
@@ -565,7 +565,7 @@ TH1D *IsGISAXSTools::getOutputDataScanHist(const OutputData<double> &data, const
 
     hist1->SetTitle(ostr_title.str().c_str());
     // FIXME remove this trick to bypass weird bug with DrawCopy of TH1D projection of TH1D histograms
-    TH1D *h1 = (TH1D*)hist1->Clone();
+    TH1D *h1 = dynamic_cast<TH1D*>(hist1->Clone());
     delete hist1;
     return h1;
 }
diff --git a/App/src/TestFumiliLMA.cpp b/App/src/TestFumiliLMA.cpp
index 97e6b24d1bd88e1413098fac2375c78622e327d1..6ab407368921a163737af8057203d5d2eaa4232b 100644
--- a/App/src/TestFumiliLMA.cpp
+++ b/App/src/TestFumiliLMA.cpp
@@ -180,27 +180,27 @@ void TestFumiliLMA::FillOutputDataFromFunction(OutputData<double> &data, TF2 *fu
 }
 
 
-double MyChi2Function::DataElement(const double *pars, unsigned int i, double *g ) const
+double MyChi2Function::DataElement(const double *pars, unsigned int index, double *g ) const
 {
-    double xx[2];
-    std::cout << " DataElement() -> " << g << " " << i;
-    for(int i=0; i<m_test->m_func->GetNpar(); ++i) std::cout << " " << pars[i];
+    std::cout << " DataElement() -> " << g << " " << index;
+    for(int ipar=0; ipar<m_test->m_func->GetNpar(); ++ipar) std::cout << " " << pars[ipar];
     std::cout << std::endl;
     const AxisDouble *xaxis = m_test->m_real_data->getAxis(0);
     const AxisDouble *yaxis = m_test->m_real_data->getAxis(1);
-    size_t index_x = m_test->m_real_data->toCoordinates(i)[0];
-    size_t index_y = m_test->m_real_data->toCoordinates(i)[1];
+    size_t index_x = m_test->m_real_data->toCoordinates(index)[0];
+    size_t index_y = m_test->m_real_data->toCoordinates(index)[1];
     double x = (*xaxis)[index_x];
     double y = (*yaxis)[index_y];
     m_test->m_func->SetParameters(pars);
     double value = m_test->m_func->Eval(x,y);
-    double real_value = (*m_test->m_real_data)[i];
+    double real_value = (*m_test->m_real_data)[index];
 //    std::cout << " DataElement " << i << " ix:" << index_x << " iy:" << index_y << " x:" << x << " y:" << y << " value:" << value << " real_val:" << real_value<< std::endl;
     double weight = 1./(m_test->m_sigma * m_test->m_sigma);
     double residual = weight * ( real_value - value ) ;
     if (g != 0)    {
 //        std::cout << " gradient ! " << std::endl;
         m_test->m_func->SetParameters(pars);
+        double xx[2];
         xx[0] = x;
         xx[1] = y;
         m_test->m_func->GradientPar( xx, g,1.E-9);
diff --git a/App/src/TestIsGISAXS12.cpp b/App/src/TestIsGISAXS12.cpp
index a46c265841fa0c9f9fbe86d9c0986afcfb2c9b3e..8157ba801ca60aadbe5a729486b9128d97ca78b8 100644
--- a/App/src/TestIsGISAXS12.cpp
+++ b/App/src/TestIsGISAXS12.cpp
@@ -151,8 +151,7 @@ void TestIsGISAXS12::run_isgisaxs_fit()
     // creating fit suite
     m_fitSuite = new FitSuite();
     //m_fitSuite->setMinimizer( new ROOTMinimizer("Minuit2", "Migrad") );
-    //m_fitSuite->setMinimizer( new ROOTMinimizer("GSLMultiFit", "") );
-    m_fitSuite->setMinimizer( new ROOTMinimizer("Minuit2", "Migrad") );
+    m_fitSuite->setMinimizer( new ROOTMinimizer("GSLMultiFit", "") );
     m_fitSuite->attachObserver( new FitSuiteObserverPrint(10) );
     m_fitSuite->attachObserver( new FitSuiteObserverDraw(50) );
 
diff --git a/App/src/TestIsGISAXS2.cpp b/App/src/TestIsGISAXS2.cpp
index 404e023805746f743fa69aae77f2708dea8257c7..93073e2dc7366f3b277cba3e6143771ce2d26c2c 100644
--- a/App/src/TestIsGISAXS2.cpp
+++ b/App/src/TestIsGISAXS2.cpp
@@ -26,10 +26,8 @@ void TestIsGISAXS2::execute()
     experiment.setDetectorParameters(100, 0.0*Units::degree, 2.0*Units::degree, 100, 0.0*Units::degree, 2.0*Units::degree, true);
     experiment.setBeamParameters(1.0*Units::angstrom, -0.2*Units::degree, 0.0*Units::degree);
 
-    MultiLayer *sample(0);
-
     // cylinders of two types
-    sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("IsGISAXS2_CylindersMixture"));
+    MultiLayer *sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("IsGISAXS2_CylindersMixture"));
     experiment.setSample(*sample);
     experiment.runSimulation();
     IsGISAXSTools::writeOutputDataToFile(*experiment.getOutputData(), m_data_path+"this_bimodal.ima");
diff --git a/App/src/TestIsGISAXS3.cpp b/App/src/TestIsGISAXS3.cpp
index f272b359928b1412a1c7015b24a8488fffb51f82..3dcc7ec7f5a5feb69abbc4cee0da9b1fab05af80 100644
--- a/App/src/TestIsGISAXS3.cpp
+++ b/App/src/TestIsGISAXS3.cpp
@@ -24,10 +24,8 @@ void TestIsGISAXS3::execute()
     experiment.setDetectorParameters(100, 0.0*Units::degree, 2.0*Units::degree, 100, 0.0*Units::degree, 2.0*Units::degree, true);
     experiment.setBeamParameters(1.0*Units::angstrom, -0.2*Units::degree, 0.0*Units::degree);
 
-    MultiLayer *sample(0);
-
     // cylinder in BA
-    sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("IsGISAXS3_CylinderBA"));
+    MultiLayer *sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("IsGISAXS3_CylinderBA"));
     experiment.setSample(*sample);
     experiment.runSimulation();
     IsGISAXSTools::writeOutputDataToFile(*experiment.getOutputData(), m_data_path+"this_cylinder_BA.ima");
diff --git a/App/src/TestIsGISAXS4.cpp b/App/src/TestIsGISAXS4.cpp
index 81dd6c84fbca2b485ceb07ecba5980b8e8e4c133..5ad1c79275f821e20efd58a77ec131fe688e598a 100644
--- a/App/src/TestIsGISAXS4.cpp
+++ b/App/src/TestIsGISAXS4.cpp
@@ -23,10 +23,8 @@ void TestIsGISAXS4::execute()
     experiment.setDetectorParameters(100, 0.0*Units::degree, 2.0*Units::degree, 100, 0.0*Units::degree, 2.0*Units::degree, true);
     experiment.setBeamParameters(1.0*Units::angstrom, -0.2*Units::degree, 0.0*Units::degree);
 
-    MultiLayer *p_sample(0);
-
     // 1DDL
-    p_sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("IsGISAXS4_1DDL"));
+    MultiLayer *p_sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("IsGISAXS4_1DDL"));
     experiment.setSample(*p_sample);
     experiment.runSimulation();
     IsGISAXSTools::writeOutputDataToFile(*experiment.getOutputData(), m_data_path+"this_1DDL.ima");
diff --git a/App/src/TestIsGISAXS8.cpp b/App/src/TestIsGISAXS8.cpp
index 14af6afbf24498d186bc9678513a3f7a39ea8340..afd55fc599c36efcd4d0b4254274f8a1710c6886 100644
--- a/App/src/TestIsGISAXS8.cpp
+++ b/App/src/TestIsGISAXS8.cpp
@@ -23,10 +23,8 @@ void TestIsGISAXS8::execute()
     experiment.setDetectorParameters(100, 0.0*Units::degree, 2.0*Units::degree, 100, 0.0*Units::degree, 2.0*Units::degree, true);
     experiment.setBeamParameters(1.0*Units::angstrom, -0.2*Units::degree, 0.0*Units::degree);
 
-    MultiLayer *p_sample(0);
-
     // 2DDL_lattice
-    p_sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("IsGISAXS8_2DDL_lattice"));
+    MultiLayer *p_sample = dynamic_cast<MultiLayer *>(SampleFactory::instance().createItem("IsGISAXS8_2DDL_lattice"));
     experiment.setSample(*p_sample);
     experiment.runSimulation();
     IsGISAXSTools::writeOutputDataToFile(*experiment.getOutputData(), m_data_path+"this_2DDL_lattice.ima");
diff --git a/App/src/TestIsGISAXS9.cpp b/App/src/TestIsGISAXS9.cpp
index 3a75958783f9fc55ffb63ac6497400deec719a04..ad7c418235761e42d18af6022af3976a66cc63e7 100644
--- a/App/src/TestIsGISAXS9.cpp
+++ b/App/src/TestIsGISAXS9.cpp
@@ -22,7 +22,7 @@ TestIsGISAXS9::~TestIsGISAXS9()
 
 void TestIsGISAXS9::clear()
 {
-    for(std::vector<OutputData<double> *>::iterator it=m_results.begin(); it!=m_results.end(); it++) {
+    for(std::vector<OutputData<double> *>::iterator it=m_results.begin(); it!=m_results.end(); ++it) {
         delete (*it);
     }
     m_results.clear();
diff --git a/App/src/TestPerformance.cpp b/App/src/TestPerformance.cpp
index 5ec0a58e05316f9441b58a56ffa87a4aa12aedf9..1d0df090411fca835055f76cd2ac30aeb15905cf 100644
--- a/App/src/TestPerformance.cpp
+++ b/App/src/TestPerformance.cpp
@@ -33,7 +33,7 @@ TestPerformance::TestPerformance()
 
 TestPerformance::~TestPerformance()
 {
-    for(performance_tests_t::iterator it=m_tests.begin(); it!= m_tests.end(); it++) {
+    for(performance_tests_t::iterator it=m_tests.begin(); it!= m_tests.end(); ++it) {
         delete (*it);
     }
 
@@ -53,7 +53,7 @@ void TestPerformance::execute()
 
     // run tests
     TBenchmark mb;
-    for(performance_tests_t::iterator it=m_tests.begin(); it!= m_tests.end(); it++) {
+    for(performance_tests_t::iterator it=m_tests.begin(); it!= m_tests.end(); ++it) {
         PerformanceTestInfo *test_info = (*it);
         std::string test_name = test_info->m_test->getName();
 
@@ -105,7 +105,7 @@ void TestPerformance::write_performance()
     file << m_performance_info["datime"] << get_delimeter();
     file << std::left << Utils::AdjustStringLength(m_performance_info["hostname"],10) << get_delimeter();
     file << std::left << Utils::AdjustStringLength(m_performance_info["sysinfo"],23) << get_delimeter();
-    for(performance_tests_t::iterator it=m_tests.begin(); it!= m_tests.end(); it++) {
+    for(performance_tests_t::iterator it=m_tests.begin(); it!= m_tests.end(); ++it) {
         std::string test_name = (*it)->m_test->getName();
         file << std::left << Utils::AdjustStringLength(m_performance_info[test_name],7) << get_delimeter();
     }
@@ -136,7 +136,7 @@ void TestPerformance::get_sysinfo()
     m_performance_info["hostname"] = hostname;
 
     // saving hardware information
-    std::string sysinfo;
+    //std::string sysinfo;
     SysInfo_t sys_info;
     int status = gSystem->GetSysInfo(&sys_info);
     if( status == -1) {
@@ -169,7 +169,7 @@ void PerfTest_FresnelCoeff::execute()
     kvec.setLambdaAlphaPhi(1.54*Units::angstrom, -alpha_i, 0.0);
     OpticalFresnel::MultiLayerCoeff_t coeffs;
     OpticalFresnel fresnelCalculator;
-    MultiLayer *ml = (MultiLayer *) m_sample;
+    MultiLayer *ml = dynamic_cast<MultiLayer *>(m_sample);
     fresnelCalculator.execute(*ml, kvec, coeffs);
 }
 
diff --git a/App/src/TestToyExperiment.cpp b/App/src/TestToyExperiment.cpp
index 5a64f6b9581eef0d3da32d067eb7f55d6904d727..51c0943300b4b311c6db27d2ecea3fa9e492d0c4 100644
--- a/App/src/TestToyExperiment.cpp
+++ b/App/src/TestToyExperiment.cpp
@@ -62,6 +62,7 @@ TestToyExperiment::TestToyExperiment()
     , m_sigma_noise(0)
     , m_experiment(0)
     , m_real_data(0)
+    , m_fitSuite(0)
 {
     m_sigma_noise = 0.01;
     m_func_object = new SincXSincYFunctionObject();
diff --git a/Core/Algorithms/src/ChiSquaredFrequency.cpp b/Core/Algorithms/src/ChiSquaredFrequency.cpp
index 1c0e041e3fb485eac51d4663a4fd3076823db85d..1991f387f6460378702937f31971a6d146d38339 100644
--- a/Core/Algorithms/src/ChiSquaredFrequency.cpp
+++ b/Core/Algorithms/src/ChiSquaredFrequency.cpp
@@ -98,7 +98,7 @@ void ChiSquaredFrequency::initWeights()
         n_dims[i] = (int)mp_simulation_ft->getAxis(i)->getSize();
     }
     mp_weights->setAxisSizes(rank, n_dims);
-    delete n_dims;
+    delete [] n_dims;
     OutputData<double>::iterator it_weights = mp_weights->begin();
     size_t nbr_rows = mp_weights->getAllSizes()[0];
     size_t row_length = mp_weights->getAllSizes()[1];
diff --git a/Core/Algorithms/src/GISASExperiment.cpp b/Core/Algorithms/src/GISASExperiment.cpp
index 1c61a90d6dbcbf9d6d42f2890eb953dda1585299..d2add40bcf771fb8a2deb4eb0b693ed86e5a9acc 100644
--- a/Core/Algorithms/src/GISASExperiment.cpp
+++ b/Core/Algorithms/src/GISASExperiment.cpp
@@ -114,6 +114,16 @@ void GISASExperiment::runSimulation()
 void GISASExperiment::runSimulationElement(size_t index)
 {
     (void)index;
+    Experiment::runSimulation();
+    if( !mp_sample) throw NullPointerException( "GISASExperiment::runSimulation() -> Error! No sample set.");
+
+    m_intensity_map.setAllTo(0.0);
+    DWBASimulation *p_dwba_simulation = mp_sample->createDWBASimulation();
+    if (!p_dwba_simulation) throw NullPointerException("GISASExperiment::runSimulation() -> No dwba simulation");
+    p_dwba_simulation->init(*this);
+    p_dwba_simulation->run();
+    m_intensity_map += p_dwba_simulation->getDWBAIntensity();
+    delete p_dwba_simulation;
 }
 
 
diff --git a/Core/Algorithms/src/MaskCoordinateFunction.cpp b/Core/Algorithms/src/MaskCoordinateFunction.cpp
index 070602cb61f491157a361443ffd01ed2a89aecb3..30bd131d932ae2a6520748fd63c9c15ad352da92 100644
--- a/Core/Algorithms/src/MaskCoordinateFunction.cpp
+++ b/Core/Algorithms/src/MaskCoordinateFunction.cpp
@@ -55,8 +55,8 @@ MaskCoordinateRectangleFunction* MaskCoordinateRectangleFunction::clone() const
 
 MaskCoordinateRectangleFunction::~MaskCoordinateRectangleFunction()
 {
-    delete m_minima;
-    delete m_maxima;
+    delete [] m_minima;
+    delete [] m_maxima;
 }
 
 bool MaskCoordinateRectangleFunction::isInStandardMaskedArea(const int* coordinates) const
@@ -88,8 +88,8 @@ MaskCoordinateEllipseFunction* MaskCoordinateEllipseFunction::clone() const
 
 MaskCoordinateEllipseFunction::~MaskCoordinateEllipseFunction()
 {
-    delete m_center;
-    delete m_radii;
+    delete [] m_center;
+    delete [] m_radii;
 }
 
 bool MaskCoordinateEllipseFunction::isInStandardMaskedArea(const int* coordinates) const
diff --git a/Core/Algorithms/src/MultiLayerDWBASimulation.cpp b/Core/Algorithms/src/MultiLayerDWBASimulation.cpp
index a2de088391ad2588436d74c6ad0c321188afddad..5e9eaaea6a8dcb54428892c23266cdabfc9ff4a1 100644
--- a/Core/Algorithms/src/MultiLayerDWBASimulation.cpp
+++ b/Core/Algorithms/src/MultiLayerDWBASimulation.cpp
@@ -14,7 +14,7 @@ MultiLayerDWBASimulation::MultiLayerDWBASimulation(
 MultiLayerDWBASimulation::~MultiLayerDWBASimulation()
 {
     delete mp_multi_layer;
-    for(std::map<size_t, LayerDWBASimulation*>::iterator it=m_layer_dwba_simulation_map.begin(); it!=m_layer_dwba_simulation_map.end(); it++)
+    for(std::map<size_t, LayerDWBASimulation*>::iterator it=m_layer_dwba_simulation_map.begin(); it!=m_layer_dwba_simulation_map.end(); ++it)
     {
         delete (*it).second;
     }
diff --git a/Core/Geometry/inc/BasicVector3D.h b/Core/Geometry/inc/BasicVector3D.h
index 77f1e77360bf79da9545c0ecae32cec2d3edd391..27f0250373b02b7a4d4ec3cce4ecd1308c46d394 100755
--- a/Core/Geometry/inc/BasicVector3D.h
+++ b/Core/Geometry/inc/BasicVector3D.h
@@ -586,7 +586,7 @@ class Transform3D;
     return (a.x()!=b.x() || a.y()!=b.y() || a.z()!=b.z());
   }
 
-  inline BasicVector3D<double> CrossProduct(const BasicVector3D<double> vectorLeft, const BasicVector3D<double> vectorRight)
+  inline BasicVector3D<double> CrossProduct(const BasicVector3D<double> &vectorLeft, const BasicVector3D<double> &vectorRight)
   {
       double x = vectorLeft.y()*vectorRight.z() - vectorLeft.z()*vectorRight.y();
       double y = vectorLeft.z()*vectorRight.x() - vectorLeft.x()*vectorRight.z();
@@ -594,7 +594,7 @@ class Transform3D;
       return BasicVector3D<double> (x, y, z);
   }
 
-  inline double DotProduct(const BasicVector3D<double> left, const BasicVector3D<double> right)
+  inline double DotProduct(const BasicVector3D<double> &left, const BasicVector3D<double> &right)
   {
       return left.x()*right.x() + left.y()*right.y() + left.z()*right.z();
   }
@@ -716,7 +716,7 @@ class Transform3D;
     return (a.x()!=b.x() || a.y()!=b.y() || a.z()!=b.z());
   }
 
-  inline BasicVector3D<std::complex<double> > CrossProduct(const BasicVector3D<std::complex<double> > vectorLeft, const BasicVector3D<std::complex<double> > vectorRight)
+  inline BasicVector3D<std::complex<double> > CrossProduct(const BasicVector3D<std::complex<double> > &vectorLeft, const BasicVector3D<std::complex<double> > &vectorRight)
   {
       std::complex<double> x = vectorLeft.y()*vectorRight.z() - vectorLeft.z()*vectorRight.y();
       std::complex<double> y = vectorLeft.z()*vectorRight.x() - vectorLeft.x()*vectorRight.z();
@@ -724,7 +724,7 @@ class Transform3D;
       return BasicVector3D<std::complex<double> > (x, y, z);
   }
 
-  inline std::complex<double> DotProduct(const BasicVector3D<std::complex<double> > left, const BasicVector3D<std::complex<double> > right)
+  inline std::complex<double> DotProduct(const BasicVector3D<std::complex<double> > &left, const BasicVector3D<std::complex<double> > &right)
   {
       return left.x()*right.x() + left.y()*right.y() + left.z()*right.z();
   }
diff --git a/Core/Samples/inc/ICompositeIterator.h b/Core/Samples/inc/ICompositeIterator.h
index 7532d108d10be5e64c0df75f9d5a3c1c759d7f78..acd9f8ef4d9d40561aa16f3a645c726017402dbb 100644
--- a/Core/Samples/inc/ICompositeIterator.h
+++ b/Core/Samples/inc/ICompositeIterator.h
@@ -99,7 +99,7 @@ protected:
 class ICompositeIterator
 {
 public:
-    ICompositeIterator(ICompositeSample *root) : m_root(root) { }
+    ICompositeIterator(ICompositeSample *root) : m_root(root), m_done(false) { }
     virtual ~ICompositeIterator() { }
 
     void first();
diff --git a/Core/Samples/src/Crystal.cpp b/Core/Samples/src/Crystal.cpp
index e1ba27ef0782ed7253c4a3987e0892663ef3e931..20d27bd6da11a93d3ef26338f202f83b3c3bb688 100644
--- a/Core/Samples/src/Crystal.cpp
+++ b/Core/Samples/src/Crystal.cpp
@@ -44,9 +44,8 @@ std::vector<DiffuseParticleInfo*>* Crystal::createDiffuseParticleInfo(
 {
     std::vector<DiffuseParticleInfo *> *p_result = new std::vector<DiffuseParticleInfo *>(
             mp_lattice_basis->createDiffuseParticleInfos());
-    if (p_result->size()==0) {
-        return p_result;
-    }
+    if (p_result->empty()) return p_result;
+
     double primitive_cell_volume = m_lattice.getVolume();
     double parent_volume = parent_info.getParticle()->getSimpleFormFactor()->getVolume();
     double parent_height = parent_info.getParticle()->getSimpleFormFactor()->getHeight();
diff --git a/Core/Samples/src/HomogeneousMaterial.cpp b/Core/Samples/src/HomogeneousMaterial.cpp
index 5d4ecdbd39cb6b965384e79293a91a5c8bfbda08..d66cbdf40e043fa6362d37c964c73356e2ecc254 100644
--- a/Core/Samples/src/HomogeneousMaterial.cpp
+++ b/Core/Samples/src/HomogeneousMaterial.cpp
@@ -30,7 +30,7 @@ HomogeneousMaterial::HomogeneousMaterial(const std::string &name, double refract
 
 HomogeneousMaterial::HomogeneousMaterial(const HomogeneousMaterial &other) : IMaterial(other)
 {
-    m_refractive_index = m_refractive_index;
+    m_refractive_index = other.m_refractive_index;
 }
 
 
diff --git a/Core/Samples/src/MaterialManager.cpp b/Core/Samples/src/MaterialManager.cpp
index 63163af6c80b3d9708c7250d9ea44addbf0c3a5f..1d8d8906956b8cefcff6d52b1d0b0720a4d04542 100644
--- a/Core/Samples/src/MaterialManager.cpp
+++ b/Core/Samples/src/MaterialManager.cpp
@@ -6,7 +6,7 @@
 // cleaning material database
 /* ************************************************************************* */
 void MaterialManager::clear() {
-    for(materials_t::iterator it = m_materials.begin(); it!= m_materials.end(); it++) {
+    for(materials_t::iterator it = m_materials.begin(); it!= m_materials.end(); ++it) {
         if( (*it).second ) delete (*it).second;
     }
     m_materials.clear();
@@ -66,7 +66,7 @@ const IMaterial *MaterialManager::addHomogeneousMaterial(const std::string &name
 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++) {
+    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/Samples/src/MultiLayer.cpp b/Core/Samples/src/MultiLayer.cpp
index 8c0ff2a4b161be4f7646619631f7a23720248e3e..919fb764e139eb55ddf76dece0b9cfc2084fd205 100644
--- a/Core/Samples/src/MultiLayer.cpp
+++ b/Core/Samples/src/MultiLayer.cpp
@@ -113,8 +113,7 @@ void MultiLayer::addLayerWithTopRoughness(const Layer &layer, const LayerRoughne
     if (getNumberOfLayers())
     {
         const Layer *p_last_layer = m_layers.back();
-        LayerInterface *interface(0);
-        interface = LayerInterface::createRoughInterface( p_last_layer, p_new_layer, roughness);
+        LayerInterface *interface = LayerInterface::createRoughInterface( p_last_layer, p_new_layer, roughness);
         addAndRegisterLayer(p_new_layer);
         addAndRegisterInterface(interface);
         m_layers_z.push_back(m_layers_z.back() - layer.getThickness() );
diff --git a/Core/Tools/inc/Coordinate3D.h b/Core/Tools/inc/Coordinate3D.h
index c0752197099efee49192bf812f0542a1d814f0d2..a22bbd08fb1e837869626b2bbddd4b54c8e20492 100644
--- a/Core/Tools/inc/Coordinate3D.h
+++ b/Core/Tools/inc/Coordinate3D.h
@@ -136,7 +136,7 @@ template <class T> Coordinate3D<T> operator*(const T &factor, const Coordinate3D
     return right*factor;
 }
 
-template <class T> T GetDistanceBetweenPoints(const Coordinate3D<T> left, const Coordinate3D<T> right)
+template <class T> T GetDistanceBetweenPoints(const Coordinate3D<T> &left, const Coordinate3D<T> &right)
 {
     Coordinate3D<T> connectingVector = left - right;
     return connectingVector.norm();
diff --git a/Core/Tools/inc/FitParameterLinked.h b/Core/Tools/inc/FitParameterLinked.h
index c1d2aa8e42986f182e59ceb7c2cfa0d185f3b307..29395e50acbcdcb5c28eba42cf3ee8f5332040fc 100644
--- a/Core/Tools/inc/FitParameterLinked.h
+++ b/Core/Tools/inc/FitParameterLinked.h
@@ -41,7 +41,7 @@ public:
     virtual void setValue(double value)
     {
         FitParameter::setValue(value);
-        for(PoolParameterColl_t::iterator it=m_parametercoll.begin(); it!=m_parametercoll.end(); it++) {
+        for(PoolParameterColl_t::iterator it=m_parametercoll.begin(); it!=m_parametercoll.end(); ++it) {
             (*it).setValue(value); // setting value for all registered parameters
         }
     }
diff --git a/Core/Tools/inc/IFactory.h b/Core/Tools/inc/IFactory.h
index 4722f225c1d42fa453f76694be2da45b380c8aab..5baa9c2a0beafb9753bc0029b7d9ba391f51076b 100644
--- a/Core/Tools/inc/IFactory.h
+++ b/Core/Tools/inc/IFactory.h
@@ -89,7 +89,7 @@ public:
         m_callbacks.clear();
         if(m_own_objects) {
             typename std::vector<AbstractProduct *>::iterator it;
-            for(it=m_objects.begin(); it!=m_objects.end(); it++) {
+            for(it=m_objects.begin(); it!=m_objects.end(); ++it) {
                 delete (*it);
             }
         }
diff --git a/Core/Tools/inc/INamed.h b/Core/Tools/inc/INamed.h
index 080c16009e1bf72d2504b92a108c1c0af308224d..03724bfd6fd3623c8bcba1e3657a199002ca122d 100644
--- a/Core/Tools/inc/INamed.h
+++ b/Core/Tools/inc/INamed.h
@@ -25,8 +25,8 @@ class INamed
 {
 public:
     INamed() {}
-    INamed(std::string name) { m_name = name; }
-    INamed(std::string name, std::string title) { m_name = name; m_title=title; }
+    INamed(const std::string &name) : m_name(name) { }
+    INamed(const std::string &name, const std::string &title) : m_name(name), m_title(title) { }
     virtual ~INamed(){}
 
     virtual void setName(std::string name) { m_name = name; }
diff --git a/Core/Tools/inc/ISingleton.h b/Core/Tools/inc/ISingleton.h
index ecf12a9c45fe041f738c530d04c7c7777a0dfd24..163adf5d5f44e48ded5af91e682b7248a0648f34 100644
--- a/Core/Tools/inc/ISingleton.h
+++ b/Core/Tools/inc/ISingleton.h
@@ -66,7 +66,7 @@ protected:
 
 private:
     ISingleton(const ISingleton<T> &) {}
-    ISingleton &operator=(const ISingleton<T> &) { throw; }
+    ISingleton &operator=(const ISingleton<T> &) { throw std::runtime_error("ISingleton::operator=()"); }
 
     static T_Pointer m_instance;
     static bool m_destroyed;
diff --git a/Core/Tools/inc/Utils.h b/Core/Tools/inc/Utils.h
index ca3e752c53c7b51b08162548ae6a89cc630ead3f..da1e4cf0faeb31664ce15bf06ac6b7b0398811b0 100644
--- a/Core/Tools/inc/Utils.h
+++ b/Core/Tools/inc/Utils.h
@@ -92,7 +92,7 @@ public:
     static std::string GetHomePath();
 
     //! set relative path, which is the path from working directory to executable module. The value is known only from argv[0] and should be set from outside
-    static void SetRelativePath(const std::string path) { m_relative_path = path; }
+    static void SetRelativePath(const std::string &path) { m_relative_path = path; }
 
 private:
     static std::string m_relative_path; //!< it's value of argv[0], i.e. the path from working directory to executable module
diff --git a/Core/Tools/src/FitSuite.cpp b/Core/Tools/src/FitSuite.cpp
index bc8f40d6192aed474c18403473ada4a23ba49e84..6ef0468a6d8ba0a8554e7e730c6ab9016cf07ab8 100644
--- a/Core/Tools/src/FitSuite.cpp
+++ b/Core/Tools/src/FitSuite.cpp
@@ -181,6 +181,7 @@ double FitSuite::functionToMinimize(const double *pars_current_values)
 /* ************************************************************************* */
 double FitSuite::elementFunction(const double *pars_current_values, unsigned int index, double *deriv)
 {
+    if(index % 10 == 0) std::cout << " elementFunction " << index << std::endl;
     // set fitting parameters to values suggested by the minimizer
     m_fit_parameters.setValues(pars_current_values);
 
diff --git a/Core/Tools/src/OutputDataFunctions.cpp b/Core/Tools/src/OutputDataFunctions.cpp
index 0971cc09d341daa9737a19c3d4e45265b3756023..6e2e36819b9f3d0b34745b19c22a97243d8b7bb6 100644
--- a/Core/Tools/src/OutputDataFunctions.cpp
+++ b/Core/Tools/src/OutputDataFunctions.cpp
@@ -109,6 +109,8 @@ void OutputDataFunctions::fourierTransformR(const OutputData<complex_t>& source,
     }
     // allocate result
     if (source.getAllocatedSize() != total_complex_size) {
+        delete[] n_real_dims;
+        delete[] n_complex_dims;
         throw ClassInitializationException("Inverse Fourier transform requires properly allocated map sizes");
     }
     //  initialize temporary arrays
diff --git a/Core/Tools/src/ParameterPool.cpp b/Core/Tools/src/ParameterPool.cpp
index 17ab19c17269b67d0e4f11ebb5ca4ce95eadf3b2..42fecbe76f32ea5f8595415886617680f727f83e 100644
--- a/Core/Tools/src/ParameterPool.cpp
+++ b/Core/Tools/src/ParameterPool.cpp
@@ -122,7 +122,7 @@ std::vector<ParameterPool::RealPar >  ParameterPool::getMatchedParameters(const
 {
     std::vector<ParameterPool::RealPar > selected_parameters;
     // loop over all parameters in the pool
-    for(parametermap_t::const_iterator it=m_map.begin(); it!= m_map.end(); it++) {
+    for(parametermap_t::const_iterator it=m_map.begin(); it!= m_map.end(); ++it) {
         // (*it).first - parameter key, (*it).second - parameter itself
         // parameters whose key match pattern is added to the FitMultiParameter container
         if( Utils::StringMatchText::WildcardPattern( (*it).first, wildcards ) ) {
@@ -161,7 +161,7 @@ bool ParameterPool::setParameterValue(const std::string &name, double value)
 int ParameterPool::setMatchedParametersValue(const std::string &wildcards, double value)
 {
     int npars(0);
-    for(parametermap_t::iterator it=m_map.begin(); it!= m_map.end(); it++) {
+    for(parametermap_t::iterator it=m_map.begin(); it!= m_map.end(); ++it) {
         if( Utils::StringMatchText::WildcardPattern( (*it).first, wildcards ) ) {
             (*it).second.setValue(value);
             npars++;
@@ -183,14 +183,14 @@ void ParameterPool::print(std::ostream &ostr) const
         if(nsize < 4) {
             ostr << "POOL_" << nsize;
             ostr << "(";
-            for(parametermap_t::const_iterator it=m_map.begin(); it!= m_map.end(); it++) {
+            for(parametermap_t::const_iterator it=m_map.begin(); it!= m_map.end(); ++it) {
                 std::cout << "'" << (*it).first << "'" << ":" << it->second.getValue() << " " ;
             }
             ostr << ")";
 
         // printing in several lines
         } else {
-            for(parametermap_t::const_iterator it=m_map.begin(); it!= m_map.end(); it++) {
+            for(parametermap_t::const_iterator it=m_map.begin(); it!= m_map.end(); ++it) {
                 std::cout << "'" << (*it).first << "'" << ":" << it->second.getValue() << std::endl;
             }
         }
diff --git a/Core/Tools/src/ProgramOptions.cpp b/Core/Tools/src/ProgramOptions.cpp
index 2340c2597af6fe9f1c432e2e2d581e0e625b1101..2a8e6bd09c7523b21972af42719116160a802dbe 100644
--- a/Core/Tools/src/ProgramOptions.cpp
+++ b/Core/Tools/src/ProgramOptions.cpp
@@ -59,7 +59,7 @@ void ProgramOptions::parseCommandLine(int argc, char **argv)
         // we get here if there is unrecognized options
         std::cout << "ProgramOptions::parseCommanLine() -> Error. Unrecognized options in command line." << std::endl;
         std::cerr << "error: " << e.what() << "\n";
-        throw e; // throwing it further to terminate program
+        throw; // throwing it further to terminate program
     }
 
     // and now call parsing of config file
@@ -100,7 +100,7 @@ void ProgramOptions::parseConfigFile()
             // we get here if there is unrecognized options
             std::cout << "ProgramOptions::parseConfigFile() -> Error. Unrecognized options in file '" << config_file << "'" << std::endl;
             std::cerr << "error: " << e.what() << "\n";
-            throw e; // throwing it further to terminate program
+            throw; // throwing it further to terminate program
         }
     }
 
diff --git a/Examples/Performance/perf_history.txt b/Examples/Performance/perf_history.txt
index 864bb43fcdcbb1311d60e498ade900acf4f60d14..aa0eff27ab9cd93a6de8e080a91b9093b736abb6 100644
--- a/Examples/Performance/perf_history.txt
+++ b/Examples/Performance/perf_history.txt
@@ -154,4 +154,8 @@
 # current status of the art
 2012-11-29 11:09:34 | jcnsopc73  | macosx64, 2800 MHz      | 266667  | 14.7059 | 14.2857 | 5.26316 | 
 
-2012-11-29 11:14:27 | jcnsopc73  | macosx64, 2800 MHz      | 253165  | 14.3885 | 14.2857 | 5.40541 | 
+2012-11-29 11:14:27 | jcnsopc73  | macosx64, 2800 MHz      | 253165  | 14.3885 | 14.2857 | 5.40541 |
+
+# fast-math is off; few performance changes in OutputData and BasicVector3D
+2012-12-13 10:06:39 | jcnsopc73  | macosx64, 2800 MHz      | 259740  | 19.802  | 19.2308 | 5.26316 | 
+
diff --git a/Macros/CodeProfiling/run_valgrind.sh b/Macros/CodeProfiling/run_valgrind.sh
index 3a4f37de804de5325cb14a48aa5bdabf2191a2a8..0f2e9b9f5d052ffe1e8d2a159d4d1bc5ff2fe0a5 100755
--- a/Macros/CodeProfiling/run_valgrind.sh
+++ b/Macros/CodeProfiling/run_valgrind.sh
@@ -9,7 +9,7 @@ application=../../App/App
 #arguments="isgisaxs10 batch"
 #arguments="isgisaxs9 batch"
 #arguments="isgisaxs2 batch profile"
-arguments="--isgisaxs03 --batch"
+arguments="--isgisaxs09 --batch"
 focuson=GISASExperiment
 
 # ------------------------------------------- #
diff --git a/shared.pri b/shared.pri
index 3b00e638fe7ad40dc3c18974ec14bac942511f78..8a97ab6dd4c5ed36cb6417b46122f7a933ede75d 100644
--- a/shared.pri
+++ b/shared.pri
@@ -105,7 +105,8 @@ CONFIG(JCNS) {
 QMAKE_CXXFLAGS_DEBUG += -fdiagnostics-show-option # to find out in gcc which option control warning
 #QMAKE_CXXFLAGS_RELEASE += -O3 -ffast-math -msse3
 QMAKE_CXXFLAGS_RELEASE -= -O2
-QMAKE_CXXFLAGS_RELEASE += -g -O3 -ffast-math
+QMAKE_CXXFLAGS_RELEASE += -g -O3
+#QMAKE_CXXFLAGS_RELEASE += -g -O3
 # uncommenting line below produces non-stripped (very large) libraries
 #QMAKE_STRIP=: