Index: sansmodels/src/sans/models/BaseComponent.py
===================================================================
--- sansmodels/src/sans/models/BaseComponent.py	(revision 83a25dab0638401b2f766f5995098b5d775ea28e)
+++ sansmodels/src/sans/models/BaseComponent.py	(revision 26e4a247fb629283560bcebfc702766d91e89b16)
@@ -72,5 +72,5 @@
         q_array = numpy.asarray(qdist)
         iq_array = numpy.zeros(len(q_array))
-        for i in len(q_array):
+        for i in xrange(len(q_array)):
             iq_array[i] = self.runXY(q_array[i])
             
Index: sansmodels/src/sans/models/DebyeModel.py
===================================================================
--- sansmodels/src/sans/models/DebyeModel.py	(revision d37ba31f90770e95e2b80c5999a7c2c4b4b82acd)
+++ sansmodels/src/sans/models/DebyeModel.py	(revision 26e4a247fb629283560bcebfc702766d91e89b16)
@@ -64,9 +64,9 @@
         # an exception
         y = (x * self.params['rg'])**2.0
-        if y == 0:
-            return 1e+16
+        if x == 0:
+            D=1
         else:
-            D = 2.0*( math.exp(-y) + y -1.0 )/y**2.0
-            return self.params['scale']* D + self.params['background']
+           D = 2.0*( math.exp(-y) + y -1.0 )/y**2.0
+        return self.params['scale']* D + self.params['background']
    
     def run(self, x = 0.0):
Index: sansmodels/src/sans/models/c_extensions/elliptical_cylinder.h
===================================================================
--- sansmodels/src/sans/models/c_extensions/elliptical_cylinder.h	(revision 1ed3834d2e968f8ff632d0b368f55ac28174df7a)
+++ sansmodels/src/sans/models/c_extensions/elliptical_cylinder.h	(revision 26e4a247fb629283560bcebfc702766d91e89b16)
@@ -7,5 +7,6 @@
  * [DESCRIPTION] = Please see details...
  * [FIXED]= <text> cyl_phi.width;
- * cyl_theta.width; cyl_psi.width; length.width; r_minor.width; r_ratio.width </text>
+ * cyl_theta.width; cyl_psi.width; length.width; r_minor.width; r_ratio.width 
+ *</text>
  * [ORIENTATION_PARAMS]= cyl_phi; cyl_theta; cyl_psi;  cyl_phi.width; cyl_theta.width; cyl_psi.width
  * */
Index: sansmodels/src/sans/models/c_models/classTemplate.txt
===================================================================
--- sansmodels/src/sans/models/c_models/classTemplate.txt	(revision 8344c5029e4ed7f30ffef7c8d0d06ee7cfa35ff2)
+++ sansmodels/src/sans/models/c_models/classTemplate.txt	(revision 26e4a247fb629283560bcebfc702766d91e89b16)
@@ -149,41 +149,5 @@
     return PyArray_Return(result); 
  }
-/**
- * Function to call to evaluate model
- * @param args: input numpy array  [q[],phi[]]
- * @return: numpy array object 
- */
-static PyObject * evaluateTwoDim( [CMODEL]* model, 
-                              PyArrayObject *q, PyArrayObject *phi)
- {
-    PyArrayObject *result;
-    //check validity of input vectors
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE
-        || phi->nd != 1 || phi->descr->type_num != PyArray_DOUBLE
-        || phi->dimensions[0] != q->dimensions[0]){
-     
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        PyErr_SetString(PyExc_ValueError ,"wrong input"); 
-        return NULL;
-    }
-	result= (PyArrayObject *)PyArray_FromDims(q->nd,(int*)(q->dimensions), PyArray_DOUBLE);
-
-	if (result == NULL){
-	    const char * message= "Could not create result ";
-        PyErr_SetString(PyExc_RuntimeError , message);
-	    return NULL;
-	}
-	
-    for (int i = 0; i < q->dimensions[0]; i++) {
-      double q_value = *(double *)(q->data + i*q->strides[0]);
-      double phi_value = *(double *)(phi->data + i*phi->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      if (q_value == 0)
-          *result_value = 0.0;
-      else
-          *result_value = model->evaluate_rphi(q_value, phi_value);
-    }
-    return PyArray_Return(result); 
- }
+
  /**
  * Function to call to evaluate model
Index: sansmodels/src/sans/models/test/utest_dispersity.py
===================================================================
--- sansmodels/src/sans/models/test/utest_dispersity.py	(revision eba988511d86410985b5a1c35ce70dd3968132a8)
+++ sansmodels/src/sans/models/test/utest_dispersity.py	(revision 26e4a247fb629283560bcebfc702766d91e89b16)
@@ -57,34 +57,6 @@
         
         new_model = self.model.clone()
-        print "gaussian",self.model.run(0.001)
         self.assertAlmostEqual(new_model.run(0.001), 4723.32213339, 3)
         self.assertAlmostEqual(new_model.runXY([0.001,0.001]), 4743.56, 2)
-        
-    def test_schulz_zero(self):
-        from sans.models.dispersion_models import SchulzDispersion
-        disp = SchulzDispersion()
-        self.model.set_dispersion('radius', disp)
-        self.model.dispersion['radius']['width'] = 5.0
-        #self.model.dispersion['radius']['width'] = 0.0
-        self.model.dispersion['radius']['npts'] = 100
-        #self.model.setParam('scale', 1.0)
-        self.model.setParam('scale', 10.0)
-        print "schulz",self.model.run(0.001), self.model.dispersion
-        self.assertAlmostEqual(self.model.run(0.001), 450.355, 3)
-        self.assertAlmostEqual(self.model.runXY([0.001,0.001]), 452.299, 3)
-        
-    def test_lognormal_zero(self):
-        from sans.models.dispersion_models import LogNormalDispersion
-        disp = LogNormalDispersion()
-        self.model.set_dispersion('radius', disp)
-        self.model.dispersion['radius']['width'] = 5.0
-        #self.model.dispersion['radius']['width'] = 0.0
-        self.model.dispersion['radius']['npts'] = 100
-        #self.model.setParam('scale', 1.0)
-        self.model.setParam('scale', 10.0)
-        print "model dispersion",self.model.dispersion
-        print "lognormal",self.model.run(0.001)
-        self.assertAlmostEqual(self.model.run(0.001), 450.355, 3)
-        self.assertAlmostEqual(self.model.runXY([0.001,0.001]), 452.299, 3)
         
     def test_gaussian_zero(self):
Index: sansmodels/src/sans/models/test/utest_models.py
===================================================================
--- sansmodels/src/sans/models/test/utest_models.py	(revision eba988511d86410985b5a1c35ce70dd3968132a8)
+++ sansmodels/src/sans/models/test/utest_models.py	(revision 26e4a247fb629283560bcebfc702766d91e89b16)
@@ -24,9 +24,9 @@
     def test1D(self):
         """ Test 1D model for a sphere """
-        self.assertAlmostEqual(self.comp.run(1.0), 5.6387e-5, 4)
+        self.assertAlmostEqual(self.comp.run(1.0), 56.3878, 4)
         
     def test1D_2(self):
         """ Test 2D model for a sphere """
-        self.assertAlmostEqual(self.comp.run([1.0, 1.3]), 5.63878e-5, 4)
+        self.assertAlmostEqual(self.comp.run([1.0, 1.3]), 56.3878, 4)
 
 class TestCyl(unittest.TestCase):
Index: sansmodels/src/sans/models/test/utest_other_dispersity.py
===================================================================
--- sansmodels/src/sans/models/test/utest_other_dispersity.py	(revision 26e4a247fb629283560bcebfc702766d91e89b16)
+++ sansmodels/src/sans/models/test/utest_other_dispersity.py	(revision 26e4a247fb629283560bcebfc702766d91e89b16)
@@ -0,0 +1,132 @@
+"""
+    Unit tests for dispersion functionality of 
+    C++ model classes
+"""
+
+import unittest, math, numpy
+
+class TestCylinder(unittest.TestCase):
+    """
+        Testing C++ Cylinder model
+    """
+    def setUp(self):
+        from sans.models.CylinderModel import CylinderModel
+        self.model= CylinderModel()
+        
+        self.model.setParam('scale', 1.0)
+        self.model.setParam('radius', 20.0)
+        self.model.setParam('length', 400.0)
+        self.model.setParam('contrast', 3.e-6)
+        self.model.setParam('background', 0.0)
+        self.model.setParam('cyl_theta', 0.0)
+        self.model.setParam('cyl_phi', 0.0)
+        
+    def test_simple(self):
+        self.assertAlmostEqual(self.model.run(0.001), 450.355, 3)
+        self.assertAlmostEqual(self.model.runXY([0.001,0.001]), 452.299, 3)
+        
+    def test_constant(self):
+        from sans.models.dispersion_models import DispersionModel
+        disp = DispersionModel()
+        self.model.setParam('scale', 10.0)
+        self.model.set_dispersion('radius', disp)
+        self.model.dispersion['radius']['width'] = 5.0
+        self.model.dispersion['radius']['npts'] = 100
+        
+        self.assertAlmostEqual(self.model.run(0.001), 4527.47250339, 3)
+        self.assertAlmostEqual(self.model.runXY([0.001, 0.001]), 4546.997777604715, 3)
+        
+    def test_gaussian(self):
+        from sans.models.dispersion_models import GaussianDispersion
+        disp = GaussianDispersion()
+        self.model.set_dispersion('radius', disp)
+        self.model.dispersion['radius']['width'] = 5.0
+        self.model.dispersion['radius']['npts'] = 100
+        self.model.setParam('scale', 10.0)
+        
+        self.assertAlmostEqual(self.model.run(0.001), 4723.32213339, 3)
+        self.assertAlmostEqual(self.model.runXY([0.001,0.001]), 4743.56, 2)
+        
+    def test_clone(self):
+        from sans.models.dispersion_models import GaussianDispersion
+        disp = GaussianDispersion()
+        self.model.set_dispersion('radius', disp)
+        self.model.dispersion['radius']['width'] = 5.0
+        self.model.dispersion['radius']['npts'] = 100
+        self.model.setParam('scale', 10.0)
+        
+        new_model = self.model.clone()
+        print "gaussian",self.model.run(0.001)
+        self.assertAlmostEqual(new_model.run(0.001), 4723.32213339, 3)
+        self.assertAlmostEqual(new_model.runXY([0.001,0.001]), 4743.56, 2)
+        
+    def test_schulz_zero(self):
+        from sans.models.dispersion_models import SchulzDispersion
+        disp = SchulzDispersion()
+        self.model.set_dispersion('radius', disp)
+        self.model.dispersion['radius']['width'] = 5.0
+        #self.model.dispersion['radius']['width'] = 0.0
+        self.model.dispersion['radius']['npts'] = 100
+        #self.model.setParam('scale', 1.0)
+        self.model.setParam('scale', 10.0)
+        print "schulz",self.model.run(0.001), self.model.dispersion
+        self.assertAlmostEqual(self.model.run(0.001), 450.355, 3)
+        self.assertAlmostEqual(self.model.runXY([0.001,0.001]), 452.299, 3)
+        
+    def test_lognormal_zero(self):
+        from sans.models.dispersion_models import LogNormalDispersion
+        disp = LogNormalDispersion()
+        self.model.set_dispersion('radius', disp)
+        self.model.dispersion['radius']['width'] = 5.0
+        #self.model.dispersion['radius']['width'] = 0.0
+        self.model.dispersion['radius']['npts'] = 100
+        #self.model.setParam('scale', 1.0)
+        self.model.setParam('scale', 10.0)
+        print "model dispersion",self.model.dispersion
+        print "lognormal",self.model.run(0.001)
+        self.assertAlmostEqual(self.model.run(0.001), 450.355, 3)
+        self.assertAlmostEqual(self.model.runXY([0.001,0.001]), 452.299, 3)
+        
+    def test_gaussian_zero(self):
+        from sans.models.dispersion_models import GaussianDispersion
+        disp = GaussianDispersion()
+        self.model.set_dispersion('radius', disp)
+        self.model.dispersion['radius']['width'] = 0.0
+        self.model.dispersion['radius']['npts'] = 100
+        self.model.setParam('scale', 1.0)
+        
+        self.assertAlmostEqual(self.model.run(0.001), 450.355, 3)
+        self.assertAlmostEqual(self.model.runXY([0.001,0.001]), 452.299, 3)
+        
+    def test_array(self):
+        """
+            Perform complete rotational average and
+            compare to 1D
+        """
+        from sans.models.dispersion_models import ArrayDispersion
+        disp_ph = ArrayDispersion()
+        disp_th = ArrayDispersion()
+        
+        values_ph = numpy.zeros(100)
+        values_th = numpy.zeros(100)
+        weights   = numpy.zeros(100)
+        for i in range(100):
+            values_ph[i]=(2.0*math.pi/99.0*i)
+            values_th[i]=(math.pi/99.0*i)
+            weights[i]=(1.0)
+        
+        disp_ph.set_weights(values_ph, weights)
+        disp_th.set_weights(values_th, weights)
+        
+        self.model.set_dispersion('cyl_theta', disp_th)
+        self.model.set_dispersion('cyl_phi', disp_ph)
+        
+        val_1d = self.model.run(math.sqrt(0.0002))
+        val_2d = self.model.runXY([0.01,0.01]) 
+        
+        self.assertTrue(math.fabs(val_1d-val_2d)/val_1d < 0.02)
+        
+
+if __name__ == '__main__':
+    unittest.main()
+   
