diff --git a/src/colvar/CH3Shifts.cpp b/src/colvar/CH3Shifts.cpp
index e911980e8d4c5d9b0e9259ac21c9b3f350831c43..4b2770025b65649706613ab7458cbfff3e03e238 100644
--- a/src/colvar/CH3Shifts.cpp
+++ b/src/colvar/CH3Shifts.cpp
@@ -183,7 +183,7 @@ PLUMED_COLVAR_INIT(ao)
   if(ensemble&&comm.Get_rank()==0) {
     if(multi_sim_comm.Get_size()<2) error("You CANNOT run Replica-Averaged simulations without running multiple replicas!\n");
     else ens_dim=multi_sim_comm.Get_size(); 
-  } else ens_dim=0; 
+  } else ens_dim=1; 
   if(ensemble) comm.Sum(&ens_dim, 1);
 
   stringadb  = stringa_data + string("/CH3shifts.dat");
@@ -294,34 +294,19 @@ void CH3Shifts::calculate()
      coor.coor[ipos+2] = len_pl2alm*Pos[2];
   }
 
+  bool printout=false;
+  string csfile;
+  if(pperiod>0&&comm.Get_rank()==0) printout = (!(getStep()%pperiod));
+  if(printout) csfile = string("cs")+getLabel()+"-"+to_string(getStep())+string(".dat");
+
   double fact=1.0;
   if(!ensemble) { 
      energy = meth_list[0]->calc_cs_force(coor, forces);
-     bool printout=false;
-     if(pperiod>0&&comm.Get_rank()==0) printout = (!(getStep()%pperiod));
-     if(printout) {
-       string csfile;
-       char tmps1[21];
-       // add to the name the label of the cv in such a way to have different files
-       // when there is more than one defined variable
-       sprintf(tmps1, "%li", getStep());
-       csfile = string("cs")+tmps1+string(".dat");
-       meth_list[0]->write_cs(csfile.c_str());
-     }
+     if(printout) meth_list[0]->write_cs(csfile.c_str());
   } else {
      meth_list[0]->calc_cs(coor);
-     bool printout=false;
-     if(pperiod>0&&comm.Get_rank()==0) printout = (!(getStep()%pperiod));
-     if(printout) {
-       string csfile;
-       char tmps1[21], tmps2[21];
-       // add to the name the label of the cv in such a way to have different files
-       // when there is more than one defined variable
-       sprintf(tmps1, "%li", getStep());
-       sprintf(tmps2, "%i", multi_sim_comm.Get_rank());
-       csfile = string("cs")+tmps2+"-"+tmps1+string(".dat");
-       meth_list[0]->write_cs(csfile.c_str());
-     }
+     if(printout) meth_list[0]->write_cs(csfile.c_str());
+
      unsigned size = meth_list[0]->ala_calc_hb.size();
      for(unsigned j=0;j<size;j++) sh[0][j] = meth_list[0]->ala_calc_hb[j];
      size = meth_list[0]->ile_calc_hd.size();
@@ -342,7 +327,6 @@ void CH3Shifts::calculate()
      if(comm.Get_rank()==0) { // I am the master of my replica
        // among replicas
        multi_sim_comm.Sum(&sh[0][0], numResidues*8);
-       multi_sim_comm.Barrier(); 
        for(unsigned i=0;i<8;i++) for(int j=0;j<numResidues;j++) sh[j][i] *= fact; 
      } else for(unsigned i=0;i<8;i++) for(int j=0;j<numResidues;j++) sh[j][i] = 0.;
      // inside each replica
diff --git a/src/colvar/CS2Backbone.cpp b/src/colvar/CS2Backbone.cpp
index fa79121fd6b18840801a55231da2869fed886632..0b5219b10fc9c11e7336b96962a1b69dfbd31c9a 100644
--- a/src/colvar/CS2Backbone.cpp
+++ b/src/colvar/CS2Backbone.cpp
@@ -195,7 +195,7 @@ PLUMED_COLVAR_INIT(ao)
   if(ensemble&&comm.Get_rank()==0) {
     if(multi_sim_comm.Get_size()<2) error("You CANNOT run Replica-Averaged simulations without running multiple replicas!\n");
     else ens_dim=multi_sim_comm.Get_size(); 
-  } else ens_dim=0; 
+  } else ens_dim=1; 
   if(ensemble) comm.Sum(&ens_dim, 1);
 
   stringadb  = stringa_data + string("/camshift.db");
@@ -320,7 +320,6 @@ PLUMED_COLVAR_INIT(ao)
      <<plumed.cite("Kohlhoff K, Robustelli P, Cavalli A, Salvatella A, Vendruscolo M, J. Am. Chem. Soc. 131, 13894 (2009)")
      <<plumed.cite("Camilloni C, Robustelli P, De Simone A, Cavalli A, Vendruscolo M, J. Am. Chem. Soc. 134, 3968 (2012)") <<"\n";
 
-
   coor.resize(atoms.size()); 
   csforces.resize(atoms.size()); 
 
@@ -355,15 +354,7 @@ void CS2Backbone::calculate()
   bool printout=false;
   if(pperiod>0&&comm.Get_rank()==0) printout = (!(getStep()%pperiod));
   if(printout) {
-    string csfile;
-    char tmps1[21], tmps2[21];
-    // add to the name the label of the cv in such a way to have different files
-    // when there is more than one defined variable
-    sprintf(tmps1, "%li", getStep());
-    if(ensemble) {
-      sprintf(tmps2, "%i", multi_sim_comm.Get_rank());
-      csfile = string("cs-")+getLabel()+"-"+tmps2+"-"+tmps1+string(".dat");
-    } else csfile = string("cs-")+getLabel()+"-"+tmps1+string(".dat");
+    string csfile = string("cs-")+getLabel()+"-"+to_string(getStep())+string(".dat");;
     cam_list[0].printout_chemical_shifts(csfile.c_str());
   }
 
@@ -380,8 +371,7 @@ void CS2Backbone::calculate()
   }
 
   csforces.clear();
-  double energy;
-  energy = cam_list[0].ens_energy_force(coor, csforces, sh);
+  double energy = cam_list[0].ens_energy_force(coor, csforces, sh);
   if(!serial) comm.Sum(&csforces[0][0], N*4);
 
   Tensor virial;
diff --git a/src/colvar/NOE.cpp b/src/colvar/NOE.cpp
index 6bddb291124d8515b8dc1b3444d0d43aede03cd6..1f08891a46ed154af15b8a3ba47ca2391fb999cc 100644
--- a/src/colvar/NOE.cpp
+++ b/src/colvar/NOE.cpp
@@ -162,13 +162,13 @@ serial(false)
   if(ensemble&&comm.Get_rank()==0) {
     if(multi_sim_comm.Get_size()<2) error("You CANNOT run Replica-Averaged simulations without running multiple replicas!\n");
     else ens_dim=multi_sim_comm.Get_size(); 
-  } else ens_dim=0; 
+  } else ens_dim=1; 
   if(ensemble) comm.Sum(&ens_dim, 1);
 
   // Ouput details of all contacts
   unsigned index=0; 
   for(unsigned i=0;i<nga.size();++i){
-    log.printf("  The %uth NOE is calculated using %i equivalent couples of atoms and compared with a %f reference distance\n", i, nga[i], noedist[i]);
+    log.printf("  The %uth NOE is calculated using %u equivalent couples of atoms and compared with a %f reference distance\n", i, nga[i], noedist[i]);
     for(unsigned j=0;j<nga[i];j++) {
       log.printf("    couple %u is %d %d.\n", j, ga_lista[index].serial(), gb_lista[index].serial() );
       index++;
@@ -251,16 +251,7 @@ void NOE::calculate(){
   bool printout=false;
   if(pperiod>0&&comm.Get_rank()==0) printout = (!(getStep()%pperiod));
   if(printout) {
-    string csfile;
-    char tmps1[21], tmps2[21];
-    // add to the name the label of the cv in such a way to have different files
-    // when there is more than one defined variable
-    sprintf(tmps1, "%li", getStep());
-    if(ensemble) {
-      sprintf(tmps2, "%i", multi_sim_comm.Get_rank());
-      csfile = string("noe")+tmps2+"-"+tmps1+string(".dat");
-    } else csfile = string("noe")+tmps1+string(".dat");
-    // now print it!!
+    string csfile = string("noe")+to_string(getStep())+string(".dat");
     FILE *outfile = fopen(csfile.c_str(), "w");
     fprintf(outfile, "#index calc exp\n");
     for(unsigned i=0;i<nga.size();i++) { 
diff --git a/src/colvar/RDC.cpp b/src/colvar/RDC.cpp
index a0a6f39405216eb7d423984603c08cced48e1e08..ce0d3a8418bdb73fa0a53f7a8236431c4f435327 100644
--- a/src/colvar/RDC.cpp
+++ b/src/colvar/RDC.cpp
@@ -442,12 +442,7 @@ void RDC::calculate()
   bool printout=false;
   if(pperiod>0&&comm.Get_rank()==0) printout = (!(getStep()%pperiod));
   if(printout) {
-    string dcfile;
-    char tmps1[21];
-    sprintf(tmps1, "%li", getStep());
-    if(ensemble) {
-      dcfile = string("rdc-")+getLabel()+"-"+tmps1+string(".dat");
-    } else dcfile = string("rdc-")+getLabel()+"-"+tmps1+string(".dat");
+    string dcfile = string("rdc-")+getLabel()+"-"+to_string(getStep())+string(".dat");
     FILE *outfile = fopen(dcfile.c_str(), "w");
     fprintf(outfile, "#index calc exp\n");
     double sum=0.;