Index: src/sas/sascalc/calculator/c_extensions/sld2i.c
===================================================================
--- src/sas/sascalc/calculator/c_extensions/sld2i.c	(revision 0957bb3ad795897233168bbc11756fd9ff98f8b1)
+++ src/sas/sascalc/calculator/c_extensions/sld2i.c	(revision 0957bb3ad795897233168bbc11756fd9ff98f8b1)
@@ -0,0 +1,204 @@
+/**
+Computes the (magnetic) scattering form sld (n and m) profile
+ */
+#include <stdio.h>
+#include <math.h>
+#include "sld2i.h"
+#include "libfunc.h"
+#include "librefl.h"
+/**
+ * Constructor for GenI
+ *
+ * binning
+ * //@param qx: array of Qx values
+ * //@param qy: array of Qy values
+ * //@param qz: array of Qz values
+ * @param x: array of x values
+ * @param y: array of y values
+ * @param z: array of z values
+ * @param sldn: array of sld n
+ * @param mx: array of sld mx
+ * @param my: array of sld my
+ * @param mz: array of sld mz
+ * @param in_spin: ratio of up spin in Iin
+ * @param out_spin: ratio of up spin in Iout
+ * @param s_theta: angle (from x-axis) of the up spin in degree
+ */
+void initGenI(GenI* this, int npix, double* x, double* y, double* z, double* sldn,
+			double* mx, double* my, double* mz, double* voli,
+			double in_spin, double out_spin,
+			double s_theta) {
+	this->n_pix = npix;
+	this->x_val = x;
+	this->y_val = y;
+	this->z_val = z;
+	this->sldn_val = sldn;
+	this->mx_val = mx;
+	this->my_val = my;
+	this->mz_val = mz;
+	this->vol_pix = voli;
+	this->inspin = in_spin;
+	this->outspin = out_spin;
+	this->stheta = s_theta;
+}
+
+/**
+ * Compute 2D anisotropic
+ */
+void genicomXY(GenI* this, int npoints, double *qx, double *qy, double *I_out){
+	//npoints is given negative for angular averaging
+	// Assumes that q doesn't have qz component and sld_n is all real
+	//double q = 0.0;
+	//double Pi = 4.0*atan(1.0);
+	polar_sld b_sld;
+	double qr = 0.0;
+	complex iqr = cassign(0.0, 0.0);
+	complex ephase = cassign(0.0, 0.0);
+	complex comp_sld = cassign(0.0, 0.0);
+
+	complex sumj_uu;
+	complex sumj_ud;
+	complex sumj_du;
+	complex sumj_dd;
+	complex temp_fi;
+
+	double count = 0.0;
+	//check if this computation is for averaging
+
+	//Assume that pixel volumes are given in vol_pix in A^3 unit
+	//int x_size = 0; //in Ang
+	//int y_size = 0; //in Ang
+	//int z_size = 0; //in Ang
+
+	// Loop over q-values and multiply apply matrix
+
+	for(int i=0; i<npoints; i++){
+		//I_out[i] = 0.0;
+		sumj_uu = cassign(0.0, 0.0);
+		sumj_ud = cassign(0.0, 0.0);
+		sumj_du = cassign(0.0, 0.0);
+		sumj_dd = cassign(0.0, 0.0);
+		//printf ("%d ", i);
+		//q = sqrt(qx[i]*qx[i] + qy[i]*qy[i]); // + qz[i]*qz[i]);
+
+		for(int j=0; j<this->n_pix; j++){
+			if (this->sldn_val[j]!=0.0
+				||this->mx_val[j]!=0.0
+				||this->my_val[j]!=0.0
+				||this->mz_val[j]!=0.0)
+			{
+				//anisotropic
+				temp_fi = cassign(0.0, 0.0);
+				b_sld = cal_msld(0, qx[i], qy[i], this->sldn_val[j],
+							 this->mx_val[j], this->my_val[j], this->mz_val[j],
+			 				 this->inspin, this->outspin, this->stheta);
+				qr = (qx[i]*this->x_val[j] + qy[i]*this->y_val[j]);
+				iqr = cassign(0.0, qr);
+				ephase = cplx_exp(iqr);
+
+				//Let's multiply pixel(atomic) volume here
+				ephase = rcmult(this->vol_pix[j], ephase);
+				//up_up
+				if (this->inspin > 0.0 && this->outspin > 0.0){
+					comp_sld = cassign(b_sld.uu, 0.0);
+					temp_fi = cplx_mult(comp_sld, ephase);
+					sumj_uu = cplx_add(sumj_uu, temp_fi);
+				}
+				//down_down
+				if (this->inspin < 1.0 && this->outspin < 1.0){
+					comp_sld = cassign(b_sld.dd, 0.0);
+					temp_fi = cplx_mult(comp_sld, ephase);
+					sumj_dd = cplx_add(sumj_dd, temp_fi);
+				}
+				//up_down
+				if (this->inspin > 0.0 && this->outspin < 1.0){
+					comp_sld = cassign(b_sld.re_ud, b_sld.im_ud);
+					temp_fi = cplx_mult(comp_sld, ephase);
+					sumj_ud = cplx_add(sumj_ud, temp_fi);
+				}
+				//down_up
+				if (this->inspin < 1.0 && this->outspin > 0.0){
+					comp_sld = cassign(b_sld.re_du, b_sld.im_du);
+					temp_fi = cplx_mult(comp_sld, ephase);
+					sumj_du = cplx_add(sumj_du, temp_fi);
+				}
+
+
+				if (i == 0){
+					count += this->vol_pix[j];
+				}
+			}
+		}
+		//printf("aa%d=%g %g %d\n", i, (sumj_uu.re*sumj_uu.re + sumj_uu.im*sumj_uu.im), (sumj_dd.re*sumj_dd.re + sumj_dd.im*sumj_dd.im), count);
+
+		I_out[i] = (sumj_uu.re*sumj_uu.re + sumj_uu.im*sumj_uu.im);
+		I_out[i] += (sumj_ud.re*sumj_ud.re + sumj_ud.im*sumj_ud.im);
+		I_out[i] += (sumj_du.re*sumj_du.re + sumj_du.im*sumj_du.im);
+		I_out[i] += (sumj_dd.re*sumj_dd.re + sumj_dd.im*sumj_dd.im);
+
+		I_out[i] *= (1.0E+8 / count); //in cm (unit) / number; //to be multiplied by vol_pix
+	}
+	//printf ("count = %d %g %g %g %g\n", count, sldn_val[0],mx_val[0], my_val[0], mz_val[0]);
+}
+/**
+ * Compute 1D isotropic
+ * Isotropic: Assumes all slds are real (no magnetic)
+ * Also assumes there is no polarization: No dependency on spin
+ */
+void genicom(GenI* this, int npoints, double *q, double *I_out){
+	//npoints is given negative for angular averaging
+	// Assumes that q doesn't have qz component and sld_n is all real
+	//double Pi = 4.0*atan(1.0);
+	int is_sym = this->n_pix < 0;
+	double qr = 0.0;
+	double sumj;
+	double sld_j = 0.0;
+	double count = 0.0;
+	int n_pix = is_sym ? -this->n_pix : this->n_pix;
+	//Assume that pixel volumes are given in vol_pix in A^3 unit
+	// Loop over q-values and multiply apply matrix
+	for(int i=0; i<npoints; i++){
+		sumj =0.0;
+		for(int j=0; j<n_pix; j++){
+			//Isotropic: Assumes all slds are real (no magnetic)
+			//Also assumes there is no polarization: No dependency on spin
+			if (is_sym == 1){
+				// approximation for a spherical symmetric particle
+				qr = sqrt(this->x_val[j]*this->x_val[j]+this->y_val[j]*this->y_val[j]+this->z_val[j]*this->z_val[j])*q[i];
+				if (qr > 0.0){
+					qr = sin(qr) / qr;
+					sumj += this->sldn_val[j] * this->vol_pix[j] * qr;
+				}
+				else{
+					sumj += this->sldn_val[j] * this->vol_pix[j];
+				}
+			}
+			else{
+				//full calculation
+				//pragma omp parallel for
+				for(int k=0; k<n_pix; k++){
+					sld_j =  this->sldn_val[j] * this->sldn_val[k] * this->vol_pix[j] * this->vol_pix[k];
+					qr = (this->x_val[j]-this->x_val[k])*(this->x_val[j]-this->x_val[k])+
+						      (this->y_val[j]-this->y_val[k])*(this->y_val[j]-this->y_val[k])+
+						      (this->z_val[j]-this->z_val[k])*(this->z_val[j]-this->z_val[k]);
+					qr = sqrt(qr) * q[i];
+					if (qr > 0.0){
+						sumj += sld_j*sin(qr)/qr;
+					}
+					else{
+						sumj += sld_j;
+					}
+				}
+			}
+			if (i == 0){
+				count += this->vol_pix[j];
+			}
+		}
+		I_out[i] = sumj;
+		if (is_sym == 1){
+			I_out[i] *= sumj;
+		}
+		I_out[i] *= (1.0E+8 / count); //in cm (unit) / number; //to be multiplied by vol_pix
+	}
+	//printf ("count = %d %g %g %g %g\n", count, sldn_val[0],mx_val[0], my_val[0], mz_val[0]);
+}
Index: src/sas/sascalc/calculator/c_extensions/sld2i.cpp
===================================================================
--- src/sas/sascalc/calculator/c_extensions/sld2i.cpp	(revision b523c0e4093c0c8e82cebd10672473d88adeaee9)
+++ 	(revision )
@@ -1,210 +1,0 @@
-/**
-Computes the (magnetic) scattering form sld (n and m) profile
- */
-#include "sld2i.hh"
-#include <stdio.h>
-#include <math.h>
-using namespace std;
-extern "C" {
-	#include "libfunc.h"
-	#include "librefl.h"
-}
-/**
- * Constructor for GenI
- *
- * binning
- * //@param qx: array of Qx values
- * //@param qy: array of Qy values
- * //@param qz: array of Qz values
- * @param x: array of x values
- * @param y: array of y values
- * @param z: array of z values
- * @param sldn: array of sld n
- * @param mx: array of sld mx
- * @param my: array of sld my
- * @param mz: array of sld mz
- * @param in_spin: ratio of up spin in Iin
- * @param out_spin: ratio of up spin in Iout
- * @param s_theta: angle (from x-axis) of the up spin in degree
- */
-GenI :: GenI(int npix, double* x, double* y, double* z, double* sldn,
-			double* mx, double* my, double* mz, double* voli,
-			double in_spin, double out_spin,
-			double s_theta) {
-	//this->qx_val = qx;
-	//this->qy_val = qy;
-	//this->qz_val = qz;
-	this->n_pix = npix;
-	this->x_val = x;
-	this->y_val = y;
-	this->z_val = z;
-	this->sldn_val = sldn;
-	this->mx_val = mx;
-	this->my_val = my;
-	this->mz_val = mz;
-	this->vol_pix = voli;
-	this->inspin = in_spin;
-	this->outspin = out_spin;
-	this->stheta = s_theta;
-};
-
-/**
- * Compute 2D anisotropic
- */
-void GenI :: genicomXY(int npoints, double *qx, double *qy, double *I_out){
-	//npoints is given negative for angular averaging 
-	// Assumes that q doesn't have qz component and sld_n is all real
-	//double q = 0.0;
-	//double Pi = 4.0*atan(1.0);
-	polar_sld b_sld;
-	double qr = 0.0;
-	complex iqr = cassign(0.0, 0.0);
-	complex ephase = cassign(0.0, 0.0);
-	complex comp_sld = cassign(0.0, 0.0);
-
-	complex sumj_uu;
-	complex sumj_ud;
-	complex sumj_du;
-	complex sumj_dd;
-	complex temp_fi;
-
-	double count = 0.0;
-	//check if this computation is for averaging
-
-	//Assume that pixel volumes are given in vol_pix in A^3 unit
-	//int x_size = 0; //in Ang
-	//int y_size = 0; //in Ang
-	//int z_size = 0; //in Ang
-	
-	// Loop over q-values and multiply apply matrix
-	
-	for(int i=0; i<npoints; i++){
-		//I_out[i] = 0.0;
-		sumj_uu = cassign(0.0, 0.0);
-		sumj_ud = cassign(0.0, 0.0);
-		sumj_du = cassign(0.0, 0.0);
-		sumj_dd = cassign(0.0, 0.0);		
-		//printf ("%d ", i);
-		//q = sqrt(qx[i]*qx[i] + qy[i]*qy[i]); // + qz[i]*qz[i]);
-
-		for(int j=0; j<n_pix; j++){
-			if (sldn_val[j]!=0.0||mx_val[j]!=0.0||my_val[j]!=0.0||mz_val[j]!=0.0)
-			{	
-				//anisotropic
-				temp_fi = cassign(0.0, 0.0);
-				b_sld = cal_msld(0, qx[i], qy[i], sldn_val[j],
-							 mx_val[j], my_val[j], mz_val[j],
-			 				 inspin, outspin, stheta);
-				qr = (qx[i]*x_val[j] + qy[i]*y_val[j]);
-				iqr = cassign(0.0, qr);
-				ephase = cplx_exp(iqr);
-				
-				//Let's multiply pixel(atomic) volume here
-				ephase = rcmult(vol_pix[j], ephase);
-				//up_up
-				if (inspin > 0.0 && outspin > 0.0){
-					comp_sld = cassign(b_sld.uu, 0.0);
-					temp_fi = cplx_mult(comp_sld, ephase);
-					sumj_uu = cplx_add(sumj_uu, temp_fi);
-				}
-				//down_down
-				if (inspin < 1.0 && outspin < 1.0){
-					comp_sld = cassign(b_sld.dd, 0.0);
-					temp_fi = cplx_mult(comp_sld, ephase);
-					sumj_dd = cplx_add(sumj_dd, temp_fi);
-				}
-				//up_down
-				if (inspin > 0.0 && outspin < 1.0){
-					comp_sld = cassign(b_sld.re_ud, b_sld.im_ud);
-					temp_fi = cplx_mult(comp_sld, ephase);
-					sumj_ud = cplx_add(sumj_ud, temp_fi);
-				}
-				//down_up
-				if (inspin < 1.0 && outspin > 0.0){
-					comp_sld = cassign(b_sld.re_du, b_sld.im_du);
-					temp_fi = cplx_mult(comp_sld, ephase);
-					sumj_du = cplx_add(sumj_du, temp_fi);
-				}
-
-
-				if (i == 0){
-					count += vol_pix[j];
-				}
-			}
-		}
-		//printf("aa%d=%g %g %d\n", i, (sumj_uu.re*sumj_uu.re + sumj_uu.im*sumj_uu.im), (sumj_dd.re*sumj_dd.re + sumj_dd.im*sumj_dd.im), count);
-
-		I_out[i] = (sumj_uu.re*sumj_uu.re + sumj_uu.im*sumj_uu.im);
-		I_out[i] += (sumj_ud.re*sumj_ud.re + sumj_ud.im*sumj_ud.im);
-		I_out[i] += (sumj_du.re*sumj_du.re + sumj_du.im*sumj_du.im);
-		I_out[i] += (sumj_dd.re*sumj_dd.re + sumj_dd.im*sumj_dd.im);
-
-		I_out[i] *= (1.0E+8 / count); //in cm (unit) / number; //to be multiplied by vol_pix
-	}
-	//printf ("count = %d %g %g %g %g\n", count, sldn_val[0],mx_val[0], my_val[0], mz_val[0]);
-}
-/**
- * Compute 1D isotropic
- * Isotropic: Assumes all slds are real (no magnetic)
- * Also assumes there is no polarization: No dependency on spin
- */
-void GenI :: genicom(int npoints, double *q, double *I_out){
-	//npoints is given negative for angular averaging 
-	// Assumes that q doesn't have qz component and sld_n is all real
-	//double Pi = 4.0*atan(1.0);
-	int is_sym = 0;
-	double qr = 0.0;
-	double sumj;
-	double sld_j = 0.0;
-	double count = 0.0;
-	if (n_pix < 0 ){
-		is_sym = 1;
-		n_pix = n_pix * -1;
-	}
-	//Assume that pixel volumes are given in vol_pix in A^3 unit
-	// Loop over q-values and multiply apply matrix
-	for(int i=0; i<npoints; i++){
-		sumj =0.0;		
-		for(int j=0; j<n_pix; j++){
-			//Isotropic: Assumes all slds are real (no magnetic)
-			//Also assumes there is no polarization: No dependency on spin
-			if (is_sym == 1){
-				// approximation for a spherical symmetric particle
-				qr = sqrt(x_val[j]*x_val[j]+y_val[j]*y_val[j]+z_val[j]*z_val[j])*q[i];
-				if (qr > 0.0){
-					qr = sin(qr) / qr;
-					sumj += sldn_val[j] * vol_pix[j] * qr;
-				}
-				else{
-					sumj += sldn_val[j] * vol_pix[j];
-				}
-			}
-			else{
-				//full calculation
-				//pragma omp parallel for
-				for(int k=0; k<n_pix; k++){
-					sld_j =  sldn_val[j] * sldn_val[k] * vol_pix[j] * vol_pix[k];
-					qr = (x_val[j]-x_val[k])*(x_val[j]-x_val[k])+
-						      (y_val[j]-y_val[k])*(y_val[j]-y_val[k])+ 
-						      (z_val[j]-z_val[k])*(z_val[j]-z_val[k]);
-					qr = sqrt(qr) * q[i];
-					if (qr > 0.0){
-						sumj += sld_j*sin(qr)/qr;
-					}
-					else{
-						sumj += sld_j;
-					}
-				}
-			}
-			if (i == 0){
-				count += vol_pix[j];
-			}
-		}
-		I_out[i] = sumj;
-		if (is_sym == 1){
-			I_out[i] *= sumj;
-		}
-		I_out[i] *= (1.0E+8 / count); //in cm (unit) / number; //to be multiplied by vol_pix
-	}
-	//printf ("count = %d %g %g %g %g\n", count, sldn_val[0],mx_val[0], my_val[0], mz_val[0]);
-}
Index: src/sas/sascalc/calculator/c_extensions/sld2i.h
===================================================================
--- src/sas/sascalc/calculator/c_extensions/sld2i.h	(revision 0957bb3ad795897233168bbc11756fd9ff98f8b1)
+++ src/sas/sascalc/calculator/c_extensions/sld2i.h	(revision 0957bb3ad795897233168bbc11756fd9ff98f8b1)
@@ -0,0 +1,36 @@
+/**
+Computes the (magnetic) scattering form sld (n and m) profile
+ */
+#ifndef SLD2I_CLASS_H
+#define SLD2I_CLASS_H
+
+/**
+ * Base class
+ */
+typedef struct {
+	// vectors
+	int n_pix;
+	double* x_val;
+	double* y_val;
+	double* z_val;
+	double* sldn_val;
+	double* mx_val;
+	double* my_val;
+	double* mz_val;
+	double* vol_pix;
+    // spin ratios
+    double inspin;
+    double outspin;
+    double stheta;
+} GenI;
+
+// Constructor
+void initGenI(GenI*, int npix, double* x, double* y, double* z, double* sldn,
+		double* mx, double* my, double* mz, double* voli,
+		double in_spin, double out_spin,
+		double s_theta);
+// compute function
+void genicomXY(GenI*, int npoints, double* qx, double* qy, double *I_out);
+void genicom(GenI*, int npoints, double* q, double *I_out);
+
+#endif
Index: src/sas/sascalc/calculator/c_extensions/sld2i.hh
===================================================================
--- src/sas/sascalc/calculator/c_extensions/sld2i.hh	(revision 4c29e4db880ce15b4400de7af0865fa99a32fe16)
+++ 	(revision )
@@ -1,45 +1,0 @@
-/**
-Computes the (magnetic) scattering form sld (n and m) profile
- */
-#ifndef SLD2I_CLASS_H
-#define SLD2I_CLASS_H
-
-#include <vector>
-
-using namespace std;
-
-/**
- * Base class
- */
-class GenI {
-protected:
-	vector<double>* I_out;
-	// vectors
-	int n_pix;
-	double* qx;
-	double* qy;
-	double* x_val;
-	double* y_val;
-	double* z_val;
-	double* sldn_val;
-	double* mx_val;
-	double* my_val;
-	double* mz_val;
-	double* vol_pix;
-    // spin ratios
-    double inspin;
-    double outspin;
-    double stheta;
-
-public:
-    // Constructor
-	GenI(int npix, double* x, double* y, double* z, double* sldn, 
-			double* mx, double* my, double* mz, double* voli,
-			double in_spin, double out_spin,
-			double s_theta);
-	// compute function
-	void genicomXY(int npoints, double* qx, double* qy, double *I_out);
-	void genicom(int npoints, double* q, double *I_out);
-};
-
-#endif
Index: src/sas/sascalc/calculator/c_extensions/sld2i_module.c
===================================================================
--- src/sas/sascalc/calculator/c_extensions/sld2i_module.c	(revision 0957bb3ad795897233168bbc11756fd9ff98f8b1)
+++ src/sas/sascalc/calculator/c_extensions/sld2i_module.c	(revision 0957bb3ad795897233168bbc11756fd9ff98f8b1)
@@ -0,0 +1,202 @@
+/**
+  SLD2I module to perform point and I calculations
+ */
+#include <Python.h>
+#include <stdio.h>
+#include <sld2i.h>
+
+#if PY_MAJOR_VERSION < 3
+typedef void (*PyCapsule_Destructor)(PyObject *);
+typedef void (*PyCObject_Destructor)(void *);
+#define PyCapsule_New(pointer, name, destructor) (PyCObject_FromVoidPtr(pointer, (PyCObject_Destructor)destructor))
+#define PyCapsule_GetPointer(capsule, name) (PyCObject_AsVoidPtr(capsule))
+#endif
+
+
+// Utilities
+#define INVECTOR(obj,buf,len)										\
+    do { \
+        int err = PyObject_AsReadBuffer(obj, (const void **)(&buf), &len); \
+        if (err < 0) return NULL; \
+        len /= sizeof(*buf); \
+    } while (0)
+
+#define OUTVECTOR(obj,buf,len) \
+    do { \
+        int err = PyObject_AsWriteBuffer(obj, (void **)(&buf), &len); \
+        if (err < 0) return NULL; \
+        len /= sizeof(*buf); \
+    } while (0)
+
+
+/**
+ * Delete a GenI object
+ */
+void
+del_sld2i(PyObject *obj){
+	GenI* sld2i = (GenI *)(PyCapsule_GetPointer(obj, "GenI"));
+	PyMem_Free((void *)sld2i);
+}
+
+/**
+ * Create a GenI as a python object by supplying arrays
+ */
+PyObject * new_GenI(PyObject *self, PyObject *args) {
+	PyObject *x_val_obj;
+	PyObject *y_val_obj;
+	PyObject *z_val_obj;
+	PyObject *sldn_val_obj;
+	PyObject *mx_val_obj;
+	PyObject *my_val_obj;
+	PyObject *mz_val_obj;
+	PyObject *vol_pix_obj;
+	Py_ssize_t n_x;
+	//PyObject rlimit_obj;
+	//PyObject npoints_obj;
+	//PyObject nrbins_obj;
+	//PyObject nphibins_obj;
+	int n_pix;
+	double* x_val;
+	double* y_val;
+	double* z_val;
+	double* sldn_val;
+	double* mx_val;
+	double* my_val;
+	double* mz_val;
+	double* vol_pix;
+	double inspin;
+	double outspin;
+	double stheta;
+
+	if (!PyArg_ParseTuple(args, "iOOOOOOOOddd", &n_pix, &x_val_obj, &y_val_obj, &z_val_obj, &sldn_val_obj, &mx_val_obj, &my_val_obj, &mz_val_obj, &vol_pix_obj, &inspin, &outspin, &stheta)) return NULL;
+	OUTVECTOR(x_val_obj, x_val, n_x);
+	OUTVECTOR(y_val_obj, y_val, n_x);
+	OUTVECTOR(z_val_obj, z_val, n_x);
+	OUTVECTOR(sldn_val_obj, sldn_val, n_x);
+	OUTVECTOR(mx_val_obj, mx_val, n_x);
+	OUTVECTOR(my_val_obj, my_val, n_x);
+	OUTVECTOR(mz_val_obj, mz_val, n_x);
+	OUTVECTOR(vol_pix_obj, vol_pix, n_x);
+	GenI* sld2i =  PyMem_Malloc(sizeof(GenI));
+	if (sld2i != NULL) {
+		initGenI(sld2i, n_pix,x_val,y_val,z_val,sldn_val,mx_val,my_val,mz_val,vol_pix,inspin,outspin,stheta);
+	}
+	return PyCapsule_New(sld2i, "GenI", del_sld2i);
+}
+
+/**
+ * GenI the given input (2D) according to a given object
+ */
+PyObject * genicom_inputXY(PyObject *self, PyObject *args) {
+	int npoints;
+	PyObject *qx_obj;
+	double *qx;
+	PyObject *qy_obj;
+	double *qy;
+	PyObject *I_out_obj;
+	Py_ssize_t n_out;
+	double *I_out;
+	PyObject *gen_obj;
+
+	if (!PyArg_ParseTuple(args, "OiOOO",  &gen_obj, &npoints, &qx_obj, &qy_obj, &I_out_obj)) return NULL;
+	OUTVECTOR(qx_obj, qx, n_out);
+	OUTVECTOR(qy_obj, qy, n_out);
+	OUTVECTOR(I_out_obj, I_out, n_out);
+
+	// Sanity check
+	//if(n_in!=n_out) return Py_BuildValue("i",-1);
+
+	// Set the array pointers
+	GenI* sld2i = (GenI *)PyCapsule_GetPointer(gen_obj, "GenI");
+
+	genicomXY(sld2i, npoints, qx, qy, I_out);
+	//return PyCObject_FromVoidPtr(s, del_genicom);
+	return Py_BuildValue("i",1);
+}
+
+/**
+ * GenI the given 1D input according to a given object
+ */
+PyObject * genicom_input(PyObject *self, PyObject *args) {
+	int npoints;
+	PyObject *q_obj;
+	double *q;
+	PyObject *I_out_obj;
+	Py_ssize_t n_out;
+	double *I_out;
+	PyObject *gen_obj;
+
+	if (!PyArg_ParseTuple(args, "OiOO",  &gen_obj, &npoints, &q_obj, &I_out_obj)) return NULL;
+	OUTVECTOR(q_obj, q, n_out);
+	OUTVECTOR(I_out_obj, I_out, n_out);
+
+	// Sanity check
+	//if(n_in!=n_out) return Py_BuildValue("i",-1);
+
+	// Set the array pointers
+	GenI *sld2i = (GenI *)PyCapsule_GetPointer(gen_obj, "GenI");
+
+	genicom(sld2i, npoints, q, I_out);
+	//return PyCObject_FromVoidPtr(s, del_genicom);
+	return Py_BuildValue("i",1);
+}
+
+/**
+ * Define module methods
+ */
+static PyMethodDef module_methods[] = {
+	{"new_GenI", (PyCFunction)new_GenI, METH_VARARGS,
+		  "Create a new GenI object"},
+	{"genicom",(PyCFunction)genicom_input, METH_VARARGS,
+		  "genicom the given 1d input arrays"},
+	{"genicomXY",(PyCFunction)genicom_inputXY, METH_VARARGS,
+		  "genicomXY the given 2d input arrays"},
+    {NULL}
+};
+
+#define MODULE_DOC "Sld2i C Library"
+#define MODULE_NAME "sld2i"
+#define MODULE_INIT2 initsld2i
+#define MODULE_INIT3 PyInit_sld2i
+#define MODULE_METHODS module_methods
+
+/* ==== boilerplate python 2/3 interface bootstrap ==== */
+
+
+#if defined(WIN32) && !defined(__MINGW32__)
+    #define DLL_EXPORT __declspec(dllexport)
+#else
+    #define DLL_EXPORT
+#endif
+
+#if PY_MAJOR_VERSION >= 3
+
+  DLL_EXPORT PyMODINIT_FUNC MODULE_INIT3(void)
+  {
+    static struct PyModuleDef moduledef = {
+      PyModuleDef_HEAD_INIT,
+      MODULE_NAME,         /* m_name */
+      MODULE_DOC,          /* m_doc */
+      -1,                  /* m_size */
+      MODULE_METHODS,      /* m_methods */
+      NULL,                /* m_reload */
+      NULL,                /* m_traverse */
+      NULL,                /* m_clear */
+      NULL,                /* m_free */
+    };
+    return PyModule_Create(&moduledef);
+  }
+
+#else /* !PY_MAJOR_VERSION >= 3 */
+
+  DLL_EXPORT PyMODINIT_FUNC MODULE_INIT2(void)
+  {
+    Py_InitModule4(MODULE_NAME,
+		 MODULE_METHODS,
+		 MODULE_DOC,
+		 0,
+		 PYTHON_API_VERSION
+		 );
+  }
+
+#endif /* !PY_MAJOR_VERSION >= 3 */
Index: src/sas/sascalc/calculator/c_extensions/sld2i_module.cpp
===================================================================
--- src/sas/sascalc/calculator/c_extensions/sld2i_module.cpp	(revision 1d014cbb271bb612a92607b84c582f19f50b2b11)
+++ 	(revision )
@@ -1,202 +1,0 @@
-/**
-  SLD2I module to perform point and I calculations
- */
-#include <Python.h>
-#include <stdio.h>
-#include <sld2i.hh>
-
-#if PY_MAJOR_VERSION < 3
-typedef void (*PyCapsule_Destructor)(PyObject *);
-typedef void (*PyCObject_Destructor)(void *);
-#define PyCapsule_New(pointer, name, destructor) (PyCObject_FromVoidPtr(pointer, (PyCObject_Destructor)destructor))
-#define PyCapsule_GetPointer(capsule, name) (PyCObject_AsVoidPtr(capsule))
-#endif
-
-
-// Utilities
-#define INVECTOR(obj,buf,len)										\
-    do { \
-        int err = PyObject_AsReadBuffer(obj, (const void **)(&buf), &len); \
-        if (err < 0) return NULL; \
-        len /= sizeof(*buf); \
-    } while (0)
-
-#define OUTVECTOR(obj,buf,len) \
-    do { \
-        int err = PyObject_AsWriteBuffer(obj, (void **)(&buf), &len); \
-        if (err < 0) return NULL; \
-        len /= sizeof(*buf); \
-    } while (0)
-
-
-/**
- * Delete a GenI object
- */
-void
-del_sld2i(PyObject *obj){
-	GenI* sld2i = static_cast<GenI *>(PyCapsule_GetPointer(obj, "GenI"));
-	delete sld2i;
-	return;
-}
-
-/**
- * Create a GenI as a python object by supplying arrays
- */
-PyObject * new_GenI(PyObject *, PyObject *args) {
-	PyObject *x_val_obj;
-	PyObject *y_val_obj;
-	PyObject *z_val_obj;
-	PyObject *sldn_val_obj;
-	PyObject *mx_val_obj;
-	PyObject *my_val_obj;
-	PyObject *mz_val_obj;
-	PyObject *vol_pix_obj;
-	Py_ssize_t n_x;
-	//PyObject rlimit_obj;
-	//PyObject npoints_obj;
-	//PyObject nrbins_obj;
-	//PyObject nphibins_obj;
-	int n_pix;
-	double* x_val;
-	double* y_val;
-	double* z_val;
-	double* sldn_val;
-	double* mx_val;
-	double* my_val;
-	double* mz_val;
-	double* vol_pix;
-	double inspin;
-	double outspin;
-	double stheta;
-
-	if (!PyArg_ParseTuple(args, "iOOOOOOOOddd", &n_pix, &x_val_obj, &y_val_obj, &z_val_obj, &sldn_val_obj, &mx_val_obj, &my_val_obj, &mz_val_obj, &vol_pix_obj, &inspin, &outspin, &stheta)) return NULL;
-	OUTVECTOR(x_val_obj, x_val, n_x);
-	OUTVECTOR(y_val_obj, y_val, n_x);
-	OUTVECTOR(z_val_obj, z_val, n_x);
-	OUTVECTOR(sldn_val_obj, sldn_val, n_x);
-	OUTVECTOR(mx_val_obj, mx_val, n_x);
-	OUTVECTOR(my_val_obj, my_val, n_x);
-	OUTVECTOR(mz_val_obj, mz_val, n_x);
-	OUTVECTOR(vol_pix_obj, vol_pix, n_x);
-	GenI* sld2i = new GenI(n_pix,x_val,y_val,z_val,sldn_val,mx_val,my_val,mz_val,vol_pix,inspin,outspin,stheta);
-	return PyCapsule_New(sld2i, "GenI", del_sld2i);
-}
-
-/**
- * GenI the given input (2D) according to a given object
- */
-PyObject * genicom_inputXY(PyObject *, PyObject *args) {
-	int npoints;
-	PyObject *qx_obj;
-	double *qx;
-	PyObject *qy_obj;
-	double *qy;
-	PyObject *I_out_obj;
-	Py_ssize_t n_out;
-	double *I_out;
-	PyObject *gen_obj;
-
-	if (!PyArg_ParseTuple(args, "OiOOO",  &gen_obj, &npoints, &qx_obj, &qy_obj, &I_out_obj)) return NULL;
-	OUTVECTOR(qx_obj, qx, n_out);
-	OUTVECTOR(qy_obj, qy, n_out);
-	OUTVECTOR(I_out_obj, I_out, n_out);
-
-	// Sanity check
-	//if(n_in!=n_out) return Py_BuildValue("i",-1);
-
-	// Set the array pointers
-	void *temp = PyCapsule_GetPointer(gen_obj, "GenI");
-	GenI* s = static_cast<GenI *>(temp);
-
-	s->genicomXY(npoints, qx, qy, I_out);
-	//return PyCObject_FromVoidPtr(s, del_genicom);
-	return Py_BuildValue("i",1);
-}
-
-/**
- * GenI the given 1D input according to a given object
- */
-PyObject * genicom_input(PyObject *, PyObject *args) {
-	int npoints;
-	PyObject *q_obj;
-	double *q;
-	PyObject *I_out_obj;
-	Py_ssize_t n_out;
-	double *I_out;
-	PyObject *gen_obj;
-
-	if (!PyArg_ParseTuple(args, "OiOO",  &gen_obj, &npoints, &q_obj, &I_out_obj)) return NULL;
-	OUTVECTOR(q_obj, q, n_out);
-	OUTVECTOR(I_out_obj, I_out, n_out);
-
-	// Sanity check
-	//if(n_in!=n_out) return Py_BuildValue("i",-1);
-
-	// Set the array pointers
-	void *temp = PyCapsule_GetPointer(gen_obj, "GenI");
-	GenI* s = static_cast<GenI *>(temp);
-
-	s->genicom(npoints, q, I_out);
-	//return PyCObject_FromVoidPtr(s, del_genicom);
-	return Py_BuildValue("i",1);
-}
-
-/**
- * Define module methods
- */
-static PyMethodDef module_methods[] = {
-	{"new_GenI", (PyCFunction)new_GenI, METH_VARARGS,
-		  "Create a new GenI object"},
-	{"genicom",(PyCFunction)genicom_input, METH_VARARGS,
-		  "genicom the given 1d input arrays"},
-	{"genicomXY",(PyCFunction)genicom_inputXY, METH_VARARGS,
-		  "genicomXY the given 2d input arrays"},
-    {NULL}
-};
-
-#define MODULE_DOC "Sld2i C Library"
-#define MODULE_NAME "sld2i"
-#define MODULE_INIT2 initsld2i
-#define MODULE_INIT3 PyInit_sld2i
-#define MODULE_METHODS module_methods
-
-/* ==== boilerplate python 2/3 interface bootstrap ==== */
-
-
-#if defined(WIN32) && !defined(__MINGW32__)
-    #define DLL_EXPORT __declspec(dllexport)
-#else
-    #define DLL_EXPORT
-#endif
-
-#if PY_MAJOR_VERSION >= 3
-
-  DLL_EXPORT PyMODINIT_FUNC MODULE_INIT3(void)
-  {
-    static struct PyModuleDef moduledef = {
-      PyModuleDef_HEAD_INIT,
-      MODULE_NAME,         /* m_name */
-      MODULE_DOC,          /* m_doc */
-      -1,                  /* m_size */
-      MODULE_METHODS,      /* m_methods */
-      NULL,                /* m_reload */
-      NULL,                /* m_traverse */
-      NULL,                /* m_clear */
-      NULL,                /* m_free */
-    };
-    return PyModule_Create(&moduledef);
-  }
-
-#else /* !PY_MAJOR_VERSION >= 3 */
-
-  DLL_EXPORT PyMODINIT_FUNC MODULE_INIT2(void)
-  {
-    Py_InitModule4(MODULE_NAME,
-		 MODULE_METHODS,
-		 MODULE_DOC,
-		 0,
-		 PYTHON_API_VERSION
-		 );
-  }
-
-#endif /* !PY_MAJOR_VERSION >= 3 */
