Index: /issm/trunk-jpl/src/c/objects/DakotaPlugin.cpp
===================================================================
--- /issm/trunk-jpl/src/c/objects/DakotaPlugin.cpp	(revision 12456)
+++ /issm/trunk-jpl/src/c/objects/DakotaPlugin.cpp	(revision 12457)
@@ -74,8 +74,8 @@
 	}
 	/*The descriptors: */
-	variable_descriptors=(char**)xmalloc(numACV*sizeof(char*));
+	variable_descriptors=xNew<char*>(numACV);
 	for(i=0;i<numACV;i++){
 		string label=xCLabels[i];
-		variable_descriptor=(char*)xmalloc((strlen(label.c_str())+1)*sizeof(char));
+		variable_descriptor=xNew<char>(strlen(label.c_str())+1);
 		memcpy(variable_descriptor,label.c_str(),(strlen(label.c_str())+1)*sizeof(char));
 
@@ -100,7 +100,7 @@
 	for(i=0;i<numACV;i++){
 		variable_descriptor=variable_descriptors[i];
-		xfree((void**)&variable_descriptor);
+		xDelete<char>(variable_descriptor);
 	}
-	xfree((void**)&variable_descriptors);
+	xDelete<char*>(variable_descriptors);
 	xDelete<IssmDouble>(responses);
 
Index: /issm/trunk-jpl/src/c/objects/DofIndexing.cpp
===================================================================
--- /issm/trunk-jpl/src/c/objects/DofIndexing.cpp	(revision 12456)
+++ /issm/trunk-jpl/src/c/objects/DofIndexing.cpp	(revision 12457)
@@ -51,9 +51,9 @@
 
 	if(this->gsize>0){
-		this->f_set=(bool*)xmalloc(this->gsize*sizeof(bool));
-		this->s_set=(bool*)xmalloc(this->gsize*sizeof(bool));
+		this->f_set=xNew<bool>(this->gsize);
+		this->s_set=xNew<bool>(this->gsize);
 		this->svalues=xNew<IssmDouble>(this->gsize);
-		if(in->doftype)this->doftype=(int*)xmalloc(this->gsize*sizeof(int)); 
-		this->gdoflist=(int*)xmalloc(this->gsize*sizeof(int)); 
+		if(in->doftype)this->doftype=xNew<int>(this->gsize); 
+		this->gdoflist=xNew<int>(this->gsize); 
 	}
 	else{
@@ -64,6 +64,6 @@
 		this->gdoflist=NULL;
 	}
-	if(this->fsize>0 && this->fsize!=UNDEF)this->fdoflist=(int*)xmalloc(this->fsize*sizeof(int)); else this->fdoflist=NULL;
-	if(this->ssize>0 && this->ssize!=UNDEF)this->sdoflist=(int*)xmalloc(this->ssize*sizeof(int)); else this->sdoflist=NULL;
+	if(this->fsize>0 && this->fsize!=UNDEF)this->fdoflist=xNew<int>(this->fsize); else this->fdoflist=NULL;
+	if(this->ssize>0 && this->ssize!=UNDEF)this->sdoflist=xNew<int>(this->ssize); else this->sdoflist=NULL;
 
 	if(this->gsize>0){
@@ -82,11 +82,11 @@
 DofIndexing::~DofIndexing(){ //destructor
 
-	xfree((void**)&f_set); 
-	xfree((void**)&s_set); 
+	xDelete<bool>(f_set); 
+	xDelete<bool>(s_set); 
 	xDelete<IssmDouble>(svalues);
-	xfree((void**)&doftype); 
-	xfree((void**)&gdoflist);
-	xfree((void**)&fdoflist);
-	xfree((void**)&sdoflist);
+	xDelete<int>(doftype); 
+	xDelete<int>(gdoflist);
+	xDelete<int>(fdoflist);
+	xDelete<int>(sdoflist);
 
 }
@@ -102,9 +102,9 @@
 	/*allocate: */
 	if(this->gsize>0){
-		this->f_set=(bool*)xmalloc(this->gsize*sizeof(bool));
-		this->s_set=(bool*)xmalloc(this->gsize*sizeof(bool));
+		this->f_set=xNew<bool>(this->gsize);
+		this->s_set=xNew<bool>(this->gsize);
 		this->svalues=xNew<IssmDouble>(this->gsize);
-		if(in_doftype)this->doftype=(int*)xmalloc(this->gsize*sizeof(int));
-		this->gdoflist=(int*)xmalloc(this->gsize*sizeof(int));
+		if(in_doftype)this->doftype=xNew<int>(this->gsize);
+		this->gdoflist=xNew<int>(this->gsize);
 	}
 
@@ -131,6 +131,6 @@
 		for(i=0;i<this->gsize;i++) if(f_set[i])size++;
 		this->fsize=size;
-		xfree((void**)&this->fdoflist);
-		if(this->fsize)this->fdoflist=(int*)xmalloc(size*sizeof(int));
+		xDelete<int>(this->fdoflist);
+		if(this->fsize)this->fdoflist=xNew<int>(size);
 		else this->fdoflist=NULL;
 	}
@@ -139,6 +139,6 @@
 		for(i=0;i<this->gsize;i++) if(s_set[i])size++;
 		this->ssize=size;
-		xfree((void**)&this->sdoflist);
-		if(this->ssize)this->sdoflist=(int*)xmalloc(size*sizeof(int));
+		xDelete<int>(this->sdoflist);
+		if(this->ssize)this->sdoflist=xNew<int>(size);
 		else this->sdoflist=NULL;
 	}
Index: /issm/trunk-jpl/src/c/objects/FemModel.cpp
===================================================================
--- /issm/trunk-jpl/src/c/objects/FemModel.cpp	(revision 12456)
+++ /issm/trunk-jpl/src/c/objects/FemModel.cpp	(revision 12457)
@@ -39,5 +39,5 @@
 	
 	/*Dynamically allocate whatever is a list of length nummodels: */
-	analysis_type_list=(int*)xmalloc(nummodels*sizeof(int));
+	analysis_type_list=xNew<int>(nummodels);
 
 	/*Initialize: */
@@ -85,5 +85,5 @@
 
 	/*Delete all the datasets: */
-	xfree((void**)&analysis_type_list);
+	xDelete<int>(analysis_type_list);
 	delete elements;
 	delete nodes;
Index: /issm/trunk-jpl/src/c/objects/Hook.cpp
===================================================================
--- /issm/trunk-jpl/src/c/objects/Hook.cpp	(revision 12456)
+++ /issm/trunk-jpl/src/c/objects/Hook.cpp	(revision 12457)
@@ -47,7 +47,7 @@
 	else{
 		/*Allocate: */
-		this->objects=(Object**)xmalloc(this->num*sizeof(Object*));
-		this->ids=(int*)xmalloc(this->num*sizeof(int));
-		this->offsets=(int*)xmalloc(this->num*sizeof(int));
+		this->objects=xNew<Object*>(this->num);
+		this->ids=xNew<int>(this->num);
+		this->offsets=xNew<int>(this->num);
 
 		/*Copy ids: */
@@ -63,7 +63,7 @@
 Hook::~Hook(){
 	/*deallocate: */
-	xfree((void**)&this->objects);
-	xfree((void**)&this->ids);
-	xfree((void**)&this->offsets);
+	xDelete<Object*>(this->objects);
+	xDelete<int>(this->ids);
+	xDelete<int>(this->offsets);
 	return;
 }
@@ -132,7 +132,7 @@
 	output->num=this->num;
 	if(output->num){
-		output->objects=(Object**)xmalloc(output->num*sizeof(Object*));
-		output->ids=(int*)xmalloc(output->num*sizeof(int));
-		output->offsets=(int*)xmalloc(output->num*sizeof(int));
+		output->objects=xNew<Object*>(output->num);
+		output->ids=xNew<int>(output->num);
+		output->offsets=xNew<int>(output->num);
 	}
 	
@@ -252,7 +252,7 @@
 	if(output->num<1) _error_("Trying to spawn an empty ElementProperties!");
 
-	output->objects=(Object**)xmalloc(output->num*sizeof(Object*));
-	output->ids=(int*)xmalloc(output->num*sizeof(int));
-	output->offsets=(int*)xmalloc(output->num*sizeof(int));
+	output->objects=xNew<Object*>(output->num);
+	output->ids=xNew<int>(output->num);
+	output->offsets=xNew<int>(output->num);
 
 	for(i=0;i<output->num;i++){
Index: /issm/trunk-jpl/src/c/objects/IoModel.cpp
===================================================================
--- /issm/trunk-jpl/src/c/objects/IoModel.cpp	(revision 12456)
+++ /issm/trunk-jpl/src/c/objects/IoModel.cpp	(revision 12457)
@@ -53,5 +53,5 @@
 
 	/*Initialize data: */
-	this->data=(IssmPDouble**)xmalloc(MaximumNumberOfEnums*sizeof(IssmPDouble*));
+	this->data=xNew<IssmPDouble*>(MaximumNumberOfEnums);
 	for(int i=0;i<MaximumNumberOfEnums;i++) this->data[i]=NULL;
 	
@@ -84,10 +84,10 @@
 	#endif
 
-	xfree((void**)&this->data);
-	xfree((void**)&this->my_elements);
-	xfree((void**)&this->my_nodes);
-	xfree((void**)&this->my_vertices);
-	xfree((void**)&this->singlenodetoelementconnectivity);
-	xfree((void**)&this->numbernodetoelementconnectivity);
+	xDelete<IssmPDouble*>(this->data);
+	xDelete<bool>(this->my_elements);
+	xDelete<bool>(this->my_nodes);
+	xDelete<int>(this->my_vertices);
+	xDelete<int>(this->singlenodetoelementconnectivity);
+	xDelete<int>(this->numbernodetoelementconnectivity);
 }
 /*}}}*/
@@ -305,5 +305,5 @@
 
 						if(string_size){
-							string=(char*)xmalloc((string_size+1)*sizeof(char));
+							string=xNew<char>(string_size+1);
 							string[string_size]='\0';
 
@@ -315,5 +315,5 @@
 						}
 						else{
-							string=(char*)xmalloc(sizeof(char));
+							string=xNew<char>(1);
 							string[0]='\0';
 						}
@@ -323,5 +323,5 @@
 
 						/*Free string*/
-						xfree((void**)&string);
+						xDelete<char>(string);
 
 						break;
@@ -404,5 +404,5 @@
 					MPI_Bcast(&string_size,1,MPI_INT,0,MPI_COMM_WORLD); 
 					if(string_size){
-						string=(char*)xmalloc((string_size+1)*sizeof(char));
+						string=xNew<char>((string_size+1));
 						string[string_size]='\0';
 
@@ -411,5 +411,5 @@
 					}
 					else{
-						string=(char*)xmalloc(sizeof(char));
+						string=xNew<char>(1);
 						string[0]='\0';
 					}
@@ -418,5 +418,5 @@
 
 					/*Free string*/
-					xfree((void**)&string);
+					xDelete<char>(string);
 
 					break;
@@ -559,5 +559,5 @@
 	/*Now allocate string: */
 	if(string_size){
-		string=(char*)xmalloc((string_size+1)*sizeof(char));
+		string=xNew<char>((string_size+1));
 		string[string_size]='\0';
 
@@ -571,5 +571,5 @@
 	}
 	else{
-		string=(char*)xmalloc(sizeof(char));
+		string=xNew<char>(1);
 		string[0]='\0';
 	}
@@ -621,5 +621,5 @@
 	/*Now allocate matrix: */
 	if(M*N){
-		matrix=(IssmPDouble*)xmalloc(M*N*sizeof(IssmPDouble));
+		matrix=xNew<IssmPDouble>(M*N);
 
 		/*Read matrix on node 0, then broadcast: */
@@ -635,5 +635,5 @@
 	/*Now cast to integer: */
 	if(M*N){
-		integer_matrix=(int*)xmalloc(M*N*sizeof(int));
+		integer_matrix=xNew<int>(M*N);
 		for (i=0;i<M;i++){
 			for (j=0;j<N;j++){
@@ -646,5 +646,5 @@
 	}
 	/*Free ressources:*/
-	xfree((void**)&matrix);
+	xDelete<IssmPDouble>(matrix);
 
 	/*Assign output pointers: */
@@ -740,5 +740,5 @@
 	/*Now allocate string array: */
 	if(numstrings){
-		strings=(char**)xmalloc(numstrings*sizeof(char*));
+		strings=xNew<char*>(numstrings);
 		for(i=0;i<numstrings;i++)strings[i]=NULL;
 
@@ -753,5 +753,5 @@
 			#endif
 			if(string_size){
-				string=(char*)xmalloc((string_size+1)*sizeof(char));
+				string=xNew<char>((string_size+1));
 				string[string_size]='\0';
 
@@ -765,5 +765,5 @@
 			}
 			else{
-				string=(char*)xmalloc(sizeof(char));
+				string=xNew<char>(1);
 				string[0]='\0';
 			}
@@ -812,7 +812,7 @@
 
 		/*Allocate matrices :*/
-		matrices=(IssmPDouble**)xmalloc(numrecords*sizeof(IssmPDouble*));
-		mdims=(int*)xmalloc(numrecords*sizeof(int));
-		ndims=(int*)xmalloc(numrecords*sizeof(int));
+		matrices=xNew<IssmPDouble*>(numrecords);
+		mdims=xNew<int>(numrecords);
+		ndims=xNew<int>(numrecords);
 
 		for(i=0;i<numrecords;i++){
@@ -841,5 +841,5 @@
 			/*Now allocate matrix: */
 			if(M*N){
-				matrix=(IssmPDouble*)xmalloc(M*N*sizeof(IssmPDouble));
+				matrix=xNew<IssmPDouble>(M*N);
 
 				/*Read matrix on node 0, then broadcast: */
@@ -886,5 +886,5 @@
 		case 3: {//IssmPDouble
 			  IssmPDouble *value = NULL;
-			  value=(IssmPDouble*)xmalloc(1*sizeof(IssmPDouble));
+			  value=xNew<IssmPDouble>(1);
 			  FetchData(value,index+1);
 			  option = new OptionDouble();
@@ -1142,6 +1142,6 @@
 	}
 	/*Free ressources:*/
-	xfree((void**)&IssmPDoublevector);
-	xfree((void**)&string);
+	xDelete<IssmPDouble>(IssmPDoublevector);
+	xDelete<char>(string);
 }
 /*FUNCTION IoModel::LastIndex{{{*/
Index: /issm/trunk-jpl/src/c/objects/Node.cpp
===================================================================
--- /issm/trunk-jpl/src/c/objects/Node.cpp	(revision 12456)
+++ /issm/trunk-jpl/src/c/objects/Node.cpp	(revision 12457)
@@ -801,5 +801,5 @@
 	if(setenum==FsetEnum){
 		if(this->indexing.fsize){
-			indices=(int*)xmalloc(this->indexing.fsize*sizeof(int));
+			indices=xNew<int>(this->indexing.fsize);
  			values=xNew<IssmDouble>(this->indexing.fsize);
 
@@ -819,5 +819,5 @@
 	else if(setenum==SsetEnum){
 		if(this->indexing.ssize){
-			indices=(int*)xmalloc(this->indexing.ssize*sizeof(int));
+			indices=xNew<int>(this->indexing.ssize);
 			values=xNew<IssmDouble>(this->indexing.ssize);
 
@@ -839,5 +839,5 @@
 	/*Free ressources:*/
 	xDelete<IssmDouble>(values);
-	xfree((void**)&indices);
+	xDelete<int>(indices);
 }
 /*}}}*/
