diff --git a/src/analysis/Analysis.cpp b/src/analysis/Analysis.cpp
index cedef3453d271668f34ca9199ff0da95cf0c226d..272ed5f1f77676a5d02c626436134c12f1c43ca5 100644
--- a/src/analysis/Analysis.cpp
+++ b/src/analysis/Analysis.cpp
@@ -222,8 +222,9 @@ argument_names(getNumberOfArguments())
 }
 
 void Analysis::readDataFromFile( const std::string& filename ){
-  FILE* fp=fopen(filename.c_str(),"r"); double tstep, oldtstep; 
+  FILE* fp=fopen(filename.c_str(),"r");
   if(fp!=NULL){
+     double tstep, oldtstep; 
      bool do_read=true, first=true;
      while (do_read) {
         PDB mypdb;
diff --git a/src/bias/MetaD.cpp b/src/bias/MetaD.cpp
index d6e06289a9fdc661f8bc5e7b50912ba0d70ec5c3..b9e92fa8153875356375ecac7d130a1533cab943 100644
--- a/src/bias/MetaD.cpp
+++ b/src/bias/MetaD.cpp
@@ -1056,10 +1056,10 @@ double MetaD::evaluateGaussian
  if(cv.size()>0) pcv=&cv[0];
  if(doInt_){
    plumed_dbg_assert(cv.size()==1);
-   pcv=&(tmpcv[0]);
    tmpcv[0]=cv[0];
    if(cv[0]<lowI_) tmpcv[0]=lowI_;
    if(cv[0]>uppI_) tmpcv[0]=uppI_;
+   pcv=&(tmpcv[0]);
  }
  if(hill.multivariate){ 
     unsigned k=0;
diff --git a/src/bias/PBMetaD.cpp b/src/bias/PBMetaD.cpp
index 66ae2e20a4830a0cc7261f4ec65cb485fc2fb0f9..9606572ca797c4239cfc6ced3e4d882b24490b0f 100644
--- a/src/bias/PBMetaD.cpp
+++ b/src/bias/PBMetaD.cpp
@@ -219,7 +219,7 @@ private:
   std::string fmt;
 
 public:
-  PBMetaD(const ActionOptions&);
+  explicit PBMetaD(const ActionOptions&);
   ~PBMetaD();
   void calculate();
   void update();
@@ -633,10 +633,10 @@ double PBMetaD::evaluateGaussian
  if(cv.size()>0) pcv=&cv[0];
  if(doInt_){
    plumed_assert(cv.size()==1);
-   pcv=&(tmpcv[0]);
    tmpcv[0]=cv[0];
    if(cv[0]<lowI_[iarg]) tmpcv[0]=lowI_[iarg];
    if(cv[0]>uppI_[iarg]) tmpcv[0]=uppI_[iarg];
+   pcv=&(tmpcv[0]);
  }
  double dp = difference(0,hill.center[0],pcv[0]) / hill.sigma[0];
  double dp2 = 0.5 * dp * dp;
diff --git a/src/core/ActionWithArguments.cpp b/src/core/ActionWithArguments.cpp
index ed99a28a25f5366409376c2e89039b8a712da904..6010bf054317c12a22f3ed74ef90cb8eb26d566b 100644
--- a/src/core/ActionWithArguments.cpp
+++ b/src/core/ActionWithArguments.cpp
@@ -55,9 +55,8 @@ void ActionWithArguments::interpretArgumentList(const std::vector<std::string>&
   for(unsigned i=0;i<c.size();i++){
       // is a regex? then just interpret it. The signal is () 
       std::size_t found1 = c[i].find("(");
-      std::size_t found2 ;
       if(found1!=std::string::npos){
-        found2=c[i].find(")",found1+1,1); // find it again
+        std::size_t found2=c[i].find(")",found1+1,1); // find it again
 	if(found2!=std::string::npos){
 		// start regex parsing
 #ifdef __PLUMED_HAS_CREGEX 
@@ -84,10 +83,8 @@ void ActionWithArguments::interpretArgumentList(const std::vector<std::string>&
            	std::vector<ActionWithValue*> all=plumed.getActionSet().select<ActionWithValue*>();
                 if( all.empty() ) error("your input file is not telling plumed to calculate anything");
 	        for(unsigned j=0;j<all.size();j++){
-				std::string thisargument=all[j]->getLabel();	
 				std::vector<std::string> ss=all[j]->getComponentsVector();	
 				for(unsigned  k=0;k<ss.size();++k){
-					thisargument=ss[k];	
 					unsigned ll=strlen(ss[k].c_str())+1;
 					char*str;
 					str=new char [ll];
diff --git a/src/core/MDAtoms.cpp b/src/core/MDAtoms.cpp
index c9f564e2b8a910bce88cf91eb78bf843d576b8e0..e4cff7366adeae42b920d05a3f79fc70527e9215 100644
--- a/src/core/MDAtoms.cpp
+++ b/src/core/MDAtoms.cpp
@@ -144,8 +144,7 @@ void MDAtomsTyped<T>::updateVirial(const Tensor&virial)const{
 
 template <class T>
 void MDAtomsTyped<T>::updateForces(const vector<int>&index,const vector<Vector>&forces){
-  unsigned nt=OpenMP::getGoodNumThreads(fx,stride*index.size());
-#pragma omp parallel for num_threads(nt)
+#pragma omp parallel for num_threads(OpenMP::getGoodNumThreads(fx,stride*index.size()))
   for(unsigned i=0;i<index.size();++i){
     fx[stride*i]+=scalef*T(forces[index[i]][0]);
     fy[stride*i]+=scalef*T(forces[index[i]][1]);
@@ -156,8 +155,7 @@ void MDAtomsTyped<T>::updateForces(const vector<int>&index,const vector<Vector>&
 template <class T>
 void MDAtomsTyped<T>::rescaleForces(const vector<int>&index,double factor){
   if(virial) for(unsigned i=0;i<3;i++)for(unsigned j=0;j<3;j++) virial[3*i+j]*=T(factor);
-  unsigned nt=OpenMP::getGoodNumThreads(fx,stride*index.size());
-#pragma omp parallel for num_threads(nt)
+#pragma omp parallel for num_threads(OpenMP::getGoodNumThreads(fx,stride*index.size()))
   for(unsigned i=0;i<index.size();++i){
     fx[stride*i]*=T(factor);
     fy[stride*i]*=T(factor);
diff --git a/src/core/SetupMolInfo.cpp b/src/core/SetupMolInfo.cpp
index 13b33234a63b4e4daff1f14a1bc52c7de1800c90..af6a4d51383d92301b7695e3ad7768c601946e30 100644
--- a/src/core/SetupMolInfo.cpp
+++ b/src/core/SetupMolInfo.cpp
@@ -97,7 +97,6 @@ pdb(*new(PDB))
 void SetupMolInfo::getBackbone( std::vector<std::string>& restrings, const std::string& fortype, std::vector< std::vector<AtomNumber> >& backbone ){
   if( fortype!=mytype ) error("cannot calculate a variable designed for " + fortype + " molecules for molecule type " + mytype );
   if( MolDataClass::numberOfAtomsPerResidueInBackbone( mytype )==0 ) error("backbone is not defined for molecule type " + mytype );
-  bool useter=false; // This is used to deal with terminal groups in WHOLEMOLECULES
 
   if( read_backbone.size()!=0 ){
       if( restrings.size()!=1 ) error("cannot interpret anything other than all for residues when using CHAIN keywords");
@@ -108,6 +107,7 @@ void SetupMolInfo::getBackbone( std::vector<std::string>& restrings, const std::
           for(unsigned j=0;j<read_backbone[i].size();++j) backbone[i][j]=read_backbone[i][j];
       }
   } else {
+      bool useter=false; // This is used to deal with terminal groups in WHOLEMOLECULES
       if( restrings.size()==1 ){
           useter=( restrings[0].find("ter")!=std::string::npos );
           if( restrings[0].find("all")!=std::string::npos ){
diff --git a/src/function/FuncPathMSD.cpp b/src/function/FuncPathMSD.cpp
index ec1392aedbaab9bd1d97c12d74be29a8dc537ec5..193fb149cd7f8c9273295e4020728d5dc64153c8 100644
--- a/src/function/FuncPathMSD.cpp
+++ b/src/function/FuncPathMSD.cpp
@@ -208,7 +208,6 @@ void FuncPathMSD::calculate(){
  // log.printf("NOW CALCULATE! \n");
   double s_path=0.;
   double partition=0.;
-  double tmp;
   if(neighpair.empty()){ // at first step, resize it
        neighpair.resize(allArguments.size());  
        for(unsigned i=0;i<allArguments.size();i++)neighpair[i].first=allArguments[i]; 
@@ -229,7 +228,7 @@ void FuncPathMSD::calculate(){
   int n=0;
   for(pairiter it=neighpair.begin();it!=neighpair.end();++it){ 
     double expval=(*it).second;
-    tmp=lambda*expval*(s_path-(indexmap[(*it).first]))/partition;
+    double tmp=lambda*expval*(s_path-(indexmap[(*it).first]))/partition;
     setDerivative(val_s_path,n,tmp);
     setDerivative(val_z_path,n,expval/partition);
     n++;
diff --git a/src/generic/DumpAtoms.cpp b/src/generic/DumpAtoms.cpp
index e70daee115907e507497cfd7e6a216bf45de420d..a7c87a184a7f038c4ac7c2dacec00493db14d6a8 100644
--- a/src/generic/DumpAtoms.cpp
+++ b/src/generic/DumpAtoms.cpp
@@ -208,9 +208,9 @@ DumpAtoms::DumpAtoms(const ActionOptions&ao):
   of.link(*this);
   of.open(file);
   std::string path=of.getPath();
-  std::string mode=of.getMode();
   log<<"  Writing on file "<<path<<"\n";
 #ifdef __PLUMED_HAS_XDRFILE
+  std::string mode=of.getMode();
   if(type=="xtc"){
     of.close();
     xd=xdrfile_open(path.c_str(),mode.c_str());
diff --git a/src/tools/Grid.cpp b/src/tools/Grid.cpp
index 1fe6d0e6219dc3d8546b28ac49cf13e183d56d9e..52b97fe9b4e4e672c51056917edfc7e9c03388a4 100644
--- a/src/tools/Grid.cpp
+++ b/src/tools/Grid.cpp
@@ -338,12 +338,12 @@ void Grid::addKernel( const KernelFunctions& kernel ){
       }
   }
 
-  double newval; std::vector<double> der( dimension_ );
+  std::vector<double> der( dimension_ );
   for(unsigned i=0;i<neighbors.size();++i){
       index_t ineigh=neighbors[i];
       getPoint( ineigh, xx );
       for(unsigned j=0;j<dimension_;++j) vv[j]->set(xx[j]);
-      newval = kernel.evaluate( vv, der, usederiv_ );
+      double newval = kernel.evaluate( vv, der, usederiv_ );
       if( usederiv_ ) addValueAndDerivatives( ineigh, newval, der );
       else addValue( ineigh, newval );
   }
diff --git a/src/tools/RMSD.cpp b/src/tools/RMSD.cpp
index 5cd3197c8fcc58fd363204c5c494920f58add3a3..b5cad41683682314630c4f67b4fc81d35a674d55 100644
--- a/src/tools/RMSD.cpp
+++ b/src/tools/RMSD.cpp
@@ -970,7 +970,6 @@ std::vector<Vector> RMSDCoreData::getDDistanceDPositions(){
   plumed_massert(!retrieve_only_rotation,"You used  only_rotation=true in doCoreCalc therefore you cannot retrieve this information now");
   if(!hasDistance)plumed_merror("getDPositionsDerivatives needs to calculate the distance via getDistance first !");
   if(!isInitialized)plumed_merror("getDPositionsDerivatives needs to initialize the coreData first!");
-  vector<Vector> ddist_tmp(n);
   Vector csum;
   Vector tmp1,tmp2;
   for(unsigned iat=0;iat<n;iat++){
@@ -1003,7 +1002,6 @@ std::vector<Vector>  RMSDCoreData::getDDistanceDReference(){
   derivatives.resize(n);
   double prefactor=1.0;
   if(!distanceIsMSD) prefactor*=0.5/dist;
-  vector<Vector> ddist_tmp(n);
   Vector csum,tmp1,tmp2;
 
   plumed_massert(!retrieve_only_rotation,"You used  only_rotation=true in doCoreCalc therefore you cannot retrieve this information now");
@@ -1046,7 +1044,6 @@ std::vector<Vector>  RMSDCoreData::getDDistanceDReferenceSOMA(){
   derivatives.resize(n);
   double prefactor=1.0;
   if(!distanceIsMSD) prefactor*=0.5/dist;
-  vector<Vector> ddist_tmp(n);
   Vector csum,tmp1,tmp2;
 
   plumed_massert(!retrieve_only_rotation,"You used  only_rotation=true in doCoreCalc therefore you cannot retrieve this information now");