diff --git a/src/core/ActionWithArguments.cpp b/src/core/ActionWithArguments.cpp
index 2490129bb2ec01c08ff0a3d82d4cf9668461fd71..b492410ca7a7c1252890dc3b9f2930fd3d206fb5 100644
--- a/src/core/ActionWithArguments.cpp
+++ b/src/core/ActionWithArguments.cpp
@@ -98,10 +98,9 @@ void ActionWithArguments::interpretArgumentList(const std::vector<std::string>&
 				std::vector<std::string> ss=all[j]->getComponentsVector();	
 				for(unsigned  k=0;k<ss.size();++k){
 					unsigned ll=strlen(ss[k].c_str())+1;
-					char*str;
-					str=new char [ll];
-					strcpy(str,ss[k].c_str());
-					char *ppstr=str;
+                                        std::vector<char> str(ll);
+					strcpy(&str[0],ss[k].c_str());
+					const char *ppstr=&str[0];
 		                	if(!regexec(preg, ppstr , preg->re_nsub, pmatch, 0)) {
 						log.printf("  Something matched with \"%s\" : ",ss[k].c_str());
 						do {
@@ -123,7 +122,6 @@ void ActionWithArguments::interpretArgumentList(const std::vector<std::string>&
 								ppstr += pmatch[0].rm_eo;	/* Restart from last match */
 						} while(!regexec(preg,ppstr,preg->re_nsub,pmatch,0));
 					}		
-					delete [] str;
 				}
 		};
 		regfree(preg);
diff --git a/src/core/Atoms.cpp b/src/core/Atoms.cpp
index 70f39aaa76f5fb7d1efb23c3bc46a5979ba31385..2c3a5fbdcf1617ca1878d44dc137d21b1394f383 100644
--- a/src/core/Atoms.cpp
+++ b/src/core/Atoms.cpp
@@ -381,8 +381,9 @@ void Atoms::setAtomsContiguous(int start){
 }
 
 void Atoms::setRealPrecision(int p){
+  MDAtomsBase *x=MDAtomsBase::create(p);
   delete mdatoms;
-  mdatoms=MDAtomsBase::create(p);
+  mdatoms=x;
 }
 
 int Atoms::getRealPrecision()const{
diff --git a/src/core/CLToolMain.cpp b/src/core/CLToolMain.cpp
index 09d20edc03de851c01cac43e3d4f5b1f480b03d0..f60bca99d04489358648b0109aee9b55f52546a4 100644
--- a/src/core/CLToolMain.cpp
+++ b/src/core/CLToolMain.cpp
@@ -76,15 +76,18 @@ void CLToolMain::cmd(const std::string& word,void*val){
   } else if(word=="run"){
        CHECK_NULL(val,word);
        argc=argv.size();
-       char**v=new char* [argc];
+       int n=0; for(int i=0;i<argc;++i) n+=argv[i].length()+1;
+       std::vector<char> args(n);
+       std::vector<char*> v(argc);
+       char* ptr=&args[0];
        for(int i=0;i<argc;++i){
-         v[i]=new char [argv[i].length()+1];
-         for(unsigned c=0;c<argv[i].length();++c) v[i][c]=argv[i][c];
-         v[i][argv[i].length()]=0;
+         v[i]=ptr;
+         for(unsigned c=0;c<argv[i].length();++c){
+           *ptr=argv[i][c]; ptr++;
+         }
+         *ptr=0; ptr++;
        }
-       int ret=run(argc,v,in,out,comm);
-       for(int i=0;i<argc;++i) delete [] v[i];
-       delete [] v;
+       int ret=run(argc,&v[0],in,out,comm);
        *static_cast<int*>(val)=ret;
   } else {
     plumed_merror("cannot interpret cmd(\"CLTool " + word + "\"). check plumed developers manual to see the available commands.");
diff --git a/src/core/PlumedMain.cpp b/src/core/PlumedMain.cpp
index d28039dbf6297a264d799f2be6f13c79ad9807f6..8e92c93a62d99b710561827b97606bbfd0b7dd21 100644
--- a/src/core/PlumedMain.cpp
+++ b/src/core/PlumedMain.cpp
@@ -547,7 +547,8 @@ void PlumedMain::readInputWords(const std::vector<std::string> & words){
       log<<"I cannot understand line:";
       for(unsigned i=0;i<interpreted.size();++i) log<<" "<<interpreted[i];
       log<<"\n";
-      exit(1);
+      log.flush();
+      plumed_error();
     };
     action->checkRead();
     actionSet.push_back(action);
diff --git a/src/function/FuncSumHills.cpp b/src/function/FuncSumHills.cpp
index 21843d1813d6990499bd2f038402e8b5e2f2e870..25ed19207d65c136961d338ee9d9c7b5ec26763f 100644
--- a/src/function/FuncSumHills.cpp
+++ b/src/function/FuncSumHills.cpp
@@ -364,11 +364,10 @@ historep(NULL)
         }
 
         if(integratehills) {
-        	FilesHandler *hillsHandler;
-        	hillsHandler=new FilesHandler(hillsFiles,parallelread,*this, log);
+        	FilesHandler hillsHandler(hillsFiles,parallelread,*this, log);
 		vector<double> vmin,vmax;
         	vector<unsigned> vbin;  
-        	hillsHandler->getMinMaxBin(tmphillsvalues,comm,vmin,vmax,vbin);
+        	hillsHandler.getMinMaxBin(tmphillsvalues,comm,vmin,vmax,vbin);
 		log<<"  found boundaries from hillsfile: \n";
 		gmin.resize(vmin.size());
 		gmax.resize(vmax.size());
@@ -382,15 +381,13 @@ historep(NULL)
 		 	Tools::convert(vmax[i],gmax[i]);
 			log<<"  variable "<< getPntrToArgument(i)->getName()<<" min: "<<gmin[i]<<" max: "<<gmax[i]<<" nbin: "<<gbin[i]<<"\n";
 		}
-                delete hillsHandler;
         } 
 	// if at this stage bins are not there then do it with histo
 	if(gmin.size()==0){
-    	   	FilesHandler *histoHandler;
-	        histoHandler=new FilesHandler(histoFiles,parallelread,*this, log);
+    	   	FilesHandler histoHandler(histoFiles,parallelread,*this, log);
 		vector<double> vmin,vmax;
         	vector<unsigned> vbin;  
-        	histoHandler->getMinMaxBin(tmphistovalues,comm,vmin,vmax,vbin,histoSigma);
+        	histoHandler.getMinMaxBin(tmphistovalues,comm,vmin,vmax,vbin,histoSigma);
 		log<<"  found boundaries from histofile: \n";
 		gmin.resize(vmin.size());
 		gmax.resize(vmax.size());
@@ -404,7 +401,6 @@ historep(NULL)
 		 	Tools::convert(vmax[i],gmax[i]);
 			log<<"  variable "<< proj[i] <<" min: "<<gmin[i]<<" max: "<<gmax[i]<<" nbin: "<<gbin[i]<<"\n";
 		}
-                delete histoHandler;
         }
 	log<<"  done!\n"; 
 	log<<"   \n"; 
@@ -529,9 +525,9 @@ historep(NULL)
 		if(integratehills){
 
     	      		log<<"  Bias: Projecting on subgrid... \n";
-              		BiasWeight *Bw=new BiasWeight(beta); 
+              		BiasWeight Bw(beta); 
              		Grid biasGrid=*(biasrep->getGridPtr());
-   	      		Grid smallGrid=biasGrid.project(proj,Bw);
+   	      		Grid smallGrid=biasGrid.project(proj,&Bw);
               		OFile gridfile; gridfile.link(*this);
 	      		std::ostringstream ostr;ostr<<nfiles;
               		string myout; 
@@ -543,7 +539,6 @@ historep(NULL)
    	      		smallGrid.writeToFile(gridfile);
               		gridfile.close();
                         if(!ibias)integratehills=false;// once you get to the final bunch just give up 
-                        delete Bw;
 		}
                 // this should be removed
 		if(integratehisto){
@@ -616,8 +611,6 @@ historep(NULL)
 
 	nfiles++;
     }
-    if(hillsHandler) delete hillsHandler;
-    if(histoHandler) delete histoHandler;
 
     return;
   } 
diff --git a/src/generic/DumpAtoms.cpp b/src/generic/DumpAtoms.cpp
index 1ec293ccb6e2b37489e343a0973c7a486affb5f7..2358cbe305ad863517b3f64e8aa88101785ba1fc 100644
--- a/src/generic/DumpAtoms.cpp
+++ b/src/generic/DumpAtoms.cpp
@@ -278,17 +278,19 @@ void DumpAtoms::update(){
   } else if(type=="xtc" || type=="trr"){
     matrix box;
     const Tensor & t(getPbc().getBox());
-    rvec* pos=new rvec [getNumberOfAtoms()];
-    for(int i=0;i<3;i++) for(int j=0;j<3;j++) box[i][j]=lenunit*t(i,j);
-    for(int i=0;i<getNumberOfAtoms();i++) for(int j=0;j<3;j++) pos[i][j]=lenunit*getPosition(i)(j);
     int natoms=getNumberOfAtoms();
     int step=getStep();
     float time=getTime()/plumed.getAtoms().getUnits().getTime();
     float precision=Tools::fastpow(10.0,iprecision);
+    for(int i=0;i<3;i++) for(int j=0;j<3;j++) box[i][j]=lenunit*t(i,j);
+    rvec* pos=new rvec [natoms];
+// Notice that code below cannot throw any exception.
+// Thus, this pointer is excepton safe
+    for(int i=0;i<natoms;i++) for(int j=0;j<3;j++) pos[i][j]=lenunit*getPosition(i)(j);
     if(type=="xtc"){
-      write_xtc(xd,natoms,step,time,box,pos,precision);
+      write_xtc(xd,natoms,step,time,box,&pos[0],precision);
     } else if(type=="trr"){
-      write_trr(xd,natoms,step,time,0.0,box,pos,NULL,NULL);
+      write_trr(xd,natoms,step,time,0.0,box,&pos[0],NULL,NULL);
     }
     delete [] pos;
 #endif