Index: ../trunk-jpl/src/c/bamg/Mesh.cpp
===================================================================
--- ../trunk-jpl/src/c/bamg/Mesh.cpp	(revision 18452)
+++ ../trunk-jpl/src/c/bamg/Mesh.cpp	(revision 18453)
@@ -226,22 +226,22 @@
 	Mesh::~Mesh() {/*{{{*/
 		/*Original code from Frederic Hecht <hecht@ann.jussieu.fr> (BAMG v1.01, Mesh2.cpp/Triangles)*/
 
-		//if (vertices)             delete [] vertices;
-		if (edges)                delete [] edges;
-		if (triangles)            delete [] triangles;
-		if (quadtree)             delete    quadtree;
-		//if (orderedvertices)                delete [] orderedvertices;
-		if (subdomains)           delete []  subdomains;
-		if (VerticesOnGeomEdge)   delete [] VerticesOnGeomEdge;
-		if (VerticesOnGeomVertex) delete [] VerticesOnGeomVertex;
-		if (VertexOnBThVertex)    delete [] VertexOnBThVertex;
-		if (VertexOnBThEdge)      delete [] VertexOnBThEdge;
+		if(vertices)             delete [] vertices;
+		if(edges)                delete [] edges;
+		if(triangles)            delete [] triangles;
+		if(quadtree)             delete    quadtree;
+		if(orderedvertices)      delete [] orderedvertices;
+		if(subdomains)           delete []  subdomains;
+		if(VerticesOnGeomEdge)   delete [] VerticesOnGeomEdge;
+		if(VerticesOnGeomVertex) delete [] VerticesOnGeomVertex;
+		if(VertexOnBThVertex)    delete [] VertexOnBThVertex;
+		if(VertexOnBThEdge)      delete [] VertexOnBThEdge;
 
-		if (&Gh) {
+		if(&Gh){
 			if (Gh.NbRef>0) Gh.NbRef--;
 			else if (Gh.NbRef==0) delete &Gh;
 		}
-		if (&BTh && (&BTh != this)) {
+		if(&BTh && (&BTh != this)){
 			if (BTh.NbRef>0) BTh.NbRef--;
 			else if (BTh.NbRef==0) delete &BTh;
 		}
@@ -2725,7 +2725,7 @@
 		VerticesOnGeomEdge=NULL;
 
 		/*Allocate if maxnbv_in>0*/
-		if (maxnbv_in) {
+		if(maxnbv_in){
 			vertices=new BamgVertex[maxnbv];
 			_assert_(vertices);
 			orderedvertices=new BamgVertex* [maxnbv];
@@ -2733,7 +2733,7 @@
 			triangles=new Triangle[maxnbt];
 			_assert_(triangles);
 		}
-		else {
+		else{
 			vertices=NULL;
 			orderedvertices=NULL;
 			triangles=NULL;
Index: ../trunk-jpl/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.cpp
===================================================================
--- ../trunk-jpl/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.cpp	(revision 18452)
+++ ../trunk-jpl/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.cpp	(revision 18453)
@@ -48,12 +48,12 @@
 	data_interp=xNew<double>(N_interp*N_data);
 
 	/*read background mesh*/
-	Mesh Th(index_data,x_data,y_data,nods_data,nels_data); 
+	Mesh* Th=new Mesh(index_data,x_data,y_data,nods_data,nels_data); 
 
 	/*Get reference number (for subdomains)*/
-	long* reft = xNew<long>(Th.nbt);
-	Th.TriangleReferenceList(reft);
-	Th.CreateSingleVertexToTriangleConnectivity();
+	long* reft = xNew<long>(Th->nbt);
+	Th->TriangleReferenceList(reft);
+	Th->CreateSingleVertexToTriangleConnectivity();
 
 	/*Get domain boundaries*/
 	xmin=x_data[0]; ymin=y_data[0];
@@ -78,10 +78,10 @@
 
 		/*Get current point coordinates*/
 		r.x=x_interp[i]; r.y=y_interp[i];
-		I2 I=Th.R2ToI2(r);
+		I2 I=Th->R2ToI2(r);
 
 		/*Find triangle holding r/I*/
-		Triangle &tb=*Th.TriangleFindFromCoord(I,dete);
+		Triangle &tb=*Th->TriangleFindFromCoord(I,dete);
 
 		/*point inside convex*/
 		if (tb.det>0){ 
@@ -91,11 +91,11 @@
 			areacoord[1]= (double) dete[1]/tb.det;
 			areacoord[2]= (double) dete[2]/tb.det;
 			/*3 vertices of the triangle*/
-			i0=Th.GetId(tb[0]);
-			i1=Th.GetId(tb[1]);
-			i2=Th.GetId(tb[2]);
+			i0=Th->GetId(tb[0]);
+			i1=Th->GetId(tb[1]);
+			i2=Th->GetId(tb[2]);
 			/*triangle number*/
-			it=Th.GetId(tb);
+			it=Th->GetId(tb);
 
 			/*Inside convex but outside mesh*/
 			if (reft[it]<0 && isdefault){
@@ -119,11 +119,11 @@
 				areacoord[VerticesOfTriangularEdge[k][0]] = bb;
 				areacoord[OppositeVertex[k]] = 1 - aa -bb;
 				//3 vertices of the triangle
-				i0=Th.GetId(tc[0]);
-				i1=Th.GetId(tc[1]);
-				i2=Th.GetId(tc[2]);
+				i0=Th->GetId(tc[0]);
+				i1=Th->GetId(tc[1]);
+				i2=Th->GetId(tc[2]);
 				//triangle number
-				it=Th.GetId(tc);
+				it=Th->GetId(tc);
 			}
 		}
 
@@ -144,6 +144,7 @@
 	//if(N_interp>=100) _printf_("\r      interpolation progress: "<<fixed<<setw(6)<<setprecision(2)<<100.<<"%  \n");
 
 	/*clean-up and return*/
+	delete Th;
 	xDelete<long>(reft);
 	*pdata_interp=data_interp;
 	return 1;
Index: ../trunk-jpl/src/wrappers/python/io/WritePythonData.cpp
===================================================================
--- ../trunk-jpl/src/wrappers/python/io/WritePythonData.cpp	(revision 18452)
+++ ../trunk-jpl/src/wrappers/python/io/WritePythonData.cpp	(revision 18453)
@@ -34,9 +34,13 @@
 	npy_intp dims[2]={0,0};
 	PyObject* array=NULL;
 
+	/*copy matrix: */
+	double* matrix_python=xNew<double>(M*N);
+	memcpy(matrix_python,matrix,M*N*sizeof(double));
+
 	dims[0]=(npy_intp)M;
 	dims[1]=(npy_intp)N;
-	array=PyArray_SimpleNewFromData(2,dims,NPY_DOUBLE,matrix);
+	array=PyArray_SimpleNewFromData(2,dims,NPY_DOUBLE,matrix_python);
 
 	PyTuple_SetItem(tuple, index, array);
 }/*}}}*/
@@ -46,13 +50,9 @@
 	npy_intp dims[2]={0,0};
 	PyObject* array=NULL;
 
-	/*intermediary:*/
-	long* lmatrix=NULL;
-	int i;
-
 	/*transform into long matrix: */
-	lmatrix=xNew<long>(M*N);
-	for(i=0;i<M*N;i++)lmatrix[i]=(long)matrix[i];
+	long* lmatrix=xNew<long>(M*N);
+	for(int i=0;i<M*N;i++)lmatrix[i]=(long)matrix[i];
 
 	dims[0]=(npy_intp)M;
 	dims[1]=(npy_intp)N;
@@ -66,25 +66,29 @@
 	npy_intp dims[2]={0,0};
 	PyObject* array=NULL;
 
+	/*copy matrix: */
+	bool* matrix_python=xNew<bool>(M*N);
+	memcpy(matrix_python,matrix,M*N*sizeof(bool));
+
 	dims[0]=(npy_intp)M;
 	dims[1]=(npy_intp)N;
-	array=PyArray_SimpleNewFromData(2,dims,NPY_BOOL,matrix);
+	array=PyArray_SimpleNewFromData(2,dims,NPY_BOOL,matrix_python);
 
 	PyTuple_SetItem(tuple, index, array);
 }/*}}}*/
 /*FUNCTION WriteData(PyObject* py_tuple,int index, double* vector, int M){{{*/
 void WriteData(PyObject* py_tuple, int index, double* vector, int M){
 
-	double   *buffer = NULL;
 	npy_intp  dim   = 10;
 	PyObject *array = NULL;
 
-	/*Copy vector*/
-	buffer=xNew<double>(M);
-	for(int i=0;i<M;i++)buffer[i]=vector[i];
 
+	/*copy vector: */
+	double* vector_python=xNew<double>(M);
+	memcpy(vector_python,vector,M*sizeof(double));
+
 	dim=(npy_intp)M;
-	array=PyArray_SimpleNewFromData(1,&dim,NPY_DOUBLE,buffer);
+	array=PyArray_SimpleNewFromData(1,&dim,NPY_DOUBLE,vector_python);
 
 	PyTuple_SetItem(py_tuple, index, array);
 
Index: ../trunk-jpl/src/wrappers/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp
===================================================================
--- ../trunk-jpl/src/wrappers/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp	(revision 18452)
+++ ../trunk-jpl/src/wrappers/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp	(revision 18453)
@@ -75,5 +75,13 @@
 	WriteData(DATAINTERP,data_interp,N_interp,N_data);
 
 	/*end module: */
+	xDelete<int>(index);
+	xDelete<double>(x_data);
+	xDelete<double>(y_data);
+	xDelete<double>(data);
+	xDelete<double>(x_interp);
+	xDelete<double>(y_interp);
+	xDelete<double>(data_interp);
+	delete options;
 	MODULEEND();
 }
