Index: sansmodels/src/c_extensions/cylinder.c
===================================================================
--- sansmodels/src/c_extensions/cylinder.c	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ 	(revision )
@@ -1,120 +1,0 @@
-/**
- * Scattering model for a cylinder
- * @author: Mathieu Doucet / UTK
- */
-
-#include "cylinder.h"
-#include <math.h>
-#include "libCylinder.h"
-#include <stdio.h>
-#include <stdlib.h>
-
-
-/**
- * Function to evaluate 1D scattering function
- * @param pars: parameters of the cylinder
- * @param q: q-value
- * @return: function value
- */
-double cylinder_analytical_1D(CylinderParameters *pars, double q) {
-	double dp[6];
-
-	// Fill paramater array
-	dp[0] = pars->scale;
-	dp[1] = pars->radius;
-	dp[2] = pars->length;
-	dp[3] = pars->sldCyl;
-	dp[4] = pars->sldSolv;
-	dp[5] = pars->background;
-
-	// Call library function to evaluate model
-	return CylinderForm(dp, q);
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the cylinder
- * @param q: q-value
- * @return: function value
- */
-double cylinder_analytical_2DXY(CylinderParameters *pars, double qx, double qy) {
-	double q;
-	q = sqrt(qx*qx+qy*qy);
-    return cylinder_analytical_2D_scaled(pars, q, qx/q, qy/q);
-}
-
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the cylinder
- * @param q: q-value
- * @param phi: angle phi
- * @return: function value
- */
-double cylinder_analytical_2D(CylinderParameters *pars, double q, double phi) {
-    return cylinder_analytical_2D_scaled(pars, q, cos(phi), sin(phi));
-}
-
-/**
- * Function to evaluate 2D scattering function
- * @param pars: parameters of the cylinder
- * @param q: q-value
- * @param q_x: q_x / q
- * @param q_y: q_y / q
- * @return: function value
- */
-double cylinder_analytical_2D_scaled(CylinderParameters *pars, double q, double q_x, double q_y) {
-	double cyl_x, cyl_y, cyl_z;
-	double q_z;
-	double alpha, vol, cos_val;
-	double answer;
-	//convert angle degree to radian
-	double pi = 4.0*atan(1.0);
-	double theta = pars->cyl_theta * pi/180.0;
-	double phi = pars->cyl_phi * pi/180.0;
-
-    // Cylinder orientation
-    cyl_x = sin(theta) * cos(phi);
-    cyl_y = sin(theta) * sin(phi);
-    cyl_z = cos(theta);
-
-    // q vector
-    q_z = 0;
-
-    // Compute the angle btw vector q and the
-    // axis of the cylinder
-    cos_val = cyl_x*q_x + cyl_y*q_y + cyl_z*q_z;
-
-    // The following test should always pass
-    if (fabs(cos_val)>1.0) {
-    	printf("cyl_ana_2D: Unexpected error: cos(alpha)>1\n");
-     	return 0;
-    }
-
-    // Note: cos(alpha) = 0 and 1 will get an
-    // undefined value from CylKernel
-	alpha = acos( cos_val );
-
-	// Call the IGOR library function to get the kernel
-	answer = CylKernel(q, pars->radius, pars->length/2.0, alpha) / sin(alpha);
-
-	// Multiply by contrast^2
-	answer *= (pars->sldCyl - pars->sldSolv)*(pars->sldCyl - pars->sldSolv);
-
-	//normalize by cylinder volume
-	//NOTE that for this (Fournet) definition of the integral, one must MULTIPLY by Vcyl
-    vol = acos(-1.0) * pars->radius * pars->radius * pars->length;
-	answer *= vol;
-
-	//convert to [cm-1]
-	answer *= 1.0e8;
-
-	//Scale
-	answer *= pars->scale;
-
-	// add in the background
-	answer += pars->background;
-
-	return answer;
-}
-
Index: sansmodels/src/c_extensions/cylinder.h
===================================================================
--- sansmodels/src/c_extensions/cylinder.h	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ sansmodels/src/c_extensions/cylinder.h	(revision dbddbf5ca23038d32d3e3e085da7bc8c67ddd7c0)
@@ -1,4 +1,6 @@
 #if !defined(cylinder_h)
 #define cylinder_h
+#include "parameters.hh"
+
 /** Structure definition for cylinder parameters
  * [PYTHONCLASS] = CylinderModel
@@ -23,41 +25,49 @@
 
  **/
-typedef struct {
-    /// Scale factor
-    //  [DEFAULT]=scale=1.0
-    double scale;
-    /// Radius of the cylinder [A]
-    //  [DEFAULT]=radius=20.0 [A]
-    double radius;
-    /// Length of the cylinder [A]
-    //  [DEFAULT]=length=400.0 [A]
-    double length;
-    /// Contrast [1/A^(2)]
-    //  [DEFAULT]=sldCyl=4.0e-6 [1/A^(2)]
-    double sldCyl;
-    /// sldCyl [1/A^(2)]
-    //  [DEFAULT]=sldSolv=1.0e-6 [1/A^(2)]
-    double sldSolv;
-	/// Incoherent Background [1/cm] 0.00
-	//  [DEFAULT]=background=0.0 [1/cm]
-	double background;
-    /// Orientation of the cylinder axis w/respect incoming beam [deg]
-    //  [DEFAULT]=cyl_theta=60.0 [deg]
-    double cyl_theta;
-    /// Orientation of the cylinder in the plane of the detector [deg]
-    //  [DEFAULT]=cyl_phi=60.0 [deg]
-    double cyl_phi;
+class CylinderModel{
+public:
+  // Model parameters
 
-} CylinderParameters;
+  /// Scale factor
+  //  [DEFAULT]=scale=1.0
+  Parameter scale;
 
+  /// Radius of the cylinder [A]
+  //  [DEFAULT]=radius=20.0 [A]
+  Parameter radius;
 
+  /// Length of the cylinder [A]
+  //  [DEFAULT]=length=400.0 [A]
+  Parameter length;
 
-/// 1D scattering function
-double cylinder_analytical_1D(CylinderParameters *pars, double q);
+  /// Contrast [1/A^(2)]
+  //  [DEFAULT]=sldCyl=4.0e-6 [1/A^(2)]
+  Parameter sldCyl;
 
-/// 2D scattering function
-double cylinder_analytical_2D(CylinderParameters *pars, double q, double phi);
-double cylinder_analytical_2DXY(CylinderParameters *pars, double qx, double qy);
-double cylinder_analytical_2D_scaled(CylinderParameters *pars, double q, double q_x, double q_y);
+  /// sldCyl [1/A^(2)]
+  //  [DEFAULT]=sldSolv=1.0e-6 [1/A^(2)]
+  Parameter sldSolv;
+
+  /// Incoherent Background [1/cm] 0.00
+  //  [DEFAULT]=background=0.0 [1/cm]
+  Parameter background;
+
+  /// Orientation of the cylinder axis w/respect incoming beam [deg]
+  //  [DEFAULT]=cyl_theta=60.0 [deg]
+  Parameter cyl_theta;
+
+  /// Orientation of the cylinder in the plane of the detector [deg]
+  //  [DEFAULT]=cyl_phi=60.0 [deg]
+  Parameter cyl_phi;
+
+  // Constructor
+  CylinderModel();
+
+  // Operators to get I(Q)
+  double operator()(double q);
+  double operator()(double qx, double qy);
+  double calculate_ER();
+  double evaluate_rphi(double q, double phi);
+};
 
 #endif
Index: sansmodels/src/c_models/cylinder.cpp
===================================================================
--- sansmodels/src/c_models/cylinder.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ sansmodels/src/c_models/cylinder.cpp	(revision dbddbf5ca23038d32d3e3e085da7bc8c67ddd7c0)
@@ -18,9 +18,7 @@
  *   sansmodels/src/libigor
  *
- *	TODO: refactor so that we pull in the old sansmodels.c_extensions
  */
 
 #include <math.h>
-#include "models.hh"
 #include "parameters.hh"
 #include <stdio.h>
@@ -32,4 +30,16 @@
 	#include "cylinder.h"
 }
+
+// Convenience parameter structure
+typedef struct {
+    double scale;
+    double radius;
+    double length;
+    double sldCyl;
+    double sldSolv;
+    double background;
+    double cyl_theta;
+    double cyl_phi;
+} CylinderParameters;
 
 CylinderModel :: CylinderModel() {
@@ -101,4 +111,79 @@
 
 	return sum/norm + background();
+}
+
+/**
+ * Function to evaluate 2D scattering function
+ * @param pars: parameters of the cylinder
+ * @param q: q-value
+ * @param q_x: q_x / q
+ * @param q_y: q_y / q
+ * @return: function value
+ */
+static double cylinder_analytical_2D_scaled(CylinderParameters *pars, double q, double q_x, double q_y) {
+  double cyl_x, cyl_y, cyl_z;
+  double q_z;
+  double alpha, vol, cos_val;
+  double answer;
+  //convert angle degree to radian
+  double pi = 4.0*atan(1.0);
+  double theta = pars->cyl_theta * pi/180.0;
+  double phi = pars->cyl_phi * pi/180.0;
+
+    // Cylinder orientation
+    cyl_x = sin(theta) * cos(phi);
+    cyl_y = sin(theta) * sin(phi);
+    cyl_z = cos(theta);
+
+    // q vector
+    q_z = 0;
+
+    // Compute the angle btw vector q and the
+    // axis of the cylinder
+    cos_val = cyl_x*q_x + cyl_y*q_y + cyl_z*q_z;
+
+    // The following test should always pass
+    if (fabs(cos_val)>1.0) {
+      printf("cyl_ana_2D: Unexpected error: cos(alpha)>1\n");
+      return 0;
+    }
+
+    // Note: cos(alpha) = 0 and 1 will get an
+    // undefined value from CylKernel
+  alpha = acos( cos_val );
+
+  // Call the IGOR library function to get the kernel
+  answer = CylKernel(q, pars->radius, pars->length/2.0, alpha) / sin(alpha);
+
+  // Multiply by contrast^2
+  answer *= (pars->sldCyl - pars->sldSolv)*(pars->sldCyl - pars->sldSolv);
+
+  //normalize by cylinder volume
+  //NOTE that for this (Fournet) definition of the integral, one must MULTIPLY by Vcyl
+    vol = acos(-1.0) * pars->radius * pars->radius * pars->length;
+  answer *= vol;
+
+  //convert to [cm-1]
+  answer *= 1.0e8;
+
+  //Scale
+  answer *= pars->scale;
+
+  // add in the background
+  answer += pars->background;
+
+  return answer;
+}
+
+/**
+ * Function to evaluate 2D scattering function
+ * @param pars: parameters of the cylinder
+ * @param q: q-value
+ * @return: function value
+ */
+static double cylinder_analytical_2DXY(CylinderParameters *pars, double qx, double qy) {
+  double q;
+  q = sqrt(qx*qx+qy*qy);
+  return cylinder_analytical_2D_scaled(pars, q, qx/q, qy/q);
 }
 
@@ -254,53 +339,2 @@
 	return rad_out;
 }
-// Testing code
-int main(void)
-{
-	CylinderModel c = CylinderModel();
-
-	printf("Length = %g\n", c.length());
-	printf("I(Qx=%g,Qy=%g) = %g\n", 0.001, 0.001, c(0.001, 0.001));
-	printf("I(Q=%g) = %g\n", 0.001, c(0.001));
-	c.radius.dispersion = new GaussianDispersion();
-	c.radius.dispersion->npts = 100;
-	c.radius.dispersion->width = 5;
-
-	//c.length.dispersion = GaussianDispersion();
-	//c.length.dispersion.npts = 20;
-	//c.length.dispersion.width = 65;
-
-	printf("I(Q=%g) = %g\n", 0.001, c(0.001));
-	c.scale = 10.0;
-	printf("I(Q=%g) = %g\n", 0.001, c(0.001));
-	printf("I(Qx=%g, Qy=%g) = %g\n", 0.001, 0.001, c(0.001, 0.001));
-	printf("I(Q=%g,  Phi=%g) = %g\n", 0.00447, .7854, c.evaluate_rphi(sqrt(0.00002), .7854));
-
-	// Average over phi at theta=90 deg
-	c.cyl_theta = 1.57;
-	double values_th[100];
-	double values[100];
-	double weights[100];
-	double pi = acos(-1.0);
-	printf("pi=%g\n", pi);
-	for(int i=0; i<100; i++){
-		values[i] = (float)i*2.0*pi/99.0;
-		values_th[i] = (float)i*pi/99.0;
-		weights[i] = 1.0;
-	}
-	//c.radius.dispersion->width = 0;
-	c.cyl_phi.dispersion = new ArrayDispersion();
-	c.cyl_theta.dispersion = new ArrayDispersion();
-	(*c.cyl_phi.dispersion).set_weights(100, values, weights);
-	(*c.cyl_theta.dispersion).set_weights(100, values_th, weights);
-
-	double i_avg = c(0.01, 0.01);
-	double i_1d = c(sqrt(0.0002));
-
-	printf("\nI(Qx=%g, Qy=%g) = %g\n", 0.01, 0.01, i_avg);
-	printf("I(Q=%g)         = %g\n", sqrt(0.0002), i_1d);
-	printf("ratio %g %g\n", i_avg/i_1d, i_1d/i_avg);
-
-
-	return 0;
-}
-
Index: sansmodels/src/c_models/models.hh
===================================================================
--- sansmodels/src/c_models/models.hh	(revision f425805ce128273a62ba1890166627177d3fa0fd)
+++ sansmodels/src/c_models/models.hh	(revision dbddbf5ca23038d32d3e3e085da7bc8c67ddd7c0)
@@ -27,25 +27,4 @@
 using namespace std;
 
-class CylinderModel{
-public:
-	// Model parameters
-	Parameter radius;
-	Parameter scale;
-	Parameter length;
-	Parameter sldCyl;
-	Parameter sldSolv;
-	Parameter background;
-	Parameter cyl_theta;
-	Parameter cyl_phi;
-
-	// Constructor
-	CylinderModel();
-
-	// Operators to get I(Q)
-	double operator()(double q);
-	double operator()(double qx, double qy);
-	double calculate_ER();
-	double evaluate_rphi(double q, double phi);
-};
 
 class CappedCylinderModel{
Index: sansmodels/src/python_wrapper/CCylinderModel.cpp
===================================================================
--- sansmodels/src/python_wrapper/CCylinderModel.cpp	(revision 67424cdc019bde2f4cbc089828ff660e6f914c2c)
+++ sansmodels/src/python_wrapper/CCylinderModel.cpp	(revision dbddbf5ca23038d32d3e3e085da7bc8c67ddd7c0)
@@ -18,5 +18,5 @@
  *
  * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY cylinder.h
+ *          DO NOT MODIFY THIS FILE, MODIFY ../c_extensions/cylinder.h
  *          AND RE-RUN THE GENERATOR SCRIPT
  *
@@ -33,8 +33,8 @@
 #include <math.h>
 #include <time.h>
+
+}
+
 #include "cylinder.h"
-}
-
-#include "models.hh"
 #include "dispersion_visitor.hh"
 
