diff --git a/Framework/API/src/NumericAxis.cpp b/Framework/API/src/NumericAxis.cpp
index 819ad1a5445b13c0a0415db954d2b2650bfe0d60..d609325a2397082f50219cfd5610807e58ae826c 100644
--- a/Framework/API/src/NumericAxis.cpp
+++ b/Framework/API/src/NumericAxis.cpp
@@ -191,9 +191,9 @@ std::string NumericAxis::label(const std::size_t &index) const {
   auto it = numberLabel.end() - 1;
   for (; it != numberLabel.begin(); --it) {
     if (*it == '0') {
-      numberLabel.erase(it);
+      it = numberLabel.erase(it);
     } else if (*it == '.') {
-      numberLabel.erase(it);
+      it = numberLabel.erase(it);
       break;
     } else {
       break;
diff --git a/Framework/Algorithms/src/AlignDetectors.cpp b/Framework/Algorithms/src/AlignDetectors.cpp
index de941aea91cf913e25be29eb8cb537a740f617e7..b45eade446063828c8540bdce23008dce25026f6 100644
--- a/Framework/Algorithms/src/AlignDetectors.cpp
+++ b/Framework/Algorithms/src/AlignDetectors.cpp
@@ -151,7 +151,9 @@ const std::string AlignDetectors::summary() const {
 }
 
 /// (Empty) Constructor
-AlignDetectors::AlignDetectors() { this->tofToDmap = NULL; }
+AlignDetectors::AlignDetectors() : m_numberOfSpectra(0) {
+  this->tofToDmap = NULL;
+}
 
 /// Destructor
 AlignDetectors::~AlignDetectors() { delete this->tofToDmap; }
diff --git a/Framework/Algorithms/src/CreateDummyCalFile.cpp b/Framework/Algorithms/src/CreateDummyCalFile.cpp
index d7c9020aaf9ecfded65339768e765ff11d20f89b..a13e9ba5626e143f39053f6c44d5f3dea6f87ca6 100644
--- a/Framework/Algorithms/src/CreateDummyCalFile.cpp
+++ b/Framework/Algorithms/src/CreateDummyCalFile.cpp
@@ -111,7 +111,7 @@ void CreateDummyCalFile::exec() {
   std::string filename = getProperty("CalFilename");
 
   // Plan to overwrite file, so do not check if it exists
-  bool overwrite = false;
+  const bool overwrite = false;
 
   int number = 0;
   Progress prog(this, 0.0, 0.8, assemblies.size());
diff --git a/Framework/Algorithms/src/FFT.cpp b/Framework/Algorithms/src/FFT.cpp
index f8e6db3c74314b67a7c712256543b0733b55e805..1d6f94e2bf38fe60405370cd002df6453f65d240 100644
--- a/Framework/Algorithms/src/FFT.cpp
+++ b/Framework/Algorithms/src/FFT.cpp
@@ -172,7 +172,7 @@ void FFT::exec() {
   // centerShift == true means that the zero on the x axis is assumed to be in
   // the data centre
   // at point with index i = ySize/2. If shift == false the zero is at i = 0
-  bool centerShift = true;
+  const bool centerShift = true;
 
   API::TextAxis *tAxis = new API::TextAxis(nOut);
   int iRe = 0;
diff --git a/Framework/Algorithms/src/FindPeakBackground.cpp b/Framework/Algorithms/src/FindPeakBackground.cpp
index f5de226028bff2fb6f34e25ccc26c37f68d85f66..047bb0748a29536e74291b11089fd189ca149331 100644
--- a/Framework/Algorithms/src/FindPeakBackground.cpp
+++ b/Framework/Algorithms/src/FindPeakBackground.cpp
@@ -157,7 +157,7 @@ void FindPeakBackground::exec() {
     Statistics stats = getStatistics(maskedY);
     Ymean = stats.mean;
     Yvariance = stats.standard_deviation * stats.standard_deviation;
-    Ysigma = std::sqrt((moment4(maskedY, n - l0, Ymean) -
+    Ysigma = std::sqrt((moment4(maskedY, static_cast<size_t>(xn), Ymean) -
                         (xn - 3.0) / (xn - 1.0) * Yvariance) /
                        xn);
     MantidVec::const_iterator it =
diff --git a/Framework/Algorithms/src/MonitorEfficiencyCorUser.cpp b/Framework/Algorithms/src/MonitorEfficiencyCorUser.cpp
index 6b04c6163b6b0eb648f952a3611da0105d343efd..cd05823acf6c0f4b34c652dfc084c6bd9bd37545 100644
--- a/Framework/Algorithms/src/MonitorEfficiencyCorUser.cpp
+++ b/Framework/Algorithms/src/MonitorEfficiencyCorUser.cpp
@@ -19,7 +19,8 @@ DECLARE_ALGORITHM(MonitorEfficiencyCorUser)
 //----------------------------------------------------------------------------------------------
 /** Constructor
  */
-MonitorEfficiencyCorUser::MonitorEfficiencyCorUser() {}
+MonitorEfficiencyCorUser::MonitorEfficiencyCorUser()
+    : m_inputWS(), m_outputWS(), m_Ei(.0), m_monitorCounts(0) {}
 
 //----------------------------------------------------------------------------------------------
 /** Destructor
diff --git a/Framework/Algorithms/src/RemovePromptPulse.cpp b/Framework/Algorithms/src/RemovePromptPulse.cpp
index ceaecb85d4746b238478623d474eab6efed925c3..a5f338a5942b2314618d3c8f065e6214de340a89 100644
--- a/Framework/Algorithms/src/RemovePromptPulse.cpp
+++ b/Framework/Algorithms/src/RemovePromptPulse.cpp
@@ -72,7 +72,7 @@ void getTofRange(MatrixWorkspace_const_sptr wksp, double &tmin, double &tmax) {
   DataObjects::EventWorkspace_const_sptr eventWksp =
       boost::dynamic_pointer_cast<const DataObjects::EventWorkspace>(wksp);
 
-  bool isEvent = false;
+  const bool isEvent = false;
   if (isEvent) {
     eventWksp->getEventXMinMax(tmin, tmax);
   } else {
diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/RefinePowderInstrumentParameters.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/RefinePowderInstrumentParameters.h
index ae51ee6bc546147d19ee3d365b728512e0bf0641..9d3eeba57a4f02f257190c767a07f51f4f6f6df0 100644
--- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/RefinePowderInstrumentParameters.h
+++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/RefinePowderInstrumentParameters.h
@@ -152,43 +152,43 @@ private:
 
   //--------------- Class Variables -------------------
   /// Output Workspace containing the dspacing ~ TOF peak positions
-  DataObjects::Workspace2D_sptr dataWS;
+  DataObjects::Workspace2D_sptr m_dataWS;
 
   /// Map for all peaks to fit individually
-  std::map<std::vector<int>, Functions::BackToBackExponential_sptr> mPeaks;
+  std::map<std::vector<int>, Functions::BackToBackExponential_sptr> m_Peaks;
 
   /// Map for all peaks' error (fitted vs. experimental): [HKL]: Chi^2
-  std::map<std::vector<int>, double> mPeakErrors;
+  std::map<std::vector<int>, double> m_PeakErrors;
 
   /// Map for function (instrument parameter)
-  std::map<std::string, double> mFuncParameters;
+  std::map<std::string, double> m_FuncParameters;
   /// Map to store the original (input) parameters
-  std::map<std::string, double> mOrigParameters;
+  std::map<std::string, double> m_OrigParameters;
 
   /// Peak function parameter names
-  std::vector<std::string> mPeakFunctionParameterNames;
+  std::vector<std::string> m_PeakFunctionParameterNames;
   /// N sets of the peak parameter values for the best N chi2 for MC.  It is
   /// paired with mPeakFunctionParameterNames
-  std::vector<std::pair<double, std::vector<double>>> mBestMCParameters;
+  std::vector<std::pair<double, std::vector<double>>> m_BestMCParameters;
   /// N sets of the peak parameter values for the best N chi2 for MC.  It is
   /// paired with mPeakFunctionParameterNames
-  std::vector<std::pair<double, std::vector<double>>> mBestFitParameters;
+  std::vector<std::pair<double, std::vector<double>>> m_BestFitParameters;
   /// N sets of the homemade chi2 and gsl chi2
-  std::vector<std::pair<double, double>> mBestFitChi2s;
+  std::vector<std::pair<double, double>> m_BestFitChi2s;
   /// Best Chi2 ever
-  double mBestGSLChi2;
+  double m_BestGSLChi2;
 
   /// Minimum allowed sigma of a peak
-  double mMinSigma;
+  double m_MinSigma;
 
   /// Minimum number of fitted peaks for refinement
-  size_t mMinNumFittedPeaks;
+  size_t m_MinNumFittedPeaks;
 
   /// Maximum number of data stored
-  size_t mMaxNumberStoredParameters;
+  size_t m_MaxNumberStoredParameters;
 
   /// Modelling function
-  Functions::ThermalNeutronDtoTOFFunction_sptr mFunction;
+  Functions::ThermalNeutronDtoTOFFunction_sptr m_Function;
 };
 
 /** Formular for linear iterpolation: X = [(xf-x0)*Y - (xf*y0-x0*yf)]/(yf-y0)
diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/GSLMatrix.h b/Framework/CurveFitting/inc/MantidCurveFitting/GSLMatrix.h
index e9e35f7ac6e9d915984bba1aa8a17d91f7c10955..9add0ff7f666e5946222020673c31a24eb6c58d6 100644
--- a/Framework/CurveFitting/inc/MantidCurveFitting/GSLMatrix.h
+++ b/Framework/CurveFitting/inc/MantidCurveFitting/GSLMatrix.h
@@ -241,6 +241,7 @@ inline GSLMatrixMult3 operator*(const GSLMatrixMult2 &mm, const Tr &m) {
 
 /// The << operator. Prints a matrix in rows.
 inline std::ostream &operator<<(std::ostream &ostr, const GSLMatrix &m) {
+  std::ios::fmtflags fflags(ostr.flags());
   ostr << std::scientific << std::setprecision(6);
   for (size_t i = 0; i < m.size1(); ++i) {
     for (size_t j = 0; j < m.size2(); ++j) {
@@ -248,6 +249,7 @@ inline std::ostream &operator<<(std::ostream &ostr, const GSLMatrix &m) {
     }
     ostr << std::endl;
   }
+  ostr.flags(fflags);
   return ostr;
 }
 
diff --git a/Framework/CurveFitting/src/Algorithms/RefinePowderInstrumentParameters.cpp b/Framework/CurveFitting/src/Algorithms/RefinePowderInstrumentParameters.cpp
index 98a64f0b76769673b79f16fcf1fab4ce31aea6d1..80d4fdec61c340ed49b564399931f1824e76dc26 100644
--- a/Framework/CurveFitting/src/Algorithms/RefinePowderInstrumentParameters.cpp
+++ b/Framework/CurveFitting/src/Algorithms/RefinePowderInstrumentParameters.cpp
@@ -48,7 +48,9 @@ DECLARE_ALGORITHM(RefinePowderInstrumentParameters)
 //----------------------------------------------------------------------------------------------
 /** Constructor
  */
-RefinePowderInstrumentParameters::RefinePowderInstrumentParameters() {}
+RefinePowderInstrumentParameters::RefinePowderInstrumentParameters()
+    : m_BestGSLChi2(0.0), m_MinSigma(0.0), m_MinNumFittedPeaks(0),
+      m_MaxNumberStoredParameters(0) {}
 
 //----------------------------------------------------------------------------------------------
 /** Destructor
@@ -145,7 +147,7 @@ void RefinePowderInstrumentParameters::exec() {
   DataObjects::TableWorkspace_sptr parameterWS =
       this->getProperty("InstrumentParameterWorkspace");
 
-  mMinSigma = getProperty("MinSigma");
+  m_MinSigma = getProperty("MinSigma");
 
   int tempint = getProperty("MinNumberFittedPeaks");
   if (tempint <= 1) {
@@ -153,13 +155,13 @@ void RefinePowderInstrumentParameters::exec() {
                   << " is too small. " << endl;
     throw std::invalid_argument("Input MinNumberFittedPeaks is too small.");
   }
-  mMinNumFittedPeaks = static_cast<size_t>(tempint);
+  m_MinNumFittedPeaks = static_cast<size_t>(tempint);
 
   tempint = getProperty("NumberBestFitRecorded");
   if (tempint <= 0)
     throw runtime_error(
         "Input NumberBestFitRecorded cannot be less and equal to 0. ");
-  mMaxNumberStoredParameters = static_cast<size_t>(tempint);
+  m_MaxNumberStoredParameters = static_cast<size_t>(tempint);
 
   string algoption = getProperty("RefinementAlgorithm");
   if (algoption.compare("DirectFit") == 0)
@@ -172,14 +174,14 @@ void RefinePowderInstrumentParameters::exec() {
 
   // 2. Parse input table workspace
   genPeaksFromTable(peakWS);
-  importParametersFromTable(parameterWS, mFuncParameters);
-  mOrigParameters = mFuncParameters;
+  importParametersFromTable(parameterWS, m_FuncParameters);
+  m_OrigParameters = m_FuncParameters;
 
   // 3. Generate a cener workspace as function of d-spacing.
   bool usemc = false;
   if (refinealgorithm == MonteCarlo)
     usemc = true;
-  genPeakCentersWorkspace(usemc, mMaxNumberStoredParameters);
+  genPeakCentersWorkspace(usemc, m_MaxNumberStoredParameters);
 
   // 4. Fit instrument geometry function
   stringstream errss;
@@ -208,7 +210,7 @@ void RefinePowderInstrumentParameters::exec() {
   }
 
   // 5. Set output workspace
-  this->setProperty("OutputWorkspace", dataWS);
+  this->setProperty("OutputWorkspace", m_dataWS);
 
   // 6. Output new instrument parameters
   DataObjects::TableWorkspace_sptr fitparamws =
@@ -228,16 +230,16 @@ void RefinePowderInstrumentParameters::fitInstrumentParameters() {
 
   // 1. Initialize the fitting function
   ThermalNeutronDtoTOFFunction rawfunc;
-  mFunction = boost::make_shared<ThermalNeutronDtoTOFFunction>(rawfunc);
-  mFunction->initialize();
+  m_Function = boost::make_shared<ThermalNeutronDtoTOFFunction>(rawfunc);
+  m_Function->initialize();
 
-  API::FunctionDomain1DVector domain(dataWS->readX(1));
+  API::FunctionDomain1DVector domain(m_dataWS->readX(1));
   API::FunctionValues values(domain);
-  const MantidVec &rawY = dataWS->readY(0);
-  const MantidVec &rawE = dataWS->readE(0);
+  const MantidVec &rawY = m_dataWS->readY(0);
+  const MantidVec &rawE = m_dataWS->readE(0);
 
   // 2. Set up parameters values
-  std::vector<std::string> funparamnames = mFunction->getParameterNames();
+  std::vector<std::string> funparamnames = m_Function->getParameterNames();
 
   std::vector<std::string> paramtofit = getProperty("ParametersToFit");
   std::sort(paramtofit.begin(), paramtofit.end());
@@ -247,22 +249,22 @@ void RefinePowderInstrumentParameters::fitInstrumentParameters() {
   std::map<std::string, double>::iterator paramiter;
   for (size_t i = 0; i < funparamnames.size(); ++i) {
     string parname = funparamnames[i];
-    paramiter = mFuncParameters.find(parname);
-    if (paramiter == mFuncParameters.end()) {
+    paramiter = m_FuncParameters.find(parname);
+    if (paramiter == m_FuncParameters.end()) {
       // Not found and thus skip
       continue;
     }
 
     double parvalue = paramiter->second;
-    mFunction->setParameter(parname, parvalue);
+    m_Function->setParameter(parname, parvalue);
     msgss << setw(10) << parname << " = " << parvalue << endl;
   }
   cout << msgss.str();
 
   // 2b. Calculate the statistic of the starting values
-  double gslchi2 = calculateFunctionStatistic(mFunction, dataWS, 0);
+  double gslchi2 = calculateFunctionStatistic(m_Function, m_dataWS, 0);
   double homchi2 =
-      calculateD2TOFFunction(mFunction, domain, values, rawY, rawE);
+      calculateD2TOFFunction(m_Function, domain, values, rawY, rawE);
   cout << "Fit Starting Value:  Chi^2 (GSL) = " << gslchi2
        << ",  Chi2^2 (Home) = " << homchi2 << endl;
 
@@ -274,9 +276,9 @@ void RefinePowderInstrumentParameters::fitInstrumentParameters() {
     vsiter = std::find(paramtofit.begin(), paramtofit.end(), parname);
 
     if (vsiter == paramtofit.end())
-      mFunction->fix(i);
+      m_Function->fix(i);
     else
-      mFunction->unfix(i);
+      m_Function->unfix(i);
   }
 
   // 4. Select minimizer.  Use Simplex for more than 1 parameters to fit.
@@ -288,13 +290,13 @@ void RefinePowderInstrumentParameters::fitInstrumentParameters() {
   g_log.information() << "Fit use minizer: " << minimizer << endl;
 
   // 5. Create and setup fit algorithm
-  g_log.information() << "Fit instrument geometry: " << mFunction->asString()
+  g_log.information() << "Fit instrument geometry: " << m_Function->asString()
                       << std::endl;
 
   stringstream outss;
-  for (size_t i = 0; i < dataWS->readX(0).size(); ++i)
-    outss << dataWS->readX(0)[i] << "\t\t" << dataWS->readY(0)[i] << "\t\t"
-          << dataWS->readE(0)[i] << endl;
+  for (size_t i = 0; i < m_dataWS->readX(0).size(); ++i)
+    outss << m_dataWS->readX(0)[i] << "\t\t" << m_dataWS->readY(0)[i] << "\t\t"
+          << m_dataWS->readE(0)[i] << endl;
   cout << "Input Peak Position Workspace To Fit: " << endl
        << outss.str() << endl;
 
@@ -302,8 +304,8 @@ void RefinePowderInstrumentParameters::fitInstrumentParameters() {
   fitalg->initialize();
 
   fitalg->setProperty("Function",
-                      boost::dynamic_pointer_cast<API::IFunction>(mFunction));
-  fitalg->setProperty("InputWorkspace", dataWS);
+                      boost::dynamic_pointer_cast<API::IFunction>(m_Function));
+  fitalg->setProperty("InputWorkspace", m_dataWS);
   fitalg->setProperty("WorkspaceIndex", 0);
   fitalg->setProperty("Minimizer", minimizer);
   fitalg->setProperty("CostFunction", "Least squares");
@@ -326,31 +328,31 @@ void RefinePowderInstrumentParameters::fitInstrumentParameters() {
   API::IFunction_sptr fitfunc = fitalg->getProperty("Function");
 
   // 4. Set the output data (model and diff)
-  mFunction->function(domain, values);
+  m_Function->function(domain, values);
 
   for (size_t i = 0; i < domain.size(); ++i) {
-    dataWS->dataY(1)[i] = values[i];
-    dataWS->dataY(2)[i] = dataWS->readY(0)[i] - values[i];
+    m_dataWS->dataY(1)[i] = values[i];
+    m_dataWS->dataY(2)[i] = m_dataWS->readY(0)[i] - values[i];
   }
 
   double selfchi2 =
-      calculateD2TOFFunction(mFunction, domain, values, rawY, rawE);
+      calculateD2TOFFunction(m_Function, domain, values, rawY, rawE);
   cout << "Homemade Chi^2 = " << selfchi2 << endl;
 
   // 5. Update fitted parameters
   for (size_t i = 0; i < funparamnames.size(); ++i) {
     std::string parname = funparamnames[i];
     double parvalue = fitfunc->getParameter(parname);
-    mFuncParameters[parname] = parvalue;
+    m_FuncParameters[parname] = parvalue;
   }
 
   // 6. Pretty screen output
   stringstream dbss;
   dbss << "************ Fit Parameter Result *************" << std::endl;
-  for (paramiter = mFuncParameters.begin(); paramiter != mFuncParameters.end();
-       ++paramiter) {
+  for (paramiter = m_FuncParameters.begin();
+       paramiter != m_FuncParameters.end(); ++paramiter) {
     std::string parname = paramiter->first;
-    double inpparvalue = mOrigParameters[parname];
+    double inpparvalue = m_OrigParameters[parname];
     double parvalue = paramiter->second;
     dbss << setw(20) << parname << " = " << setw(15) << setprecision(6)
          << parvalue << "\t\tFrom " << setw(15) << setprecision(6)
@@ -362,18 +364,18 @@ void RefinePowderInstrumentParameters::fitInstrumentParameters() {
   // 7. Play with Zscore:     template<typename TYPE>
   //    std::vector<double> getZscore(const std::vector<TYPE>& data, const bool
   //    sorted=false);
-  vector<double> z0 = Kernel::getZscore(dataWS->readY(0));
-  vector<double> z1 = Kernel::getZscore(dataWS->readY(1));
-  vector<double> z2 = Kernel::getZscore(dataWS->readY(2));
+  vector<double> z0 = Kernel::getZscore(m_dataWS->readY(0));
+  vector<double> z1 = Kernel::getZscore(m_dataWS->readY(1));
+  vector<double> z2 = Kernel::getZscore(m_dataWS->readY(2));
   stringstream zss;
   zss << setw(20) << "d_h" << setw(20) << "Z DataY" << setw(20) << "Z ModelY"
       << setw(20) << "Z DiffY" << setw(20) << "DiffY" << endl;
   for (size_t i = 0; i < z0.size(); ++i) {
-    double d_h = dataWS->readX(0)[i];
+    double d_h = m_dataWS->readX(0)[i];
     double zdatay = z0[i];
     double zmodely = z1[i];
     double zdiffy = z2[i];
-    double diffy = dataWS->readY(2)[i];
+    double diffy = m_dataWS->readY(2)[i];
     zss << setw(20) << d_h << setw(20) << zdatay << setw(20) << zmodely
         << setw(20) << zdiffy << setw(20) << diffy << endl;
   }
@@ -392,7 +394,7 @@ bool RefinePowderInstrumentParameters::fitFunction(IFunction_sptr func,
 
   fitalg->setProperty("Function",
                       boost::dynamic_pointer_cast<API::IFunction>(func));
-  fitalg->setProperty("InputWorkspace", dataWS);
+  fitalg->setProperty("InputWorkspace", m_dataWS);
   fitalg->setProperty("WorkspaceIndex", 0);
   fitalg->setProperty("Minimizer", "Simplex");
   fitalg->setProperty("CostFunction", "Least squares");
@@ -462,19 +464,20 @@ double RefinePowderInstrumentParameters::calculateFunctionStatistic(
 void RefinePowderInstrumentParameters::refineInstrumentParametersMC(
     TableWorkspace_sptr parameterWS, bool fit2) {
   // 1. Get function's parameter names
-  getD2TOFFuncParamNames(mPeakFunctionParameterNames);
+  getD2TOFFuncParamNames(m_PeakFunctionParameterNames);
 
   // 2. Parse parameter (table) workspace
   vector<double> stepsizes, lowerbounds, upperbounds;
-  importMonteCarloParametersFromTable(parameterWS, mPeakFunctionParameterNames,
+  importMonteCarloParametersFromTable(parameterWS, m_PeakFunctionParameterNames,
                                       stepsizes, lowerbounds, upperbounds);
 
   stringstream dbss;
-  for (size_t i = 0; i < mPeakFunctionParameterNames.size(); ++i) {
-    dbss << setw(20) << mPeakFunctionParameterNames[i] << ": Min = " << setw(15)
-         << setprecision(6) << lowerbounds[i] << ", Max = " << setw(15)
-         << setprecision(6) << upperbounds[i] << ", Step Size = " << setw(15)
-         << setprecision(6) << stepsizes[i] << endl;
+  for (size_t i = 0; i < m_PeakFunctionParameterNames.size(); ++i) {
+    dbss << setw(20) << m_PeakFunctionParameterNames[i]
+         << ": Min = " << setw(15) << setprecision(6) << lowerbounds[i]
+         << ", Max = " << setw(15) << setprecision(6) << upperbounds[i]
+         << ", Step Size = " << setw(15) << setprecision(6) << stepsizes[i]
+         << endl;
   }
   g_log.notice() << "Monte Carlo Parameters: " << endl
                  << dbss.str();
@@ -494,33 +497,33 @@ void RefinePowderInstrumentParameters::refineInstrumentParametersMC(
   double stepsizescalefactor = 1.1;
 
   // 5. Monte Carlo simulation
-  doParameterSpaceRandomWalk(mPeakFunctionParameterNames, lowerbounds,
+  doParameterSpaceRandomWalk(m_PeakFunctionParameterNames, lowerbounds,
                              upperbounds, stepsizes, maxsteps,
                              stepsizescalefactor, fit2);
 
   // 6. Record the result
-  const MantidVec &X = dataWS->readX(0);
-  const MantidVec &Y = dataWS->readY(0);
-  const MantidVec &E = dataWS->readE(0);
+  const MantidVec &X = m_dataWS->readX(0);
+  const MantidVec &Y = m_dataWS->readY(0);
+  const MantidVec &E = m_dataWS->readE(0);
   FunctionDomain1DVector domain(X);
   FunctionValues values(domain);
-  for (size_t i = 0; i < mBestFitParameters.size(); ++i) {
+  for (size_t i = 0; i < m_BestFitParameters.size(); ++i) {
     // a. Set the function with the
-    for (size_t j = 0; j < mPeakFunctionParameterNames.size(); ++j) {
-      mFunction->setParameter(mPeakFunctionParameterNames[j],
-                              mBestFitParameters[i].second[j]);
+    for (size_t j = 0; j < m_PeakFunctionParameterNames.size(); ++j) {
+      m_Function->setParameter(m_PeakFunctionParameterNames[j],
+                               m_BestFitParameters[i].second[j]);
     }
 
     // b. Calculate
-    calculateD2TOFFunction(mFunction, domain, values, Y, E);
+    calculateD2TOFFunction(m_Function, domain, values, Y, E);
 
     vector<double> vec_n;
-    calculateThermalNeutronSpecial(mFunction, X, vec_n);
+    calculateThermalNeutronSpecial(m_Function, X, vec_n);
 
     // c. Put the data to output workspace
-    MantidVec &newY = dataWS->dataY(3 * i + 1);
-    MantidVec &newD = dataWS->dataY(3 * i + 2);
-    MantidVec &newN = dataWS->dataY(3 * i + 3);
+    MantidVec &newY = m_dataWS->dataY(3 * i + 1);
+    MantidVec &newD = m_dataWS->dataY(3 * i + 2);
+    MantidVec &newN = m_dataWS->dataY(3 * i + 3);
     for (size_t j = 0; j < newY.size(); ++j) {
       newY[j] = values[j];
       newD[j] = Y[j] - values[j];
@@ -548,30 +551,30 @@ void RefinePowderInstrumentParameters::doParameterSpaceRandomWalk(
           << setw(20) << "Upper Boundary" << setw(20) << "Step Size" << endl;
   for (size_t i = 0; i < parnames.size(); ++i)
     inpinfo << setw(20) << parnames[i] << setw(20) <<
-  mFuncParameters[parnames[i]]
+  m_FuncParameters[parnames[i]]
             << setw(20) << lowerbounds[i]
             << setw(20) << upperbounds[i] << setw(20) <<  stepsizes[i] << endl;
   cout << inpinfo.str();
   ------------*/
 
-  // 1. Set up starting values, esp. to mFunction
+  // 1. Set up starting values, esp. to m_Function
   size_t numparameters = parnames.size();
   vector<double> paramvalues;
   for (size_t i = 0; i < numparameters; ++i) {
     string parname = parnames[i];
-    double parvalue = mFuncParameters[parname];
+    double parvalue = m_FuncParameters[parname];
     paramvalues.push_back(parvalue);
-    mFunction->setParameter(parname, parvalue);
+    m_Function->setParameter(parname, parvalue);
   }
 
   // Calcualte the function's initial statistic
-  mBestGSLChi2 = calculateFunctionStatistic(mFunction, dataWS, 0);
-  cout << "Function with starting values has Chi2 = " << mBestGSLChi2
+  m_BestGSLChi2 = calculateFunctionStatistic(m_Function, m_dataWS, 0);
+  cout << "Function with starting values has Chi2 = " << m_BestGSLChi2
        << " (GSL L.M) " << endl;
 
-  const MantidVec &X = dataWS->readX(0);
-  const MantidVec &rawY = dataWS->readY(0);
-  const MantidVec &rawE = dataWS->readE(0);
+  const MantidVec &X = m_dataWS->readX(0);
+  const MantidVec &rawY = m_dataWS->readY(0);
+  const MantidVec &rawE = m_dataWS->readE(0);
   FunctionDomain1DVector domain(X);
   FunctionValues values(domain);
 
@@ -623,7 +626,7 @@ void RefinePowderInstrumentParameters::doParameterSpaceRandomWalk(
 
   // 4. Do MC loops
   double curchi2 =
-      calculateD2TOFFunction(mFunction, domain, values, rawY, rawE);
+      calculateD2TOFFunction(m_Function, domain, values, rawY, rawE);
 
   g_log.notice() << "Monte Carlo Random Walk Starting Chi^2 = " << curchi2
                  << endl;
@@ -656,7 +659,7 @@ void RefinePowderInstrumentParameters::doParameterSpaceRandomWalk(
     }
 
     try {
-      mFunction->setParameter(parnames[paramindex], newvalue);
+      m_Function->setParameter(parnames[paramindex], newvalue);
     } catch (runtime_error &) {
       stringstream errss;
       errss << "New Value = " << newvalue
@@ -669,13 +672,13 @@ void RefinePowderInstrumentParameters::doParameterSpaceRandomWalk(
 
     // b. Calcualte the new
     double newchi2 =
-        calculateD2TOFFunction(mFunction, domain, values, rawY, rawE);
+        calculateD2TOFFunction(m_Function, domain, values, rawY, rawE);
 
     // Optionally fit
     if (fit2) {
       // i.   Copy the parameters
       for (size_t i = 0; i < numparameters; ++i) {
-        double parvalue = mFunction->getParameter(i);
+        double parvalue = m_Function->getParameter(i);
         func4fit->setParameter(i, parvalue);
       }
 
@@ -688,8 +691,8 @@ void RefinePowderInstrumentParameters::doParameterSpaceRandomWalk(
         double homchi2 =
             calculateD2TOFFunction(func4fit, domain, values, rawY, rawE);
 
-        if (gslchi2 < mBestGSLChi2)
-          mBestGSLChi2 = gslchi2;
+        if (gslchi2 < m_BestGSLChi2)
+          m_BestGSLChi2 = gslchi2;
 
         // iv.  Archive
         vector<double> newparvalues;
@@ -697,15 +700,15 @@ void RefinePowderInstrumentParameters::doParameterSpaceRandomWalk(
           double parvalue = func4fit->getParameter(i);
           newparvalues.push_back(parvalue);
         }
-        mBestFitParameters.push_back(make_pair(homchi2, newparvalues));
-        mBestFitChi2s.push_back(make_pair(homchi2, gslchi2));
+        m_BestFitParameters.push_back(make_pair(homchi2, newparvalues));
+        m_BestFitChi2s.push_back(make_pair(homchi2, gslchi2));
 
         // v.  Sort and keep in size
-        sort(mBestFitParameters.begin(), mBestFitParameters.end());
-        sort(mBestFitChi2s.begin(), mBestFitChi2s.end());
-        if (mBestFitParameters.size() > mMaxNumberStoredParameters) {
-          mBestFitParameters.pop_back();
-          mBestFitChi2s.pop_back();
+        sort(m_BestFitParameters.begin(), m_BestFitParameters.end());
+        sort(m_BestFitChi2s.begin(), m_BestFitChi2s.end());
+        if (m_BestFitParameters.size() > m_MaxNumberStoredParameters) {
+          m_BestFitParameters.pop_back();
+          m_BestFitChi2s.pop_back();
         }
 
         // cout << "\tHomemade Chi^2 = " << homchi2 << endl;
@@ -752,12 +755,12 @@ void RefinePowderInstrumentParameters::doParameterSpaceRandomWalk(
 
       // ii.  Add the new values to vector
       vector<double> parametervalues = paramvalues;
-      mBestMCParameters.push_back(make_pair(newchi2, parametervalues));
+      m_BestMCParameters.push_back(make_pair(newchi2, parametervalues));
 
       // iii. Sort and delete the last if necessary
-      sort(mBestMCParameters.begin(), mBestMCParameters.end());
-      if (mBestMCParameters.size() > mMaxNumberStoredParameters)
-        mBestMCParameters.pop_back();
+      sort(m_BestMCParameters.begin(), m_BestMCParameters.end());
+      if (m_BestMCParameters.size() > m_MaxNumberStoredParameters)
+        m_BestMCParameters.pop_back();
 
       // iv.  Update chi2 and ...
       curchi2 = newchi2;
@@ -773,24 +776,24 @@ void RefinePowderInstrumentParameters::doParameterSpaceRandomWalk(
 
   // 3. Debug output
   stringstream mcresult;
-  mcresult << "Monte Carlo Result for " << mBestMCParameters.size()
+  mcresult << "Monte Carlo Result for " << m_BestMCParameters.size()
            << " Best Results" << endl;
   mcresult << "Number of acceptance = " << numacceptance << ", out of "
            << maxsteps << " MC steps."
            << "Accept ratio = "
            << static_cast<double>(numacceptance) / static_cast<double>(maxsteps)
            << endl;
-  mcresult << "Best " << mBestMCParameters.size()
+  mcresult << "Best " << m_BestMCParameters.size()
            << " Monte Carlo (no fit) results: " << endl;
-  for (size_t i = 0; i < mBestMCParameters.size(); ++i) {
-    mcresult << setw(3) << i << ":  Chi^2 = " << mBestMCParameters[i].first
+  for (size_t i = 0; i < m_BestMCParameters.size(); ++i) {
+    mcresult << setw(3) << i << ":  Chi^2 = " << m_BestMCParameters[i].first
              << endl;
   }
-  mcresult << "Best " << mBestMCParameters.size()
-           << " fitting results.  Best Chi^2 =  " << mBestGSLChi2 << endl;
-  for (size_t i = 0; i < mBestFitParameters.size(); ++i) {
-    mcresult << setw(3) << i << ":  Chi^2 = " << mBestFitParameters[i].first
-             << ", GSL Chi^2 = " << mBestFitChi2s[i].second << endl;
+  mcresult << "Best " << m_BestMCParameters.size()
+           << " fitting results.  Best Chi^2 =  " << m_BestGSLChi2 << endl;
+  for (size_t i = 0; i < m_BestFitParameters.size(); ++i) {
+    mcresult << setw(3) << i << ":  Chi^2 = " << m_BestFitParameters[i].first
+             << ", GSL Chi^2 = " << m_BestFitChi2s[i].second << endl;
   }
   g_log.notice() << mcresult.str();
 
@@ -809,7 +812,7 @@ void RefinePowderInstrumentParameters::getD2TOFFuncParamNames(
   d2toffunc.initialize();
   std::vector<std::string> funparamnames = d2toffunc.getParameterNames();
 
-  mFunction = boost::make_shared<ThermalNeutronDtoTOFFunction>(d2toffunc);
+  m_Function = boost::make_shared<ThermalNeutronDtoTOFFunction>(d2toffunc);
 
   // 3. Copy
   parnames = funparamnames;
@@ -824,14 +827,14 @@ double RefinePowderInstrumentParameters::calculateD2TOFFunction(
     const MantidVec &rawY, const MantidVec &rawE) {
   // 1. Check validity
   if (!func) {
-    throw std::runtime_error("mFunction has not been initialized!");
+    throw std::runtime_error("m_Function has not been initialized!");
   } else {
     /*
-    vector<string> parnames = mFunction->getParameterNames();
+    vector<string> parnames = m_Function->getParameterNames();
     for (size_t i = 0; i < parnames.size(); ++i)
     {
       cout << "DBx1125  " << parnames[i] << " = " <<
-    mFunction->getParameter(parnames[i]) << endl;
+    m_Function->getParameter(parnames[i]) << endl;
     }
     */
     ;
@@ -861,7 +864,7 @@ double RefinePowderInstrumentParameters::calculateD2TOFFunction(
 //------------------------------- Processing Inputs
 //----------------------------------------
 /** Genearte peaks from input workspace
-  * Peaks are stored in a map.  (HKL) is the key
+  * m_Peaks are stored in a map.  (HKL) is the key
   */
 void RefinePowderInstrumentParameters::genPeaksFromTable(
     DataObjects::TableWorkspace_sptr peakparamws) {
@@ -873,7 +876,7 @@ void RefinePowderInstrumentParameters::genPeaksFromTable(
         "Invalid input table workspace for peak parameters");
   }
 
-  mPeaks.clear();
+  m_Peaks.clear();
 
   // 2. Parse table workspace rows to generate peaks
   vector<string> colnames = peakparamws->getColumnNames();
@@ -940,12 +943,12 @@ void RefinePowderInstrumentParameters::genPeaksFromTable(
     hkl.push_back(k);
     hkl.push_back(l);
 
-    mPeaks.insert(std::make_pair(hkl, newpeakptr));
+    m_Peaks.insert(std::make_pair(hkl, newpeakptr));
 
-    mPeakErrors.insert(make_pair(hkl, chi2));
+    m_PeakErrors.insert(make_pair(hkl, chi2));
 
-    g_log.information() << "[GeneratePeaks] Peak " << ir << " HKL = [" << hkl[0]
-                        << ", " << hkl[1] << ", " << hkl[2]
+    g_log.information() << "[Generatem_Peaks] Peak " << ir << " HKL = ["
+                        << hkl[0] << ", " << hkl[1] << ", " << hkl[2]
                         << "], Input Center = " << setw(10) << setprecision(6)
                         << newpeak.centre() << endl;
 
@@ -1118,17 +1121,17 @@ hkl, double lattice)
 /** Calcualte value n for thermal neutron peak profile
   */
 void RefinePowderInstrumentParameters::calculateThermalNeutronSpecial(
-    IFunction_sptr mFunction, vector<double> vec_d, vector<double> &vec_n) {
-  if (mFunction->name().compare("ThermalNeutronDtoTOFFunction") != 0) {
-    g_log.warning() << "Function (" << mFunction->name()
+    IFunction_sptr m_Function, vector<double> vec_d, vector<double> &vec_n) {
+  if (m_Function->name().compare("ThermalNeutronDtoTOFFunction") != 0) {
+    g_log.warning() << "Function (" << m_Function->name()
                     << " is not ThermalNeutronDtoTOFFunction.  And it is not "
                        "required to calculate n." << endl;
     for (size_t i = 0; i < vec_d.size(); ++i)
       vec_n.push_back(0);
   }
 
-  double width = mFunction->getParameter("Width");
-  double tcross = mFunction->getParameter("Tcross");
+  double width = m_Function->getParameter("Width");
+  double tcross = m_Function->getParameter("Tcross");
 
   for (size_t i = 0; i < vec_d.size(); ++i) {
     double dh = vec_d[i];
@@ -1149,7 +1152,7 @@ void RefinePowderInstrumentParameters::calculateThermalNeutronSpecial(
 void RefinePowderInstrumentParameters::genPeakCentersWorkspace(
     bool montecarlo, size_t numbestfit) {
   // 1. Collect values in a vector for sorting
-  double lattice = mFuncParameters["LatticeConstant"];
+  double lattice = m_FuncParameters["LatticeConstant"];
   if (lattice < 1.0E-5) {
     std::stringstream errmsg;
     errmsg << "Input Lattice constant = " << lattice
@@ -1176,12 +1179,12 @@ void RefinePowderInstrumentParameters::genPeakCentersWorkspace(
 
   Geometry::UnitCell unitcell(lattice, lattice, lattice, 90.0, 90.0, 90.0);
 
-  for (peakiter = mPeaks.begin(); peakiter != mPeaks.end(); ++peakiter) {
+  for (peakiter = m_Peaks.begin(); peakiter != m_Peaks.end(); ++peakiter) {
     vector<int> hkl = peakiter->first;
     BackToBackExponential_sptr peak = peakiter->second;
 
     double sigma = peak->getParameter("S");
-    if (sigma < mMinSigma) {
+    if (sigma < m_MinSigma) {
       g_log.information() << "Peak (" << hkl[0] << ", " << hkl[1] << ", "
                           << hkl[2]
                           << ") has unphysically small Sigma = " << sigma
@@ -1222,18 +1225,18 @@ void RefinePowderInstrumentParameters::genPeakCentersWorkspace(
     nspec = 1 + 3;
   }
 
-  dataWS = boost::dynamic_pointer_cast<DataObjects::Workspace2D>(
+  m_dataWS = boost::dynamic_pointer_cast<DataObjects::Workspace2D>(
       API::WorkspaceFactory::Instance().create("Workspace2D", nspec, size,
                                                size));
-  dataWS->getAxis(0)->setUnit("dSpacing");
+  m_dataWS->getAxis(0)->setUnit("dSpacing");
 
   // 4. Put data to output workspace
   for (size_t i = 0; i < peakcenters.size(); ++i) {
     for (size_t j = 0; j < nspec; ++j) {
-      dataWS->dataX(j)[i] = peakcenters[i].first;
+      m_dataWS->dataX(j)[i] = peakcenters[i].first;
     }
-    dataWS->dataY(0)[i] = peakcenters[i].second.first;
-    dataWS->dataE(0)[i] = peakcenters[i].second.second;
+    m_dataWS->dataY(0)[i] = peakcenters[i].second.first;
+    m_dataWS->dataE(0)[i] = peakcenters[i].second.second;
   }
 
   return;
@@ -1250,18 +1253,18 @@ RefinePowderInstrumentParameters::genMCResultTable() {
 
   tablews->addColumn("double", "Chi2");
   tablews->addColumn("double", "GSLChi2");
-  for (size_t i = 0; i < mPeakFunctionParameterNames.size(); ++i) {
-    tablews->addColumn("double", mPeakFunctionParameterNames[i]);
+  for (size_t i = 0; i < m_PeakFunctionParameterNames.size(); ++i) {
+    tablews->addColumn("double", m_PeakFunctionParameterNames[i]);
   }
 
   // 2. Put values in
-  for (size_t ib = 0; ib < mBestFitParameters.size(); ++ib) {
+  for (size_t ib = 0; ib < m_BestFitParameters.size(); ++ib) {
     TableRow newrow = tablews->appendRow();
-    double chi2 = mBestFitParameters[ib].first;
-    double gslchi2 = mBestFitChi2s[ib].second;
+    double chi2 = m_BestFitParameters[ib].first;
+    double gslchi2 = m_BestFitChi2s[ib].second;
     newrow << chi2 << gslchi2;
-    for (size_t ip = 0; ip < mPeakFunctionParameterNames.size(); ++ip) {
-      double tempdbl = mBestFitParameters[ib].second[ip];
+    for (size_t ip = 0; ip < m_PeakFunctionParameterNames.size(); ++ip) {
+      double tempdbl = m_BestFitParameters[ib].second[ip];
       newrow << tempdbl;
     }
   } // ENDFOR 1 Best Answer
@@ -1290,7 +1293,7 @@ RefinePowderInstrumentParameters::genOutputInstrumentParameterTable() {
 
   std::map<std::string, double>::iterator pariter;
 
-  for (pariter = mFuncParameters.begin(); pariter != mFuncParameters.end();
+  for (pariter = m_FuncParameters.begin(); pariter != m_FuncParameters.end();
        ++pariter) {
     API::TableRow newrow = newtablews->appendRow();
     std::string parname = pariter->first;
diff --git a/Framework/CurveFitting/src/GSLVector.cpp b/Framework/CurveFitting/src/GSLVector.cpp
index 6c7c341cf7d4f0f9f158ba91e7ebffe771a3cce0..cdbc2a12db0e7f571b5a8703754af69f1805cfd1 100644
--- a/Framework/CurveFitting/src/GSLVector.cpp
+++ b/Framework/CurveFitting/src/GSLVector.cpp
@@ -157,10 +157,12 @@ double GSLVector::dot(const GSLVector &v) const {
 
 /// The << operator.
 std::ostream &operator<<(std::ostream &ostr, const GSLVector &v) {
+  std::ios::fmtflags fflags(ostr.flags());
   ostr << std::scientific << std::setprecision(6);
   for (size_t j = 0; j < v.size(); ++j) {
     ostr << std::setw(13) << v[j] << ' ';
   }
+  ostr.flags(fflags);
   return ostr;
 }
 
diff --git a/Framework/DataHandling/src/SaveDiffCal.cpp b/Framework/DataHandling/src/SaveDiffCal.cpp
index 66259ba0ad274d6856f16180cc48240a99e183ca..96c2cbe07747c32a9b817a67505126fa137752eb 100644
--- a/Framework/DataHandling/src/SaveDiffCal.cpp
+++ b/Framework/DataHandling/src/SaveDiffCal.cpp
@@ -30,7 +30,8 @@ DECLARE_ALGORITHM(SaveDiffCal)
 //----------------------------------------------------------------------------------------------
 /** Constructor
  */
-SaveDiffCal::SaveDiffCal() {}
+SaveDiffCal::SaveDiffCal()
+    : m_numValues(0), m_calibrationWS(), m_detidToIndex() {}
 
 //----------------------------------------------------------------------------------------------
 /** Destructor
diff --git a/Framework/DataHandling/src/SaveGSS.cpp b/Framework/DataHandling/src/SaveGSS.cpp
index 460f326f800f6ccb0538b63aa49f9b59740bf633..3eaa53e20d4f04437f076959ffe3e940e1c2f0d8 100644
--- a/Framework/DataHandling/src/SaveGSS.cpp
+++ b/Framework/DataHandling/src/SaveGSS.cpp
@@ -410,6 +410,7 @@ void writeLogValue(std::ostream &os, const Run &runinfo,
 void SaveGSS::writeHeaders(const std::string &format, std::stringstream &os,
                            double primaryflightpath) const {
   const Run &runinfo = inputWS->run();
+  std::ios::fmtflags fflags(os.flags());
 
   // Run number
   if (format.compare(SLOG) == 0) {
@@ -483,6 +484,8 @@ void SaveGSS::writeHeaders(const std::string &format, std::stringstream &os,
     os << "\n";
   }
 
+  os.flags(fflags);
+
   return;
 }
 
@@ -491,10 +494,12 @@ void SaveGSS::writeHeaders(const std::string &format, std::stringstream &os,
   */
 inline void writeBankLine(std::stringstream &out, const std::string &bintype,
                           const int banknum, const size_t datasize) {
+  std::ios::fmtflags fflags(out.flags());
   out << "BANK " << std::fixed << std::setprecision(0)
       << banknum // First bank should be 1 for GSAS; this can be changed
       << std::fixed << " " << datasize << std::fixed << " " << datasize
       << std::fixed << " " << bintype;
+  out.flags(fflags);
 }
 
 //----------------------------------------------------------------------------------------------
diff --git a/Framework/DataObjects/inc/MantidDataObjects/CalculateReflectometryQxQz.h b/Framework/DataObjects/inc/MantidDataObjects/CalculateReflectometryQxQz.h
index 2656b0085f6924d57618e626b151cacf0d9d1508..7256f47e3bbb7c5b3a8a1936b742f8c057749b9f 100644
--- a/Framework/DataObjects/inc/MantidDataObjects/CalculateReflectometryQxQz.h
+++ b/Framework/DataObjects/inc/MantidDataObjects/CalculateReflectometryQxQz.h
@@ -22,7 +22,8 @@ public:
   /**
    Constructor
    */
-  CalculateReflectometryQxQz() : m_dirQx(0.0), m_dirQz(0.0) {}
+  CalculateReflectometryQxQz()
+      : m_cos_theta_i(0.0), m_sin_theta_i(0.0), m_dirQx(0.0), m_dirQz(0.0) {}
 
   /**
    Setter for the incident theta value require for the calculation. Internally
diff --git a/Framework/DataObjects/inc/MantidDataObjects/MDGridBox.tcc b/Framework/DataObjects/inc/MantidDataObjects/MDGridBox.tcc
index d03eb54542a77ee0bdd2b9cd5f04adcf3020215a..4de121711232aa6c6a24fd477c7118097ca62778 100644
--- a/Framework/DataObjects/inc/MantidDataObjects/MDGridBox.tcc
+++ b/Framework/DataObjects/inc/MantidDataObjects/MDGridBox.tcc
@@ -40,10 +40,10 @@ namespace DataObjects {
  */
 TMDE(MDGridBox)::MDGridBox(
     BoxController *const bc, const uint32_t depth,
-    const std::vector<
-        Mantid::Geometry::MDDimensionExtents<coord_t>> &extentsVector)
-    : MDBoxBase<MDE, nd>(bc, depth, UNDEF_SIZET, extentsVector),
-      numBoxes(0), m_Children(), diagonalSquared(0.f), nPoints(0) {
+    const std::vector<Mantid::Geometry::MDDimensionExtents<coord_t>> &
+        extentsVector)
+    : MDBoxBase<MDE, nd>(bc, depth, UNDEF_SIZET, extentsVector), numBoxes(0),
+      m_Children(), diagonalSquared(0.f), nPoints(0) {
   initGridBox();
 }
 
@@ -55,8 +55,8 @@ TMDE(MDGridBox)::MDGridBox(
 */
 TMDE(MDGridBox)::MDGridBox(
     boost::shared_ptr<API::BoxController> &bc, const uint32_t depth,
-    const std::vector<
-        Mantid::Geometry::MDDimensionExtents<coord_t>> &extentsVector)
+    const std::vector<Mantid::Geometry::MDDimensionExtents<coord_t>> &
+        extentsVector)
     : MDBoxBase<MDE, nd>(bc.get(), depth, UNDEF_SIZET, extentsVector),
       numBoxes(0), m_Children(), diagonalSquared(0.f), nPoints(0) {
   initGridBox();
@@ -68,17 +68,16 @@ template <typename MDE, size_t nd> size_t MDGridBox<MDE, nd>::initGridBox() {
         "MDGridBox::ctor(): No BoxController specified in box.");
 
   // How many is it split?
-  // If we are at the top level and we have a specific top level split, then set it.
-  boost::optional<std::vector<size_t>> splitTopInto = this->m_BoxController->getSplitTopInto();
-  if (this->getDepth() == 0 && splitTopInto)
-  {
+  // If we are at the top level and we have a specific top level split, then set
+  // it.
+  boost::optional<std::vector<size_t>> splitTopInto =
+      this->m_BoxController->getSplitTopInto();
+  if (this->getDepth() == 0 && splitTopInto) {
     for (size_t d = 0; d < nd; d++)
       split[d] = splitTopInto.get()[d];
-  }
-  else
-  {
-   for (size_t d = 0; d < nd; d++)
-    split[d] = this->m_BoxController->getSplitInto(d);
+  } else {
+    for (size_t d = 0; d < nd; d++)
+      split[d] = this->m_BoxController->getSplitInto(d);
   }
 
   // Compute sizes etc.
@@ -94,10 +93,9 @@ template <typename MDE, size_t nd> size_t MDGridBox<MDE, nd>::initGridBox() {
  * @param box :: MDBox containing the events to split
  */
 TMDE(MDGridBox)::MDGridBox(MDBox<MDE, nd> *box)
-    : MDBoxBase<MDE, nd>(*box, box->getBoxController()), split(),
-      splitCumul(), m_SubBoxSize(), numBoxes(0), m_Children(),
-      diagonalSquared(0.f), nPoints(0)
-{
+    : MDBoxBase<MDE, nd>(*box, box->getBoxController()), split(), splitCumul(),
+      m_SubBoxSize(), numBoxes(0), m_Children(), diagonalSquared(0.f),
+      nPoints(0) {
   size_t totalSize = initGridBox();
 
   double ChildVol(1);
@@ -188,10 +186,10 @@ void MDGridBox<MDE, nd>::fillBoxShell(const size_t tot,
  */
 TMDE(MDGridBox)::MDGridBox(const MDGridBox<MDE, nd> &other,
                            Mantid::API::BoxController *const otherBC)
-    : MDBoxBase<MDE, nd>(other, otherBC), numBoxes(other.numBoxes), m_Children(),
-      diagonalSquared(other.diagonalSquared), nPoints(other.nPoints) {
-  for (size_t d = 0; d < nd; d++) 
-  {
+    : MDBoxBase<MDE, nd>(other, otherBC), numBoxes(other.numBoxes),
+      m_Children(), diagonalSquared(other.diagonalSquared),
+      nPoints(other.nPoints) {
+  for (size_t d = 0; d < nd; d++) {
     split[d] = other.split[d];
     splitCumul[d] = other.splitCumul[d];
     m_SubBoxSize[d] = other.m_SubBoxSize[d];
@@ -415,7 +413,7 @@ TMDE(std::vector<MDE> *MDGridBox)::getEventsCopy() {
  */
 TMDE(void MDGridBox)::getBoxes(std::vector<API::IMDNode *> &outBoxes,
                                size_t maxDepth, bool leafOnly) {
- //Add this box, unless we only want the leaves
+  // Add this box, unless we only want the leaves
   if (!leafOnly)
     outBoxes.push_back(this);
 
@@ -1465,8 +1463,9 @@ TMDE(void MDGridBox)::integrateCylinder(
       coord_t out[nd];
       radiusTransform.apply(boxCenter, out);
       if (out[0] < std::sqrt(diagonalSquared * 0.72 + radius * radius) &&
-          std::fabs(out[1]) <
-              std::sqrt(diagonalSquared * 0.72 + 0.25 * length * length)) {
+          (nd >= 1 &&
+           std::fabs(out[1]) <
+               std::sqrt(diagonalSquared * 0.72 + 0.25 * length * length))) {
         // If the center is closer than the size of the box, then it MIGHT be
         // touching.
         // (We multiply by 0.72 (about sqrt(2)) to look for half the diagonal).
diff --git a/Framework/DataObjects/src/PeakColumn.cpp b/Framework/DataObjects/src/PeakColumn.cpp
index b3d7e129cc927636043721605c3517a80c4892a8..f8ffb4af0964c3be9a10fbfb6884363a31dc4dd4 100644
--- a/Framework/DataObjects/src/PeakColumn.cpp
+++ b/Framework/DataObjects/src/PeakColumn.cpp
@@ -134,6 +134,7 @@ const std::type_info &PeakColumn::get_pointer_type_info() const {
 void PeakColumn::print(size_t index, std::ostream &s) const {
   Peak &peak = m_peaks[index];
 
+  std::ios::fmtflags fflags(s.flags());
   if (m_name == "RunNumber")
     s << peak.getRunNumber();
   else if (m_name == "DetID")
@@ -152,6 +153,7 @@ void PeakColumn::print(size_t index, std::ostream &s) const {
     s << std::fixed << std::setprecision(m_hklPrec) << peak.getL();
   } else
     s << peak.getValueByColName(m_name);
+  s.flags(fflags);
 }
 
 //-------------------------------------------------------------------------------------
diff --git a/Framework/Geometry/src/Crystal/ScalarUtils.cpp b/Framework/Geometry/src/Crystal/ScalarUtils.cpp
index 096cbabf474a832b4b82a10cd92da237707671aa..e92b977edef531ba35d5a1092e8df1dc1ffe07e4 100644
--- a/Framework/Geometry/src/Crystal/ScalarUtils.cpp
+++ b/Framework/Geometry/src/Crystal/ScalarUtils.cpp
@@ -229,7 +229,7 @@ ConventionalCell ScalarUtils::GetCellForForm(const DblMatrix &UB,
   if (allowPermutations) {
     double angle_tolerance = 2.0;
     double length_factor = 1.05;
-    UB_list = GetRelatedUBs(UB, angle_tolerance, length_factor);
+    UB_list = GetRelatedUBs(UB, length_factor, angle_tolerance);
   } else {
     // Get exact form requested and not permutations
     UB_list.push_back(UB);
diff --git a/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp b/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp
index cdc50169d55ad5ab98597068d3a5a4ced1b04ddb..7451386f8b8db60e5b313c9fbb60b6623ff0cae6 100644
--- a/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp
+++ b/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp
@@ -1554,7 +1554,15 @@ void InstrumentDefinitionParser::populateIdList(Poco::XML::Element *pE,
             increment = atoi((pIDElem->getAttribute("step")).c_str());
 
           // check the start end and increment values are sensible
-          if (((endID - startID) / increment) < 0) {
+          if (0 == increment) {
+            std::stringstream ss;
+            ss << "The step element cannot be zero, found step: " << increment;
+
+            throw Kernel::Exception::InstrumentDefinitionError(ss.str(),
+                                                               filename);
+          }
+          int numSteps = (endID - startID) / increment;
+          if (numSteps < 0) {
             std::stringstream ss;
             ss << "The start, end, and step elements do not allow a single id "
                   "in the idlist entry - ";
@@ -1565,7 +1573,7 @@ void InstrumentDefinitionParser::populateIdList(Poco::XML::Element *pE,
                                                                filename);
           }
 
-          idList.vec.reserve((endID - startID) / increment);
+          idList.vec.reserve(numSteps);
           for (int i = startID; i != endID + increment; i += increment) {
             idList.vec.push_back(i);
           }
diff --git a/Framework/Geometry/src/Math/Acomp.cpp b/Framework/Geometry/src/Math/Acomp.cpp
index 0788103182bd08ed8d4202180f43ed171f722ee3..75c5fb5fe2be6d8d76bc081899ffbf8b4e10774a 100644
--- a/Framework/Geometry/src/Math/Acomp.cpp
+++ b/Framework/Geometry/src/Math/Acomp.cpp
@@ -366,7 +366,8 @@ Assumes that the component is sorted and inserts appropiately.
     for (acp = AX.Comp.begin(); acp != AX.Comp.end(); ++acp) {
       std::vector<Acomp>::iterator cpt;
       cpt = std::lower_bound(Comp.begin(), Comp.end(), *acp);
-      if (cpt == Comp.end() || *cpt != *aup) // Only insert if new
+      if (cpt == Comp.end() ||
+          (AX.Units.end() != aup && *cpt != *aup)) // Only insert if new
         Comp.insert(cpt, *acp);
     }
     return;
@@ -981,6 +982,9 @@ It is set on exit (to the EPI)
           break;
       }
 
+      if (PIactive.end() == px)
+        continue;
+
       EPI.push_back(PIform[*px]);
       // remove all minterm that the EPI covered
       for (ddx = DNFactive.begin(); ddx != DNFactive.end(); ++ddx)
diff --git a/Framework/ICat/src/GSoap/stdsoap2.cpp b/Framework/ICat/src/GSoap/stdsoap2.cpp
index ec26daa1e2e5e4ba9c1137565e6c2f1d5d763e28..7a966fb7a437dd7c1b35655b223446dc0506e1f8 100644
--- a/Framework/ICat/src/GSoap/stdsoap2.cpp
+++ b/Framework/ICat/src/GSoap/stdsoap2.cpp
@@ -2386,7 +2386,7 @@ int SOAP_FMAC2 soap_resolve(struct soap *soap) {
                                         "location=%p level=%u,%u id='%s'\n",
                                 ip->type, p, ip->level, fp->level, ip->id));
             while (ip->level < k) {
-              void **q = (void **)soap_malloc(soap, sizeof(q));
+              void **q = (void **)soap_malloc(soap, sizeof(*q));
               if (!q)
                 return soap->error;
               *q = p;
@@ -8188,9 +8188,11 @@ void *SOAP_FMAC2 soap_id_lookup(struct soap *soap, const char *id, void **p,
       void *s, **r = &ip->link;
       q = (void **)ip->link;
       while (q) {
-        *r = (void *)soap_malloc(soap, sizeof(void *));
-        if (!*r)
+        void **tmp = (void **)soap_malloc(soap, sizeof(void *));
+        if (!tmp)
           return NULL;
+        *r = (void *)tmp;
+
         s = *q;
         *q = *r;
         r = (void **)*r;
@@ -10040,7 +10042,7 @@ int SOAP_FMAC2 soap_element_start_end_out(struct soap *soap, const char *tag) {
   if (soap->mode & SOAP_XML_CANONICAL) {
     struct soap_nlist *np;
     for (tp = soap->attributes; tp; tp = tp->next) {
-      if (tp->visible && tp->name)
+      if (tp->visible && tp->name[0])
         soap_utilize_ns(soap, tp->name);
     }
     for (np = soap->nlist; np; np = np->next) {
@@ -11048,7 +11050,7 @@ int SOAP_FMAC2 soap_peek_element(struct soap *soap) {
           soap->arraySize[sizeof(soap->arrayType) - 1] = '\0';
           soap->arrayType[sizeof(soap->arrayType) - 1] = '\0';
         } else if (!soap_match_tag(soap, tp->name, "SOAP-ENC:offset"))
-          strncpy(soap->arrayOffset, tp->value, sizeof(soap->arrayOffset));
+          strncpy(soap->arrayOffset, tp->value, sizeof(soap->arrayOffset) - 1);
         else if (!soap_match_tag(soap, tp->name, "SOAP-ENC:position"))
           soap->position = soap_getposition(tp->value, soap->positions);
         else if (!soap_match_tag(soap, tp->name, "SOAP-ENC:root"))
diff --git a/Framework/Kernel/src/DateValidator.cpp b/Framework/Kernel/src/DateValidator.cpp
index 2ff99628903731dcf38e75d971c67852a1f8c550..5362fb247e217211a577736781841c1057ccacfe 100644
--- a/Framework/Kernel/src/DateValidator.cpp
+++ b/Framework/Kernel/src/DateValidator.cpp
@@ -28,6 +28,9 @@ struct tm getTimeValue(const std::string &sDate, std::string &error) {
   timeinfo.tm_wday = 0;
   timeinfo.tm_yday = 0;
   timeinfo.tm_isdst = -1;
+#ifndef _WIN32
+  timeinfo.tm_gmtoff = 0;
+#endif
 
   std::basic_string<char>::size_type index, off = 0;
   int day, month, year;
diff --git a/Framework/LiveData/src/ADARA/ADARAParser.cpp b/Framework/LiveData/src/ADARA/ADARAParser.cpp
index 8fe1652ecb61c1985e1538b85869fc1c8d029b3f..1fe48e4b00b4755d3c0e3a73e5c25c8caf289e86 100644
--- a/Framework/LiveData/src/ADARA/ADARAParser.cpp
+++ b/Framework/LiveData/src/ADARA/ADARAParser.cpp
@@ -9,7 +9,7 @@ using namespace ADARA;
 
 Parser::Parser(unsigned int initial_buffer_size, unsigned int max_pkt_size)
     : m_size(initial_buffer_size), m_max_size(max_pkt_size), m_len(0),
-      m_restart_offset(0), m_oversize_len(0) {
+      m_restart_offset(0), m_oversize_len(0), m_oversize_offset(0) {
   m_buffer = new uint8_t[initial_buffer_size];
   m_discarded_packets.clear();
 }
diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/Integrate3DEvents.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/Integrate3DEvents.h
index 2d2b6398fcbc13ef8930008df57da0b01eb015e7..d5a3c71fc66da3866275f0cd6a87bf0c4b5050e5 100644
--- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/Integrate3DEvents.h
+++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/Integrate3DEvents.h
@@ -127,10 +127,10 @@ private:
   double detectorQ(std::vector<Kernel::V3D> E1Vec,
                    const Mantid::Kernel::V3D QLabFrame, std::vector<double> &r);
   // Private data members
-  PeakQMap peak_qs;         // hashtable with peak Q-vectors
-  EventListMap event_lists; // hashtable with lists of events for each peak
-  Kernel::DblMatrix UBinv;  // matrix mapping from Q to h,k,l
-  double radius;            // size of sphere to use for events around a peak
+  PeakQMap m_peak_qs;         // hashtable with peak Q-vectors
+  EventListMap m_event_lists; // hashtable with lists of events for each peak
+  Kernel::DblMatrix m_UBinv;  // matrix mapping from Q to h,k,l
+  double m_radius;            // size of sphere to use for events around a peak
 };
 
 } // namespace MDAlgorithms
diff --git a/Framework/MDAlgorithms/src/ConvertCWSDExpToMomentum.cpp b/Framework/MDAlgorithms/src/ConvertCWSDExpToMomentum.cpp
index 67c0bd24fdb7f2e62820baa3acc1a485a48fe3c2..5bb6cc662e53abe742bfb355143983a89573ce5d 100644
--- a/Framework/MDAlgorithms/src/ConvertCWSDExpToMomentum.cpp
+++ b/Framework/MDAlgorithms/src/ConvertCWSDExpToMomentum.cpp
@@ -24,7 +24,8 @@ DECLARE_ALGORITHM(ConvertCWSDExpToMomentum)
 /** Constructor
  */
 ConvertCWSDExpToMomentum::ConvertCWSDExpToMomentum()
-    : m_iColFilename(2), m_iColStartDetID(3), m_setQRange(true) {}
+    : m_iColFilename(2), m_iColStartDetID(3), m_setQRange(true),
+      m_isBaseName(false) {}
 
 //----------------------------------------------------------------------------------------------
 /** Destructor
@@ -201,13 +202,15 @@ void ConvertCWSDExpToMomentum::addMDEvents(bool usevirtual) {
   // Check whether to add / or \ to m_dataDir
   std::string sep("");
   if (m_dataDir.size() > 0) {
-    // Determine system
-    bool isWindows(false);
+// Determine system
 #if _WIN64
-    isWindows = true;
-#elif _WIND32
-    isWindows = true;
+    const bool isWindows = true;
+#elif _WIN32
+    const bool isWindows = true;
+#else
+    const bool isWindows = false;
 #endif
+
     if (isWindows && *m_dataDir.rbegin() != '\\') {
       sep = "\\";
     } else if (!isWindows && *m_dataDir.rbegin() != '/')
diff --git a/Framework/MDAlgorithms/src/ImportMDEventWorkspace.cpp b/Framework/MDAlgorithms/src/ImportMDEventWorkspace.cpp
index 9bb7c6d1a1723019e115ccda352ef3039a6dccee..8aab04ee8dbf02e05f695e30c90b2100fb472a3a 100644
--- a/Framework/MDAlgorithms/src/ImportMDEventWorkspace.cpp
+++ b/Framework/MDAlgorithms/src/ImportMDEventWorkspace.cpp
@@ -266,7 +266,13 @@ void ImportMDEventWorkspace::exec() {
       m_nDimensions + 4; // signal, error, run_no, detector_no
   m_IsFullDataObjects = (nActualColumns == columnsForFullEvents);
 
-  m_nDataObjects = posDiffMDEvent / nActualColumns;
+  if (0 == nActualColumns) {
+    m_nDataObjects = 0;
+    g_log.warning() << "The number of actual columns found in the file "
+                       "(exlcuding comments) is zero" << std::endl;
+  } else {
+    m_nDataObjects = posDiffMDEvent / nActualColumns;
+  }
 
   // Get the min and max extents in each dimension.
   std::vector<double> extentMins(m_nDimensions);
diff --git a/Framework/MDAlgorithms/src/Integrate3DEvents.cpp b/Framework/MDAlgorithms/src/Integrate3DEvents.cpp
index f3db57b5fd7b3652e27e4bf5187cbf8311c872e5..372e9b1ad95a59e2852b7522d4b4e3602fc6a41b 100644
--- a/Framework/MDAlgorithms/src/Integrate3DEvents.cpp
+++ b/Framework/MDAlgorithms/src/Integrate3DEvents.cpp
@@ -35,14 +35,14 @@ using Mantid::Kernel::V3D;
 Integrate3DEvents::Integrate3DEvents(
     std::vector<std::pair<double, V3D>> const &peak_q_list,
     DblMatrix const &UBinv, double radius) {
-  this->UBinv = UBinv;
-  this->radius = radius;
+  m_UBinv = UBinv;
+  m_radius = radius;
 
   int64_t hkl_key;
   for (size_t it = 0; it != peak_q_list.size(); ++it) {
     hkl_key = getHklKey(peak_q_list[it].second);
     if (hkl_key != 0) // only save if hkl != (0,0,0)
-      peak_qs[hkl_key] = peak_q_list[it].second;
+      m_peak_qs[hkl_key] = peak_q_list[it].second;
   }
 }
 
@@ -124,7 +124,12 @@ Integrate3DEvents::ellipseIntegrateEvents(
     return boost::make_shared<NoShape>();
   }
 
-  std::vector<std::pair<double, V3D>> &some_events = event_lists[hkl_key];
+  auto pos = m_event_lists.find(hkl_key);
+  if (m_event_lists.end() == pos)
+    return boost::make_shared<NoShape>();
+  ;
+
+  std::vector<std::pair<double, V3D>> &some_events = pos->second;
 
   if (some_events.size() < 3) // if there are not enough events to
   {                           // find covariance matrix, return
@@ -132,14 +137,14 @@ Integrate3DEvents::ellipseIntegrateEvents(
   }
 
   DblMatrix cov_matrix(3, 3);
-  makeCovarianceMatrix(some_events, cov_matrix, radius);
+  makeCovarianceMatrix(some_events, cov_matrix, m_radius);
 
   std::vector<V3D> eigen_vectors;
   getEigenVectors(cov_matrix, eigen_vectors);
 
   std::vector<double> sigmas;
   for (int i = 0; i < 3; i++) {
-    sigmas.push_back(stdDev(some_events, eigen_vectors[i], radius));
+    sigmas.push_back(stdDev(some_events, eigen_vectors[i], m_radius));
   }
 
   bool invalid_peak = false;
@@ -392,7 +397,7 @@ int64_t Integrate3DEvents::getHklKey2(V3D const &hkl) {
  *  @param q_vector  The q_vector to be mapped to h,k,l
  */
 int64_t Integrate3DEvents::getHklKey(V3D const &q_vector) {
-  V3D hkl = UBinv * q_vector;
+  V3D hkl = m_UBinv * q_vector;
   int h = boost::math::iround<double>(hkl[0]);
   int k = boost::math::iround<double>(hkl[1]);
   int l = boost::math::iround<double>(hkl[2]);
@@ -424,15 +429,15 @@ void Integrate3DEvents::addEvent(std::pair<double, V3D> event_Q,
   if (hkl_key == 0) // don't keep events associated with 0,0,0
     return;
 
-  auto peak_it = peak_qs.find(hkl_key);
-  if (peak_it != peak_qs.end()) {
+  auto peak_it = m_peak_qs.find(hkl_key);
+  if (peak_it != m_peak_qs.end()) {
     if (!peak_it->second.nullVector()) {
       if (hkl_integ)
-        event_Q.second = event_Q.second - UBinv * peak_it->second;
+        event_Q.second = event_Q.second - m_UBinv * peak_it->second;
       else
         event_Q.second = event_Q.second - peak_it->second;
-      if (event_Q.second.norm() < radius) {
-        event_lists[hkl_key].push_back(event_Q);
+      if (event_Q.second.norm() < m_radius) {
+        m_event_lists[hkl_key].push_back(event_Q);
       }
     }
   }
@@ -511,8 +516,8 @@ PeakShapeEllipsoid_const_sptr Integrate3DEvents::ellipseIntegrateEvents(
     // if necessary restrict the background ellipsoid
     // to lie within the specified sphere, and adjust
     // the other sizes, proportionally
-    if (r3 * max_sigma > radius) {
-      r3 = radius / max_sigma;
+    if (r3 * max_sigma > m_radius) {
+      r3 = m_radius / max_sigma;
       r1 = r3 * 0.79370053f; // This value for r1 and r2 makes the background
       r2 = r1;               // shell volume equal to the peak region volume.
     }
diff --git a/Framework/SINQ/src/PoldiUtilities/PoldiAutoCorrelationCore.cpp b/Framework/SINQ/src/PoldiUtilities/PoldiAutoCorrelationCore.cpp
index 4a3ec4167a2bcbb4b2ea8d71ff9529c35d134574..48b5317b0eacdd7fdf4cc32a6cb5af86b2223ca7 100644
--- a/Framework/SINQ/src/PoldiUtilities/PoldiAutoCorrelationCore.cpp
+++ b/Framework/SINQ/src/PoldiUtilities/PoldiAutoCorrelationCore.cpp
@@ -385,6 +385,18 @@ UncertainValue PoldiAutoCorrelationCore::getCMessAndCSigma(
   case 2: {
     int middleIndex = cleanIndex((locator.icmin + 1), m_timeBinCount);
 
+    if (middleIndex < 0) {
+      m_logger.warning() << "Inconsistency foun while calculating correlation "
+                            "intensity and error for d-value: "
+                         << boost::lexical_cast<std::string>(dValue)
+                         << ", with detector index: "
+                         << boost::lexical_cast<std::string>(index)
+                         << ", got middle index: "
+                         << boost::lexical_cast<std::string>(middleIndex)
+                         << ", ignoring it." << std::endl;
+      break;
+    }
+
     double counts = getCounts(locator.detectorElement, middleIndex);
     double normCounts = getNormCounts(locator.detectorElement, middleIndex);
 
diff --git a/Framework/SINQ/src/PoldiUtilities/PoldiResidualCorrelationCore.cpp b/Framework/SINQ/src/PoldiUtilities/PoldiResidualCorrelationCore.cpp
index 02f23178125755897c583659e66ec70e8ca6ed16..665b2f1eefa67af58661bb36d0e4c8d86b5c6904 100644
--- a/Framework/SINQ/src/PoldiUtilities/PoldiResidualCorrelationCore.cpp
+++ b/Framework/SINQ/src/PoldiUtilities/PoldiResidualCorrelationCore.cpp
@@ -99,6 +99,15 @@ void PoldiResidualCorrelationCore::distributeCorrelationCounts(
         case 2: {
           int middleIndex = cleanIndex((locator.icmin + 1), m_timeBinCount);
 
+          if (middleIndex < 0) {
+            m_logger.warning()
+                << "Inconsistency foun while calculating distribute "
+                   "correlation counts for d-value with index "
+                << boost::lexical_cast<std::string>(k) << ", got middle index: "
+                << boost::lexical_cast<std::string>(middleIndex)
+                << ", ignoring it." << std::endl;
+            break;
+          }
           addToCountData(locator.detectorElement, middleIndex, deltaForD);
         }
         case 1: {
diff --git a/MantidPlot/src/Graph.cpp b/MantidPlot/src/Graph.cpp
index db3b3e6fcd290c43819c2df94f5f38d021aee8a4..f147c078e4ad2bfb4bfa4d86e70023fb3ff7fd4c 100644
--- a/MantidPlot/src/Graph.cpp
+++ b/MantidPlot/src/Graph.cpp
@@ -1436,7 +1436,8 @@ void Graph::setAxisScale(int axis, double start, double end, int type, double st
           QwtScaleWidget *rightAxis = d_plot->axisWidget(QwtPlot::yRight);
           if(rightAxis)
           {
-            if (type == ScaleTransformation::Log10 && (start <= 0 || start == DBL_MAX))
+            //if (type == ScaleTransformation::Log10 && (start <= 0 || start == DBL_MAX))
+            if (type == GraphOptions::Log10 && (start <= 0 || start == DBL_MAX))
             {
               start = sp->getMinPositiveValue();
             }
diff --git a/MantidPlot/src/ImportASCIIDialog.cpp b/MantidPlot/src/ImportASCIIDialog.cpp
index 44c2ff0105b2c0636fe4a8fcebce9f9dbdcb0dcd..075910ef35fb89d929af75626a20ae8a6845b781 100644
--- a/MantidPlot/src/ImportASCIIDialog.cpp
+++ b/MantidPlot/src/ImportASCIIDialog.cpp
@@ -450,62 +450,67 @@ void ImportASCIIDialog::preview()
 
 void ImportASCIIDialog::previewTable()
 {
-	if (!d_preview_table)
-		return;
+  if (!d_preview_table)
+    return;
 
-	if (!d_preview_table->isVisible())
-		d_preview_table->show();
+  if (!d_preview_table->isVisible())
+    d_preview_table->show();
 
-	if (d_current_path.trimmed().isEmpty()){
-		d_preview_table->clear();
-		d_preview_table->resetHeader();
-        return;
-    }
+  if (d_current_path.trimmed().isEmpty()){
+    d_preview_table->clear();
+    d_preview_table->resetHeader();
+    return;
+  }
 
-	int importMode = d_import_mode->currentIndex();
-	if (importMode == NewTables)
-		importMode = Table::Overwrite;
-	else
-		importMode -= 2;
-
-	d_preview_table->resetHeader();
-	d_preview_table->importASCII(d_current_path, columnSeparator(), d_ignored_lines->value(),
-							d_rename_columns->isChecked(), d_strip_spaces->isChecked(),
-							d_simplify_spaces->isChecked(), d_import_comments->isChecked(),
-                            d_comment_string->text(), (Table::ImportMode)importMode, 
-                            boxEndLine->currentIndex(), d_preview_lines_box->value());
-
-	if (d_import_dec_separators->isChecked())
-		d_preview_table->updateDecimalSeparators(decimalSeparators());
-    if (!d_preview_table->isVisible())
-        d_preview_table->show();
+  int importMode = d_import_mode->currentIndex();
+  if (importMode == NewTables) {
+    importMode = (ImportASCIIDialog::ImportMode)Table::Overwrite;
+  } else {
+    importMode -= 2;
+  }
+
+  d_preview_table->resetHeader();
+  d_preview_table->importASCII(d_current_path, columnSeparator(), d_ignored_lines->value(),
+                               d_rename_columns->isChecked(), d_strip_spaces->isChecked(),
+                               d_simplify_spaces->isChecked(), d_import_comments->isChecked(),
+                               d_comment_string->text(), (Table::ImportMode)importMode,
+                               boxEndLine->currentIndex(), d_preview_lines_box->value());
+
+  if (d_import_dec_separators->isChecked())
+    d_preview_table->updateDecimalSeparators(decimalSeparators());
+
+  if (!d_preview_table->isVisible())
+    d_preview_table->show();
 }
 
-void ImportASCIIDialog::previewMatrix()
-{
-	if (!d_preview_matrix)
-		return;
+void ImportASCIIDialog::previewMatrix() {
+  if (!d_preview_matrix)
+    return;
 
-	if (d_current_path.trimmed().isEmpty()){
-		d_preview_matrix->clear();
-        return;
-    }
+  if (d_current_path.trimmed().isEmpty()) {
+    d_preview_matrix->clear();
+    return;
+  }
 
-	int importMode = d_import_mode->currentIndex();
-	if (importMode == NewMatrices)
-		importMode = Matrix::Overwrite;
-	else
-		importMode -= 2;
+  int importMode = d_import_mode->currentIndex();
+  if (importMode == NewMatrices) {
+    importMode = (ImportASCIIDialog::ImportMode)Matrix::Overwrite;
+  } else {
+    // Overwrite-2 => NewColumns (in both Matrix::importMode and
+    // ImportASCIIDialog::importMode)
+    importMode -= 2;
+  }
 
-	QLocale locale = d_preview_matrix->locale();
-	if(d_import_dec_separators->isChecked())
-		locale = decimalSeparators();
+  QLocale locale = d_preview_matrix->locale();
+  if (d_import_dec_separators->isChecked())
+    locale = decimalSeparators();
 
-	d_preview_matrix->importASCII(d_current_path, columnSeparator(), d_ignored_lines->value(),
-							d_strip_spaces->isChecked(), d_simplify_spaces->isChecked(),
-                            d_comment_string->text(), importMode, locale,
-                            boxEndLine->currentIndex(), d_preview_lines_box->value());
-	d_preview_matrix->resizeColumnsToContents();
+  d_preview_matrix->importASCII(
+      d_current_path, columnSeparator(), d_ignored_lines->value(),
+      d_strip_spaces->isChecked(), d_simplify_spaces->isChecked(),
+      d_comment_string->text(), importMode, locale, boxEndLine->currentIndex(),
+      d_preview_lines_box->value());
+  d_preview_matrix->resizeColumnsToContents();
 }
 
 void ImportASCIIDialog::changePreviewFile(const QString& path)
@@ -542,8 +547,8 @@ void ImportASCIIDialog::setNewWindowsOnly(bool on)
     if (on){
         d_import_mode->clear();
         d_import_mode->addItem(tr("New Table"));
-        d_import_mode->addItem(tr("New Matrice"));
-		d_import_mode->addItem(tr("New Workspace"));
+        d_import_mode->addItem(tr("New Matrix"));
+        d_import_mode->addItem(tr("New Workspace"));
     }
 
     d_preview_button->setChecked(false);
diff --git a/MantidPlot/src/importOPJ.cpp b/MantidPlot/src/importOPJ.cpp
index f5d393e96b4239a28a8c3f23f98e9eabfeca5a7d..458e67fe47debd7431cdd9268e58cb0edb4594b5 100644
--- a/MantidPlot/src/importOPJ.cpp
+++ b/MantidPlot/src/importOPJ.cpp
@@ -702,6 +702,8 @@ bool ImportOPJ::importGraphs(const OPJFile& opj)
 					break;
 				case 'F':
 					s=opj.functionIndex(data.right(data.length()-2).toStdString().c_str());
+                                        if (s<0)
+                                          break;
 					int type;
 					if(opj.functionType(s)==1)//Polar
 					{
diff --git a/MantidQt/CustomDialogs/inc/MantidQtCustomDialogs/GetNegMuMuonicXRDDialog.h b/MantidQt/CustomDialogs/inc/MantidQtCustomDialogs/GetNegMuMuonicXRDDialog.h
index 85fa109a4511bb3ef96de179827dc54d33baab32..4d375e8cdc124c9d04bf0274f849ee4f597b7a13 100644
--- a/MantidQt/CustomDialogs/inc/MantidQtCustomDialogs/GetNegMuMuonicXRDDialog.h
+++ b/MantidQt/CustomDialogs/inc/MantidQtCustomDialogs/GetNegMuMuonicXRDDialog.h
@@ -36,19 +36,20 @@ namespace CustomDialogs {
 class GetNegMuMuonicXRDDialog : public API::AlgorithmDialog {
   Q_OBJECT
 
-  public:
+public:
   /// Constructor
   GetNegMuMuonicXRDDialog(QWidget *parent = 0);
 
-  private:
+private:
   /// Periodic Table widget used for selection of elements property
-  PeriodicTableWidget *periodicTable;
+  PeriodicTableWidget *m_periodicTable;
   /// QLineEdit used for input of y-position property
-  QLineEdit *yPosition;
+  QLineEdit *m_yPosition;
   /// QLineEdit used for input of GroupWorkspaceSpace
-  QLineEdit *groupWorkspaceNameInput;
-  //Check box for showing or hiding the Legend for PeriodicTableWidget
-  QCheckBox *showLegendCheck;
+  QLineEdit *m_groupWorkspaceNameInput;
+  // Check box for showing or hiding the Legend for PeriodicTableWidget
+  QCheckBox *m_showLegendCheck;
+
   /// Validate that the input is not empty before running algorithm
   bool validateDialogInput(QString input);
   /** Enables a the buttons corresponding to the elements
@@ -56,15 +57,15 @@ class GetNegMuMuonicXRDDialog : public API::AlgorithmDialog {
   */
   void enableElementsForGetNegMuMuonicXRD();
 
-  private slots:
+private slots:
   /// When the "Run" button is clicked, the algorithm is executed with inputs
   void runClicked();
   void showLegend();
 
-  protected:
+protected:
   // create the initial layout
   void initLayout();
-  signals:
+signals:
   /// signal emitted when validateDialogInput passes
   void validInput();
 };
diff --git a/MantidQt/CustomDialogs/src/GetNegMuMuonicXRDDialog.cpp b/MantidQt/CustomDialogs/src/GetNegMuMuonicXRDDialog.cpp
index 963da0325e8764e67562bd8801154cbca51c2648..463fae15e31cc0b36834b70bb1dfbef1ecd0c5a8 100644
--- a/MantidQt/CustomDialogs/src/GetNegMuMuonicXRDDialog.cpp
+++ b/MantidQt/CustomDialogs/src/GetNegMuMuonicXRDDialog.cpp
@@ -7,7 +7,6 @@
 #include <QValidator>
 #include <QFormLayout>
 
-
 namespace MantidQt {
 namespace CustomDialogs {
 DECLARE_DIALOG(GetNegMuMuonicXRDDialog)
@@ -18,7 +17,8 @@ DECLARE_DIALOG(GetNegMuMuonicXRDDialog)
  */
 
 GetNegMuMuonicXRDDialog::GetNegMuMuonicXRDDialog(QWidget *parent)
-    : API::AlgorithmDialog(parent) {}
+    : API::AlgorithmDialog(parent), m_periodicTable(NULL), m_yPosition(NULL),
+      m_groupWorkspaceNameInput(NULL), m_showLegendCheck(NULL) {}
 
 /// Initialise the layout
 void GetNegMuMuonicXRDDialog::initLayout() {
@@ -26,18 +26,18 @@ void GetNegMuMuonicXRDDialog::initLayout() {
   this->setMaximumHeight(400);
   this->setMaximumWidth(675);
   // assign periodicTable member to a new periodicTable
-  periodicTable = new PeriodicTableWidget();
+  m_periodicTable = new PeriodicTableWidget();
 
-  // assign yPosition member to a new QLineEdit
-  yPosition = new QLineEdit();
-  //assign GroupWorkspaceName member to a new QLineEdit
-  groupWorkspaceNameInput = new QLineEdit();
+  // assign m_yPosition member to a new QLineEdit
+  m_yPosition = new QLineEdit();
+  // assign GroupWorkspaceName member to a new QLineEdit
+  m_groupWorkspaceNameInput = new QLineEdit();
   auto *groupWsInputLabel = new QLabel("OutputWorkspace");
-  groupWorkspaceNameInput->setMaximumWidth(250);
+  m_groupWorkspaceNameInput->setMaximumWidth(250);
   // Disable all buttons on the periodicTable
   // as we only have a select few that need to be
   // enabled.
-  periodicTable->disableAllElementButtons();
+  m_periodicTable->disableAllElementButtons();
 
   /*Elements Enabled Correspond to those for which we
   * have data for in the dictionary found in
@@ -51,44 +51,44 @@ void GetNegMuMuonicXRDDialog::initLayout() {
   // run button for executing the algorithm
   auto *runButton = new QPushButton("Run");
 
-  // label for the QLineEdit for yPosition property
-  auto *yPositionLabel = new QLabel("Y Position");
+  // label for the QLineEdit for m_yPosition property
+  auto *m_yPositionLabel = new QLabel("Y Position");
 
-  /*validator allows only numeric input for yPosition
+  /*validator allows only numeric input for m_yPosition
    *this helps with validating the input.
    *Does not detect empty string as invalid input.
    */
-  auto yPositionNumericValidator = new QDoubleValidator();
+  auto m_yPositionNumericValidator = new QDoubleValidator();
 
   // YPosition LineEdit Attributes
-  yPosition->setMaximumWidth(250);
-  yPosition->setPlaceholderText("-0.01");
-  yPosition->setValidator(yPositionNumericValidator);
+  m_yPosition->setMaximumWidth(250);
+  m_yPosition->setPlaceholderText("-0.01");
+  m_yPosition->setValidator(m_yPositionNumericValidator);
 
   // Run Button Attributes and signal/slot assignment
   runButton->setMaximumWidth(100);
   connect(runButton, SIGNAL(clicked()), this, SLOT(runClicked()));
   connect(this, SIGNAL(validInput()), this, SLOT(accept()));
 
-  //Show Legend button attributes and signal/slot asssignment
-  showLegendCheck = new QCheckBox("Show Legend");
-  connect(showLegendCheck, SIGNAL(clicked()), this, SLOT(showLegend()));
+  // Show Legend button attributes and signal/slot asssignment
+  m_showLegendCheck = new QCheckBox("Show Legend");
+  connect(m_showLegendCheck, SIGNAL(clicked()), this, SLOT(showLegend()));
   // Adding Widgets to Layout
-  main_layout->addWidget(periodicTable);
-  main_layout->addWidget(showLegendCheck);
-  main_layout->addWidget(yPositionLabel);
-  main_layout->addWidget(yPosition);
+  main_layout->addWidget(m_periodicTable);
+  main_layout->addWidget(m_showLegendCheck);
+  main_layout->addWidget(m_yPositionLabel);
+  main_layout->addWidget(m_yPosition);
   main_layout->addWidget(groupWsInputLabel);
-  main_layout->addWidget(groupWorkspaceNameInput);
+  main_layout->addWidget(m_groupWorkspaceNameInput);
   main_layout->addWidget(runButton);
 }
 
 /**
  *
  */
-void GetNegMuMuonicXRDDialog::showLegend(){
-    bool checked = showLegendCheck->isChecked();
-    periodicTable->showGroupLegend(checked);
+void GetNegMuMuonicXRDDialog::showLegend() {
+  bool checked = m_showLegendCheck->isChecked();
+  m_periodicTable->showGroupLegend(checked);
 }
 
 /**
@@ -102,13 +102,13 @@ void GetNegMuMuonicXRDDialog::enableElementsForGetNegMuMuonicXRD() {
    * for the algorithm, and the button for that element can be enabled
    * the same as the elements are below.
    */
-  periodicTable->enableButtonByName("Au");
-  periodicTable->enableButtonByName("Ag");
-  periodicTable->enableButtonByName("Cu");
-  periodicTable->enableButtonByName("Zn");
-  periodicTable->enableButtonByName("Pb");
-  periodicTable->enableButtonByName("As");
-  periodicTable->enableButtonByName("Sn");
+  m_periodicTable->enableButtonByName("Au");
+  m_periodicTable->enableButtonByName("Ag");
+  m_periodicTable->enableButtonByName("Cu");
+  m_periodicTable->enableButtonByName("Zn");
+  m_periodicTable->enableButtonByName("Pb");
+  m_periodicTable->enableButtonByName("As");
+  m_periodicTable->enableButtonByName("Sn");
 }
 
 /**
@@ -128,7 +128,7 @@ bool GetNegMuMuonicXRDDialog::validateDialogInput(QString input) {
 */
 void GetNegMuMuonicXRDDialog::runClicked() {
   // getting a list of strings of elements selected from periodicTableWidget
-  QString elementsSelectedStr = periodicTable->getAllCheckedElementsStr();
+  QString elementsSelectedStr = m_periodicTable->getAllCheckedElementsStr();
   // if no elements are selected from the PeriodicTableWidget, a pop-up appears
   // to the user.
   if (!validateDialogInput(elementsSelectedStr)) {
@@ -141,15 +141,16 @@ void GetNegMuMuonicXRDDialog::runClicked() {
   // signal.
   if (validateDialogInput(elementsSelectedStr)) {
     storePropertyValue("Elements", elementsSelectedStr);
-    if (validateDialogInput(yPosition->text())) {
-      storePropertyValue("YAxisPosition", yPosition->text());
+    if (validateDialogInput(m_yPosition->text())) {
+      storePropertyValue("YAxisPosition", m_yPosition->text());
     } else {
-      // used as default value for yPosition property if the user does not input
+      // used as default value for m_yPosition property if the user does not
+      // input
       // one.
-      storePropertyValue("YAxisPosition", yPosition->placeholderText());
+      storePropertyValue("YAxisPosition", m_yPosition->placeholderText());
     }
-    if (validateDialogInput(groupWorkspaceNameInput->text())){
-        storePropertyValue("OutputWorkspace", groupWorkspaceNameInput->text());
+    if (validateDialogInput(m_groupWorkspaceNameInput->text())) {
+      storePropertyValue("OutputWorkspace", m_groupWorkspaceNameInput->text());
     }
     emit validInput();
   }
diff --git a/MantidQt/CustomInterfaces/src/Muon/ALCInterface.cpp b/MantidQt/CustomInterfaces/src/Muon/ALCInterface.cpp
index a52e8a9ea46656ce5503523ea3af0e8a01bf2846..f70fe204e98fc0c6d7dd30b80c2caff417715d33 100644
--- a/MantidQt/CustomInterfaces/src/Muon/ALCInterface.cpp
+++ b/MantidQt/CustomInterfaces/src/Muon/ALCInterface.cpp
@@ -31,6 +31,7 @@ namespace CustomInterfaces
 
   ALCInterface::ALCInterface(QWidget* parent)
     : UserSubWindow(parent), m_ui(),
+      m_baselineModellingView(NULL), m_peakFittingView(NULL),
       m_dataLoading(NULL), m_baselineModelling(NULL), m_peakFitting(NULL),
       m_baselineModellingModel(new ALCBaselineModellingModel()),
       m_peakFittingModel(new ALCPeakFittingModel())
diff --git a/MantidQt/CustomInterfaces/src/Tomography/ImageStackPreParams.cpp b/MantidQt/CustomInterfaces/src/Tomography/ImageStackPreParams.cpp
index 60d8a1e2bd0dbc8a26e01cb9dcae0898e0a27395..b343d7c20876fa95bda014ff49ed75407ab2daaf 100644
--- a/MantidQt/CustomInterfaces/src/Tomography/ImageStackPreParams.cpp
+++ b/MantidQt/CustomInterfaces/src/Tomography/ImageStackPreParams.cpp
@@ -5,9 +5,7 @@ using namespace MantidQt::CustomInterfaces;
 namespace MantidQt {
 namespace CustomInterfaces {
 
-ImageStackPreParams::ImageStackPreParams()
-{
+ImageStackPreParams::ImageStackPreParams() : medianFilter(false) {}
 
-}
 } // namespace CustomInterfaces
 } // namespace MantidQt
diff --git a/MantidQt/SliceViewer/src/PeaksViewer.cpp b/MantidQt/SliceViewer/src/PeaksViewer.cpp
index 8034a80c7909877c78b2e430082b98b8e5b4776a..ac8fb544ccfb0608c79fc78374bcc485ece737eb 100644
--- a/MantidQt/SliceViewer/src/PeaksViewer.cpp
+++ b/MantidQt/SliceViewer/src/PeaksViewer.cpp
@@ -122,9 +122,9 @@ PeaksViewer::~PeaksViewer() {}
  */
 bool PeaksViewer::hasThingsToShow() const { return m_presenter->size() >= 1; }
 
-void PeaksViewer::   clearPeaksModeRequest(
+void PeaksViewer::clearPeaksModeRequest(
     const PeaksWorkspaceWidget *const originWidget, const bool on) {
-  EditMode mode;
+  EditMode mode = None;
   if (on) {
     QList<PeaksWorkspaceWidget *> children =
         qFindChildren<PeaksWorkspaceWidget *>(this);
@@ -149,7 +149,7 @@ void PeaksViewer::   clearPeaksModeRequest(
 
 void PeaksViewer::addPeaksModeRequest(const PeaksWorkspaceWidget * const originWidget, const bool on)
 {
-    EditMode mode;
+    EditMode mode = None;
     if(on) {
     QList<PeaksWorkspaceWidget *> children =
         qFindChildren<PeaksWorkspaceWidget *>(this);
diff --git a/MantidQt/SpectrumViewer/inc/MantidQtSpectrumViewer/GraphDisplay.h b/MantidQt/SpectrumViewer/inc/MantidQtSpectrumViewer/GraphDisplay.h
index b3cd39f36e9a261ea1cfe2f29978d28b1efbb2c1..a7cdd630803f9bf82ed17fe8141e2dfad3eaac94 100644
--- a/MantidQt/SpectrumViewer/inc/MantidQtSpectrumViewer/GraphDisplay.h
+++ b/MantidQt/SpectrumViewer/inc/MantidQtSpectrumViewer/GraphDisplay.h
@@ -96,7 +96,7 @@ class EXPORT_OPT_MANTIDQT_SPECTRUMVIEWER GraphDisplay
    double m_minY;
    double m_maxY;
 
-   static QColor g_curveColors[];
+   static std::vector<QColor> g_curveColors;
 
 };
 
diff --git a/MantidQt/SpectrumViewer/src/GraphDisplay.cpp b/MantidQt/SpectrumViewer/src/GraphDisplay.cpp
index fb458c40088478e07a1b3a7bc941514268b022d4..3b3f3f25de46e91737a218ce8c00db2f5d172919 100644
--- a/MantidQt/SpectrumViewer/src/GraphDisplay.cpp
+++ b/MantidQt/SpectrumViewer/src/GraphDisplay.cpp
@@ -12,7 +12,7 @@ namespace MantidQt
 namespace SpectrumView
 {
 
-QColor GraphDisplay::g_curveColors[] = {Qt::black, Qt::red, Qt::green, Qt::blue};
+std::vector<QColor> GraphDisplay::g_curveColors;
 
 /**
  *  Construct a GraphDisplay to display selected graph on the specifed plot
@@ -40,6 +40,11 @@ GraphDisplay::GraphDisplay( QwtPlot*      graphPlot,
 {
   if(isVertical)
     graphPlot->setAxisMaxMajor( QwtPlot::xBottom, 3 );
+
+  g_curveColors.push_back(Qt::black);
+  g_curveColors.push_back(Qt::red);
+  g_curveColors.push_back(Qt::green);
+  g_curveColors.push_back(Qt::blue);
 }
 
 
@@ -130,7 +135,7 @@ void GraphDisplay::setData(const QVector<double> & xData,
   auto curve = new QwtPlotCurve;
   curve->setData( xData, yData );
   curve->attach( m_graphPlot );
-  auto colorIndex = m_curves.size() % sizeof(g_curveColors);
+  auto colorIndex = m_curves.size() % g_curveColors.size();
   curve->setPen(QPen(g_curveColors[colorIndex]));
   m_curves.append(curve);