Index: pr_inversion/c_extensions/Cinvertor.c
===================================================================
--- pr_inversion/c_extensions/Cinvertor.c	(revision eca05c8ee390007a16bb46b22163b8750ee5ab98)
+++ pr_inversion/c_extensions/Cinvertor.c	(revision 2d06beb109031c888260d5a73af0ae5e57628b01)
@@ -80,8 +80,23 @@
 	Py_ssize_t ndata;
 	double *data;
+	int i;
   
 	if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL;
 	OUTVECTOR(data_obj,data,ndata);
-	self->params.x = data;
+	
+	free(self->params.x);
+	self->params.x = (double*) malloc(ndata*sizeof(double));
+	
+	if(self->params.x==NULL) {
+	    PyErr_SetString(CinvertorError, 
+	    	"Cinvertor.set_x: problem allocating memory.");
+		return NULL;		
+	}
+	
+	for (i=0; i<ndata; i++) {
+		self->params.x[i] = data[i];
+	}
+	
+	//self->params.x = data;
 	self->params.npoints = ndata;
 	return Py_BuildValue("i", self->params.npoints);	
@@ -95,5 +110,5 @@
     
 	if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL;
-	INVECTOR(data_obj, data, ndata);
+	OUTVECTOR(data_obj, data, ndata);
 	
 	// Check that the input array is large enough
@@ -120,8 +135,23 @@
 	Py_ssize_t ndata;
 	double *data;
+	int i;
   
 	if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL;
 	OUTVECTOR(data_obj,data,ndata);
-	self->params.y = data;
+	
+	free(self->params.y);
+	self->params.y = (double*) malloc(ndata*sizeof(double));
+	
+	if(self->params.y==NULL) {
+	    PyErr_SetString(CinvertorError, 
+	    	"Cinvertor.set_y: problem allocating memory.");
+		return NULL;		
+	}
+	
+	for (i=0; i<ndata; i++) {
+		self->params.y[i] = data[i];
+	}	
+	
+	//self->params.y = data;
 	self->params.ny = ndata;
 	return Py_BuildValue("i", self->params.ny);	
@@ -135,5 +165,5 @@
     
 	if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL;
-	INVECTOR(data_obj, data, ndata);
+	OUTVECTOR(data_obj, data, ndata);
 	
 	// Check that the input array is large enough
@@ -160,8 +190,23 @@
 	Py_ssize_t ndata;
 	double *data;
+	int i;
   
 	if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL;
 	OUTVECTOR(data_obj,data,ndata);
-	self->params.err = data;
+	
+	free(self->params.err);
+	self->params.err = (double*) malloc(ndata*sizeof(double));
+	
+	if(self->params.err==NULL) {
+	    PyErr_SetString(CinvertorError, 
+	    	"Cinvertor.set_err: problem allocating memory.");
+		return NULL;		
+	}
+	
+	for (i=0; i<ndata; i++) {
+		self->params.err[i] = data[i];
+	}
+	
+	//self->params.err = data;
 	self->params.nerr = ndata;
 	return Py_BuildValue("i", self->params.nerr);	
@@ -175,5 +220,5 @@
     
 	if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL;
-	INVECTOR(data_obj, data, ndata);
+	OUTVECTOR(data_obj, data, ndata);
 	
 	// Check that the input array is large enough
@@ -414,4 +459,12 @@
 }
 
+static PyObject * basefunc_ft(Cinvertor *self, PyObject *args) {
+	double d_max, q;
+	int n;
+	
+	if (!PyArg_ParseTuple(args, "did", &d_max, &n, &q)) return NULL;
+	return Py_BuildValue("f", ortho_transformed(d_max, n, q));	
+	
+}
 
 static PyMethodDef Cinvertor_methods[] = {
@@ -435,4 +488,5 @@
 		   {"get_pr_err", (PyCFunction)get_pr_err, METH_VARARGS, ""},
 		   {"is_valid", (PyCFunction)is_valid, METH_VARARGS, ""},
+		   {"basefunc_ft", (PyCFunction)basefunc_ft, METH_VARARGS, ""},
    
    {NULL}
Index: pr_inversion/c_extensions/invertor.c
===================================================================
--- pr_inversion/c_extensions/invertor.c	(revision eca05c8ee390007a16bb46b22163b8750ee5ab98)
+++ pr_inversion/c_extensions/invertor.c	(revision 2d06beb109031c888260d5a73af0ae5e57628b01)
@@ -8,7 +8,7 @@
  */
 void invertor_dealloc(Invertor_params *pars) {
-	//free(pars->x);
-	//free(pars->y);
-	//free(pars->err);
+	free(pars->x);
+	free(pars->y);
+	free(pars->err);
 }
 
@@ -133,3 +133,2 @@
 }
 
-
Index: pr_inversion/c_extensions/invertor.h
===================================================================
--- pr_inversion/c_extensions/invertor.h	(revision eca05c8ee390007a16bb46b22163b8750ee5ab98)
+++ pr_inversion/c_extensions/invertor.h	(revision 2d06beb109031c888260d5a73af0ae5e57628b01)
@@ -29,4 +29,3 @@
 void pr_err(double *pars, double *err, double d_max, int n_c, 
 		double r, double *pr_value, double *pr_value_err);
-
 #endif
