Index: sansmodels/src/sans/models/c_extensions/barbell.c
===================================================================
--- sansmodels/src/sans/models/c_extensions/barbell.c	(revision 339ce675656e3ab89eff7b84d8292a2e0ffe6109)
+++ sansmodels/src/sans/models/c_extensions/barbell.c	(revision 339ce675656e3ab89eff7b84d8292a2e0ffe6109)
@@ -0,0 +1,174 @@
+/*
+ * Scattering model for a BarBell
+ */
+#include "barbell.h"
+#include <math.h>
+#include "GaussWeights.h"
+#include "libCylinder.h"
+
+/**
+ * Function to evaluate 1D scattering function
+ * @param pars: parameters of the BarBell
+ * @param q: q-value
+ * @return: function value
+ */
+double barbell_analytical_1D(BarBellParameters *pars, double q) {
+	double dp[7];
+	double result;
+
+	dp[0] = pars->scale;
+	dp[1] = pars->rad_bar;
+	dp[2] = pars->len_bar;
+	dp[3] = pars->rad_bell;
+	dp[4] = pars->sld_barbell;
+	dp[5] = pars->sld_solv;
+	dp[6] = pars->background;
+
+	result = Barbell(dp, q);
+	// Make Sure it never goes to inf/nan.
+	if ( result == INFINITY || result == NAN){
+		result = pars->background;
+	}
+	return result;
+}
+
+
+double bar2d_kernel(double dp[], double q, double alpha) {
+	int i,j;
+	double Pi;
+	double scale,contr,bkg,sldc,slds;
+	double len,rad,hDist,endRad;
+	int nordj=76;
+	double zi=alpha,yyy,answer;			//running tally of integration
+	double summj,vaj,vbj,zij;			//for the inner integration
+	double arg1,arg2,inner,be;
+
+
+	scale = dp[0];
+	rad = dp[1];
+	len = dp[2];
+	endRad = dp[3];
+	sldc = dp[4];
+	slds = dp[5];
+	bkg = dp[6];
+
+	hDist = sqrt(fabs(endRad*endRad-rad*rad));		//by definition for this model
+
+	contr = sldc-slds;
+
+	Pi = 4.0*atan(1.0);
+	vaj = -1.0*hDist/endRad;
+	vbj = 1.0;		//endpoints of inner integral
+
+	summj=0.0;
+
+	for(j=0;j<nordj;j++) {
+		//20 gauss points for the inner integral
+		zij = ( Gauss76Z[j]*(vbj-vaj) + vaj + vbj )/2.0;		//the "t" dummy
+		yyy = Gauss76Wt[j] * Dumb_kernel(dp,q,zij,zi);		//uses the same Kernel as the Dumbbell, here L>0
+		summj += yyy;
+	}
+	//now calculate the value of the inner integral
+	inner = (vbj-vaj)/2.0*summj;
+	inner *= 4.0*Pi*endRad*endRad*endRad;
+
+	//now calculate outer integrand
+	arg1 = q*len/2.0*cos(zi);
+	arg2 = q*rad*sin(zi);
+	yyy = inner;
+
+	if(arg2 == 0) {
+		be = 0.5;
+	} else {
+		be = NR_BessJ1(arg2)/arg2;
+	}
+
+	if(arg1 == 0.0) {		//limiting value of sinc(0) is 1; sinc is not defined in math.h
+		yyy += Pi*rad*rad*len*2.0*be;
+	} else {
+		yyy += Pi*rad*rad*len*sin(arg1)/arg1*2.0*be;
+	}
+	yyy *= yyy;   //sin(zi);
+	answer = yyy;
+
+
+	answer /= Pi*rad*rad*len + 2.0*Pi*(2.0*endRad*endRad*endRad/3.0+endRad*endRad*hDist-hDist*hDist*hDist/3.0);		//divide by volume
+	answer *= 1.0e8;		//convert to cm^-1
+	answer *= contr*contr;
+	answer *= scale;
+	answer += bkg;
+
+	return answer;
+}
+
+
+/**
+ * Function to evaluate 2D scattering function
+ * @param pars: parameters of the BarBell
+ * @param q: q-value
+ * @return: function value
+ */
+double barbell_analytical_2DXY(BarBellParameters *pars, double qx, double qy){
+	double q;
+	q = sqrt(qx*qx+qy*qy);
+	return barbell_analytical_2D_scaled(pars, q, qx/q, qy/q);
+}
+
+double barbell_analytical_2D(BarBellParameters *pars, double q, double phi) {
+	return barbell_analytical_2D_scaled(pars, q, cos(phi), sin(phi));
+}
+
+/**
+ * Function to evaluate 2D scattering function
+ * @param pars: parameters of the BarBell
+ * @param q: q-value
+ * @param q_x: q_x / q
+ * @param q_y: q_y / q
+ * @return: function value
+ */
+double barbell_analytical_2D_scaled(BarBellParameters *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;
+	double dp[7];
+
+	dp[0] = pars->scale;
+	dp[1] = pars->rad_bar;
+	dp[2] = pars->len_bar;
+	dp[3] = pars->rad_bell;
+	dp[4] = pars->sld_barbell;
+	dp[5] = pars->sld_solv;
+	dp[6] = pars->background;
+
+
+	//double Pi = 4.0*atan(1.0);
+    // Cylinder orientation
+    cyl_x = sin(pars->theta) * cos(pars->phi);
+    cyl_y = sin(pars->theta) * sin(pars->phi);
+    cyl_z = cos(pars->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 = bar2d_kernel(dp, q, alpha)/sin(alpha);
+
+
+	return answer;
+
+}
Index: sansmodels/src/sans/models/c_extensions/barbell.h
===================================================================
--- sansmodels/src/sans/models/c_extensions/barbell.h	(revision 339ce675656e3ab89eff7b84d8292a2e0ffe6109)
+++ sansmodels/src/sans/models/c_extensions/barbell.h	(revision 339ce675656e3ab89eff7b84d8292a2e0ffe6109)
@@ -0,0 +1,79 @@
+#if !defined(barbell_h)
+#define barbell_h
+
+/**
+ * Structure definition for BarBell parameters
+ */
+ //[PYTHONCLASS] = BarBellModel
+ //[DISP_PARAMS] = rad_bar,len_bar,rad_bell,phi,  theta
+ //[DESCRIPTION] =<text>Calculates the scattering from a barbell-shaped cylinder. That is
+ //				a sphereocylinder with spherical end caps
+ //				that have a radius larger than that of
+ //				the cylinder and the center of the end cap
+ //				radius lies outside of the cylinder.
+ //				Note: As the length of cylinder(bar) -->0,
+ //				it becomes a dumbbell.
+ //				And when rad_bar = rad_bell,
+ //				it is a spherocylinder.
+ //				It must be that rad_bar <(=) rad_bell.
+ //				[Parameters];
+ //				scale: volume fraction of spheres,
+ //				background:incoherent background,
+ //				rad_bar: radius of the cylindrical bar,
+ //				len_bar: length of the cylindrical bar,
+ //				rad_bell: radius of the spherical bell,
+ //				sld_barbell: SLD of the barbell,
+ //				sld_solv: SLD of the solvent.
+ //		</text>
+ //[FIXED]=  rad_bar.width;len_bar;rad_bell;phi.width; theta.width
+ //[ORIENTATION_PARAMS]= <text> phi; theta; phi.width; theta.width</text>
+
+typedef struct {
+    /// Scale factor
+    //  [DEFAULT]=scale= 1.0
+    double scale;
+
+    ///	rad_bar [A]
+    //  [DEFAULT]=rad_bar=20.0 [A]
+    double rad_bar;
+
+    ///	length of the bar [A]
+    //  [DEFAULT]=len_bar=400.0 [A]
+    double len_bar;
+
+    ///	Radius of sphere [A]
+    //  [DEFAULT]=rad_bell=40.0 [A]
+    double rad_bell;
+
+    ///	sld_barbell [1/A^(2)]
+    //  [DEFAULT]=sld_barbell= 1.0e-6 [1/A^(2)]
+    double sld_barbell;
+
+    ///	sld_solv [1/A^(2)]
+    //  [DEFAULT]=sld_solv= 6.3e-6 [1/A^(2)]
+    double sld_solv;
+
+	/// Incoherent Background [1/cm]
+	//  [DEFAULT]=background=0.0 [1/cm]
+	double background;
+
+    /// Angle of the main axis against z-axis in detector plane [rad]
+    //  [DEFAULT]=theta=0.0 [rad]
+    double theta;
+    /// Azimuthal angle around z-axis in detector plane [rad]
+    //  [DEFAULT]=phi=0.0 [rad]
+    double phi;
+
+} BarBellParameters;
+
+
+
+/// 1D scattering function
+double barbell_analytical_1D(BarBellParameters *pars, double q);
+
+/// 2D scattering function
+double barbell_analytical_2D(BarBellParameters *pars, double q, double phi);
+double barbell_analytical_2DXY(BarBellParameters *pars, double qx, double qy);
+double barbell_analytical_2D_scaled(BarBellParameters *pars, double q, double q_x, double q_y);
+
+#endif
Index: sansmodels/src/sans/models/c_extensions/capcyl.c
===================================================================
--- sansmodels/src/sans/models/c_extensions/capcyl.c	(revision 339ce675656e3ab89eff7b84d8292a2e0ffe6109)
+++ sansmodels/src/sans/models/c_extensions/capcyl.c	(revision 339ce675656e3ab89eff7b84d8292a2e0ffe6109)
@@ -0,0 +1,174 @@
+/*
+ * Scattering model for a Capped Cylinder
+ */
+#include "capcyl.h"
+#include <math.h>
+#include "GaussWeights.h"
+#include "libCylinder.h"
+
+/**
+ * Function to evaluate 1D scattering function
+ * @param pars: parameters of the CappedCylinder
+ * @param q: q-value
+ * @return: function value
+ */
+double capcyl_analytical_1D(CapCylParameters *pars, double q) {
+	double dp[7];
+	double result;
+
+	dp[0] = pars->scale;
+	dp[1] = pars->rad_cyl;
+	dp[2] = pars->len_cyl;
+	dp[3] = pars->rad_cap;
+	dp[4] = pars->sld_capcyl;
+	dp[5] = pars->sld_solv;
+	dp[6] = pars->background;
+
+	result = CappedCylinder(dp, q);
+	// Make Sure it never goes to inf/nan.
+	if ( result == INFINITY || result == NAN){
+		result = pars->background;
+	}
+	return result;
+}
+
+
+double capcyl2d_kernel(double dp[], double q, double alpha) {
+	int i,j;
+	double Pi;
+	double scale,contr,bkg,sldc,slds;
+	double len,rad,hDist,endRad;
+	int nordj=76;
+	double zi=alpha,yyy,answer;			//running tally of integration
+	double summj,vaj,vbj,zij;			//for the inner integration
+	double arg1,arg2,inner,be;
+
+
+	scale = dp[0];
+	rad = dp[1];
+	len = dp[2];
+	endRad = dp[3];
+	sldc = dp[4];
+	slds = dp[5];
+	bkg = dp[6];
+
+	hDist = -1.0*sqrt(fabs(endRad*endRad-rad*rad));		//by definition for this model
+
+	contr = sldc-slds;
+
+	Pi = 4.0*atan(1.0);
+	vaj = -1.0*hDist/endRad;
+	vbj = 1.0;		//endpoints of inner integral
+
+	summj=0.0;
+
+	for(j=0;j<nordj;j++) {
+		//20 gauss points for the inner integral
+		zij = ( Gauss76Z[j]*(vbj-vaj) + vaj + vbj )/2.0;		//the "t" dummy
+		yyy = Gauss76Wt[j] * ConvLens_kernel(dp,q,zij,zi);		//uses the same Kernel as the Dumbbell, here L>0
+		summj += yyy;
+	}
+	//now calculate the value of the inner integral
+	inner = (vbj-vaj)/2.0*summj;
+	inner *= 4.0*Pi*endRad*endRad*endRad;
+
+	//now calculate outer integrand
+	arg1 = q*len/2.0*cos(zi);
+	arg2 = q*rad*sin(zi);
+	yyy = inner;
+
+	if(arg2 == 0) {
+		be = 0.5;
+	} else {
+		be = NR_BessJ1(arg2)/arg2;
+	}
+
+	if(arg1 == 0.0) {		//limiting value of sinc(0) is 1; sinc is not defined in math.h
+		yyy += Pi*rad*rad*len*2.0*be;
+	} else {
+		yyy += Pi*rad*rad*len*sin(arg1)/arg1*2.0*be;
+	}
+	yyy *= yyy;   //sin(zi);
+	answer = yyy;
+
+
+	answer /= Pi*rad*rad*len + 2.0*Pi*(2.0*endRad*endRad*endRad/3.0+endRad*endRad*hDist-hDist*hDist*hDist/3.0);		//divide by volume
+	answer *= 1.0e8;		//convert to cm^-1
+	answer *= contr*contr;
+	answer *= scale;
+	answer += bkg;
+
+	return answer;
+}
+
+
+/**
+ * Function to evaluate 2D scattering function
+ * @param pars: parameters of the BarBell
+ * @param q: q-value
+ * @return: function value
+ */
+double capcyl_analytical_2DXY(CapCylParameters *pars, double qx, double qy){
+	double q;
+	q = sqrt(qx*qx+qy*qy);
+	return capcyl_analytical_2D_scaled(pars, q, qx/q, qy/q);
+}
+
+double capcyl_analytical_2D(CapCylParameters *pars, double q, double phi) {
+	return capcyl_analytical_2D_scaled(pars, q, cos(phi), sin(phi));
+}
+
+/**
+ * Function to evaluate 2D scattering function
+ * @param pars: parameters of the BarBell
+ * @param q: q-value
+ * @param q_x: q_x / q
+ * @param q_y: q_y / q
+ * @return: function value
+ */
+double capcyl_analytical_2D_scaled(CapCylParameters *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;
+	double dp[7];
+
+	dp[0] = pars->scale;
+	dp[1] = pars->rad_cyl;
+	dp[2] = pars->len_cyl;
+	dp[3] = pars->rad_cap;
+	dp[4] = pars->sld_capcyl;
+	dp[5] = pars->sld_solv;
+	dp[6] = pars->background;
+
+
+	//double Pi = 4.0*atan(1.0);
+    // Cylinder orientation
+    cyl_x = sin(pars->theta) * cos(pars->phi);
+    cyl_y = sin(pars->theta) * sin(pars->phi);
+    cyl_z = cos(pars->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 = capcyl2d_kernel(dp, q, alpha)/sin(alpha);
+
+
+	return answer;
+
+}
Index: sansmodels/src/sans/models/c_extensions/capcyl.h
===================================================================
--- sansmodels/src/sans/models/c_extensions/capcyl.h	(revision 339ce675656e3ab89eff7b84d8292a2e0ffe6109)
+++ sansmodels/src/sans/models/c_extensions/capcyl.h	(revision 339ce675656e3ab89eff7b84d8292a2e0ffe6109)
@@ -0,0 +1,77 @@
+#if !defined(capcyl_h)
+#define capcyl_h
+
+/**
+ * Structure definition for CappedCylinder parameters
+ */
+ //[PYTHONCLASS] = CappedCylinderModel
+ //[DISP_PARAMS] = rad_cyl,len_cyl,rad_cap,phi,  theta
+ //[DESCRIPTION] =<text>Calculates the scattering from a cylinder with spherical
+ //				section end-caps. That is, a sphereocylinder
+ //				with end caps that have a radius larger than
+ //				that of the cylinder and the center of the
+ //				end cap radius lies within the cylinder.
+ //				Note: As the length of cylinder -->0,
+ //				it becomes a ConvexLens.
+ //				It must be that rad_cyl <(=) rad_cap.
+ //				[Parameters];
+ //				scale: volume fraction of spheres,
+ //				background:incoherent background,
+ //				rad_cyl: radius of the cylinder,
+ //				len_cyl: length of the cylinder,
+ //				rad_cap: radius of the semi-spherical cap,
+ //				sld_capcyl: SLD of the capped cylinder,
+ //				sld_solv: SLD of the solvent.
+ //		</text>
+ //[FIXED]=  rad_cyl.width;len_cyl;rad_cap;phi.width; theta.width
+ //[ORIENTATION_PARAMS]= <text> phi; theta; phi.width; theta.width</text>
+
+typedef struct {
+    /// Scale factor
+    //  [DEFAULT]=scale= 1.0
+    double scale;
+
+    ///	rad_cyl [A]
+    //  [DEFAULT]=rad_cyl=20.0 [A]
+    double rad_cyl;
+
+    ///	length of the cylinder
+    //  [DEFAULT]=len_cyl=400.0 [A]
+    double len_cyl;
+
+    ///	Radius of sphere [A]
+    //  [DEFAULT]=rad_cap=40.0 [A]
+    double rad_cap;
+
+    ///	sld_capcyl [1/A^(2)]
+    //  [DEFAULT]=sld_capcyl= 1.0e-6 [1/A^(2)]
+    double sld_capcyl;
+
+    ///	sld_solv [1/A^(2)]
+    //  [DEFAULT]=sld_solv= 6.3e-6 [1/A^(2)]
+    double sld_solv;
+
+	/// Incoherent Background [1/cm]
+	//  [DEFAULT]=background=0.0 [1/cm]
+	double background;
+
+    /// Angle of the main axis against z-axis in detector plane [rad]
+    //  [DEFAULT]=theta=0.0 [rad]
+    double theta;
+    /// Azimuthal angle around z-axis in detector plane [rad]
+    //  [DEFAULT]=phi=0.0 [rad]
+    double phi;
+
+} CapCylParameters;
+
+
+
+/// 1D scattering function
+double capcyl_analytical_1D(CapCylParameters *pars, double q);
+
+/// 2D scattering function
+double capcyl_analytical_2D(CapCylParameters *pars, double q, double phi);
+double capcyl_analytical_2DXY(CapCylParameters *pars, double qx, double qy);
+double capcyl_analytical_2D_scaled(CapCylParameters *pars, double q, double q_x, double q_y);
+
+#endif
Index: sansmodels/src/sans/models/c_extensions/corefourshell.c
===================================================================
--- sansmodels/src/sans/models/c_extensions/corefourshell.c	(revision c724ccd87499a21402fee0d11d517066f99ddf9b)
+++ sansmodels/src/sans/models/c_extensions/corefourshell.c	(revision 339ce675656e3ab89eff7b84d8292a2e0ffe6109)
@@ -18,6 +18,6 @@
 
 	dp[0] = pars->scale;
-	dp[1] = pars->rad_core;
-	dp[2] = pars->sld_core;
+	dp[1] = pars->rad_core0;
+	dp[2] = pars->sld_core0;
 	dp[3] = pars->thick_shell1;
 	dp[4] = pars->sld_shell1;
Index: sansmodels/src/sans/models/c_extensions/corefourshell.h
===================================================================
--- sansmodels/src/sans/models/c_extensions/corefourshell.h	(revision c724ccd87499a21402fee0d11d517066f99ddf9b)
+++ sansmodels/src/sans/models/c_extensions/corefourshell.h	(revision 339ce675656e3ab89eff7b84d8292a2e0ffe6109)
@@ -6,9 +6,9 @@
  */
  //[PYTHONCLASS] = CoreFourShellModel
- //[DISP_PARAMS] = rad_core, thick_shell1,thick_shell2,thick_shell3,thick_shell4
+ //[DISP_PARAMS] = rad_core0, thick_shell1,thick_shell2,thick_shell3,thick_shell4
  //[DESCRIPTION] =<text> Calculates the scattering intensity from a core-4 shell structure.
  // 			scale = scale factor * volume fraction
- //				rad_core: the radius of the core
- //				sld_core: the SLD of the core
+ //				rad_core0: the radius of the core
+ //				sld_core0: the SLD of the core
  //				thick_shelli: the thickness of the i'th shell from the core
  //				sld_shelli: the SLD of the i'th shell from the core
@@ -16,5 +16,5 @@
  //				background: incoherent background
  //		</text>
- //[FIXED]=<text>  thick_shell4.width; thick_shell1.width;thick_shell2.width;thick_shell3.width;rad_core.width </text>
+ //[FIXED]=<text>  thick_shell4.width; thick_shell1.width;thick_shell2.width;thick_shell3.width;rad_core0.width </text>
  //[ORIENTATION_PARAMS]= <text> </text>
 
@@ -24,11 +24,11 @@
     double scale;
 
-    ///	Radius of the core [A]
-    //  [DEFAULT]=rad_core=60. [A]
-    double rad_core;
+    ///	Radius of the core0 [A]
+    //  [DEFAULT]=rad_core0=60. [A]
+    double rad_core0;
 
-    ///	sld of core [1/A^(2)]
-    //  [DEFAULT]=sld_core= 6.4e-6 [1/A^(2)]
-    double sld_core;
+    ///	sld of core0 [1/A^(2)]
+    //  [DEFAULT]=sld_core0= 6.4e-6 [1/A^(2)]
+    double sld_core0;
 
     ///	thickness of the shell1 [A]
Index: sansmodels/src/sans/models/c_extensions/fcc.c
===================================================================
--- sansmodels/src/sans/models/c_extensions/fcc.c	(revision d5b6a9d7cd9e26b5f9e28e55e8cf848a40de6ae9)
+++ sansmodels/src/sans/models/c_extensions/fcc.c	(revision 339ce675656e3ab89eff7b84d8292a2e0ffe6109)
@@ -65,5 +65,5 @@
 	double answer;
 	double Pi = 4.0*atan(1.0);
-	double aa, Da, qDa_2, latticeScale, Zq, Fkq, Fkq_2;
+	double aa, Da, qDa_2, latticeScale, Zq, Fkq, Fkq_2,contrast;
 
 	double dp[5];
@@ -77,4 +77,5 @@
 	Da = pars->d_factor*aa;
 	qDa_2 = pow(q*Da,2.0);
+	contrast = pars->sldSph - pars->sldSolv;
 
 	latticeScale = 4.0*(4.0/3.0)*Pi*(dp[1]*dp[1]*dp[1])/pow(aa*sqrt(2.0),3.0);
@@ -133,5 +134,5 @@
 
 	// Use SphereForm directly from libigor
-	answer = SphereForm(dp,q)*Zq;
+	answer = SphereForm_Paracrystal(pars->radius,contrast,q)*Zq;
 
 	//consider scales
Index: sansmodels/src/sans/models/c_extensions/onion.c
===================================================================
--- sansmodels/src/sans/models/c_extensions/onion.c	(revision a1b247163dd00d4b19fd556819b00a9ccf638299)
+++ sansmodels/src/sans/models/c_extensions/onion.c	(revision 339ce675656e3ab89eff7b84d8292a2e0ffe6109)
@@ -11,6 +11,6 @@
 	int n = dp[0];
 	double scale = dp[1];
-	double rad_core = dp[2];
-	double sld_core = dp[3];
+	double rad_core0 = dp[2];
+	double sld_core0 = dp[3];
 	double sld_solv = dp[4];
 	double background = dp[5];
@@ -30,9 +30,9 @@
 		fun_type[i] = dp[i+45];
 	}
-	sld_out[0] = sld_core;
+	sld_out[0] = sld_core0;
 	sld_out[n+1] = sld_solv;
-	sld_in[0] = sld_core;
+	sld_in[0] = sld_core0;
 	sld_in[n+1] = sld_solv;
-	thick[0] = rad_core;
+	thick[0] = rad_core0;
 	thick[n+1] = 1e+10;
 	A[0] = 0.0;
@@ -69,5 +69,5 @@
 					}
 					else{
-						slope[i] = (sld_out[i]-sld_in[i])/(exp(A[i])-1);
+						slope[i] = (sld_out[i]-sld_in[i])/(exp(A[i])-1.0);
 					}
                     for (j=0; j<2; j++){
@@ -174,6 +174,6 @@
 	dp[0] = pars->n_shells;
 	dp[1] = pars->scale;
-	dp[2] = pars->rad_core;
-	dp[3] = pars->sld_core;
+	dp[2] = pars->rad_core0;
+	dp[3] = pars->sld_core0;
 	dp[4] = pars->sld_solv;
 	dp[5] = pars->background;
Index: sansmodels/src/sans/models/c_extensions/onion.h
===================================================================
--- sansmodels/src/sans/models/c_extensions/onion.h	(revision 7381f345e4f06f419f41279b0c7ddf73d3d8c755)
+++ sansmodels/src/sans/models/c_extensions/onion.h	(revision 339ce675656e3ab89eff7b84d8292a2e0ffe6109)
@@ -6,5 +6,5 @@
  */
  //[PYTHONCLASS] = OnionModel
- //[DISP_PARAMS] = rad_core, thick_shell1,thick_shell2,thick_shell3,thick_shell4, thick_shell5,thick_shell6,thick_shell7,thick_shell8,thick_shell9,thick_shell10
+ //[DISP_PARAMS] = rad_core0, thick_shell1,thick_shell2,thick_shell3,thick_shell4, thick_shell5,thick_shell6,thick_shell7,thick_shell8,thick_shell9,thick_shell10
  //[DESCRIPTION] =<text>Form factor of mutishells normalized by the volume. Here each shell is described
  //						 by an exponential function;
@@ -24,12 +24,12 @@
  //
  //				background:background,
- //				rad_core: radius of sphere(core)
+ //				rad_core0: radius of sphere(core)
  //				thick_shell#:the thickness of the shell#
- //				sld_core: the SLD of the sphere
+ //				sld_core0: the SLD of the sphere
  //				sld_solv: the SLD of the solvent
  //				sld_shell: the SLD of the shell#
  //				A_shell#: the coefficient in the exponential function
  //		</text>
- //[FIXED]=  <text>rad_core.width;thick_shell1.width;thick_shell2.width;thick_shell3.width;thick_shell4.width;thick_shell5.width;thick_shell6.width;thick_shell7.width;thick_shell8.width;thick_shell9.width;thick_shell10.width</text>
+ //[FIXED]=  <text>rad_core0.width;thick_shell1.width;thick_shell2.width;thick_shell3.width;thick_shell4.width;thick_shell5.width;thick_shell6.width;thick_shell7.width;thick_shell8.width;thick_shell9.width;thick_shell10.width</text>
  //[ORIENTATION_PARAMS]= <text> </text>
 
@@ -42,9 +42,9 @@
 	double scale;
     ///	Radius of sphere [A]
-    //  [DEFAULT]=rad_core=200.0 [A]
-	double rad_core;
+    //  [DEFAULT]=rad_core0=200.0 [A]
+	double rad_core0;
 	///	sld_core [1/A^(2)]
-	//  [DEFAULT]=sld_core= 1.0e-6 [1/A^(2)]
-	double sld_core;
+	//  [DEFAULT]=sld_core0= 1.0e-6 [1/A^(2)]
+	double sld_core0;
 	///	sld_solv [1/A^(2)]
 	//  [DEFAULT]=sld_solv= 6.4e-6 [1/A^(2)]
Index: sansmodels/src/sans/models/c_extensions/refl.c
===================================================================
--- sansmodels/src/sans/models/c_extensions/refl.c	(revision 35aface36aa7573475600ebbacb987f50386d5f8)
+++ sansmodels/src/sans/models/c_extensions/refl.c	(revision 339ce675656e3ab89eff7b84d8292a2e0ffe6109)
@@ -268,5 +268,5 @@
 	double background = dp[6];
 
-	double sld[n+2],sld_nul[n+2],thick_inter[n+2],thick[n+2],total_thick;
+	double sld[n+2],sld_im[n+2],thick_inter[n+2],thick[n+2],total_thick;
 	fun_type[0] = dp[3];
 	for (i =1; i<=n; i++){
@@ -275,4 +275,5 @@
 		thick[i] = dp[i+26];
 		fun_type[i] = dp[i+36];
+		sld_im[i] = dp[i+46];
 
 		total_thick += thick[i] + thick_inter[i];
@@ -280,4 +281,6 @@
 	sld[0] = sld_sub;
 	sld[n+1] = sld_super;
+	sld_im[0] = fabs(dp[0+56]);
+	sld_im[n+1] = fabs(dp[1+56]);
 	thick[0] = total_thick/5.0;
 	thick[n+1] = total_thick/5.0;
@@ -287,5 +290,5 @@
 	double nsl=21.0; //nsl = Num_sub_layer:  MUST ODD number in double //no other number works now
 	int n_s, floor_nsl;
-    double sld_i,dz,phi,R,ko2;
+    double sld_i,sldim_i,dz,phi,R,ko2;
     double sign,erfunc;
     double pi;
@@ -300,6 +303,6 @@
 	//Checking if floor is available.
 	//no imaginary sld inputs in this function yet
-    n_sub=cassign(1.0-sld_sub*pow(lamda,2.0)/(2.0*pi),0.0);
-    n_sup=cassign(1.0-sld_super*pow(lamda,2.0)/(2.0*pi),0.0);
+    n_sub=cassign(1.0-sld_sub*pow(lamda,2.0)/(2.0*pi),pow(lamda,2.0)/(2.0*pi)*sld_im[0]);
+    n_sup=cassign(1.0-sld_super*pow(lamda,2.0)/(2.0*pi),pow(lamda,2.0)/(2.0*pi)*sld_im[n+1]);
     ko2 = pow(2.0*pi/lamda,2.0);
 
@@ -323,10 +326,22 @@
 					dz = thick[i];
 					sld_i = sld[i];
+					sldim_i = sld_im[i];
 				}
 				else{
 					dz = thick_inter[i-1]/nsl;
-					sld_i = interfunc(fun_type[i-1],nsl, n_s, sld[i-1], sld[i]);
+					if (sld[i-1] == sld[i]){
+						sld_i = sld[i];
+					}
+					else{
+						sld_i = interfunc(fun_type[i-1],nsl, n_s, sld[i-1], sld[i]);
+					}
+					if (sld_im[i-1] == sld_im[i]){
+						sldim_i = sld_im[i];
+					}
+					else{
+						sldim_i = interfunc(fun_type[i-1],nsl, n_s, sld_im[i-1], sld_im[i]);
+					}
 				}
-				nn = cassign(1.0-sld_i*pow(lamda,2.0)/(2.0*pi),0.0);
+				nn = cassign(1.0-sld_i*pow(lamda,2.0)/(2.0*pi),pow(lamda,2.0)/(2.0*pi)*sldim_i);
 				nn2=cmult(nn,nn);
 
@@ -366,5 +381,5 @@
  */
 double refl_analytical_1D(ReflParameters *pars, double q) {
-	double dp[47];
+	double dp[59];
 
 	dp[0] = pars->n_layers;
@@ -420,4 +435,18 @@
 	dp[46] = pars->func_inter10;
 
+	dp[47] = pars->sldIM_flat1;
+	dp[48] = pars->sldIM_flat2;
+	dp[49] = pars->sldIM_flat3;
+	dp[50] = pars->sldIM_flat4;
+	dp[51] = pars->sldIM_flat5;
+	dp[52] = pars->sldIM_flat6;
+	dp[53] = pars->sldIM_flat7;
+	dp[54] = pars->sldIM_flat8;
+	dp[55] = pars->sldIM_flat9;
+	dp[56] = pars->sldIM_flat10;
+
+	dp[57] = pars->sldIM_sub0;
+	dp[58] = pars->sldIM_medium;
+
 	return re_kernel(dp, q);
 }
Index: sansmodels/src/sans/models/c_extensions/refl.h
===================================================================
--- sansmodels/src/sans/models/c_extensions/refl.h	(revision 35aface36aa7573475600ebbacb987f50386d5f8)
+++ sansmodels/src/sans/models/c_extensions/refl.h	(revision 339ce675656e3ab89eff7b84d8292a2e0ffe6109)
@@ -142,4 +142,28 @@
     double func_inter10;
 
+    //  [DEFAULT]=sldIM_flat1=0
+    double sldIM_flat1;
+    //  [DEFAULT]=sldIM_flat2=0
+    double sldIM_flat2;
+    //  [DEFAULT]=sldIM_flat3=0
+    double sldIM_flat3;
+    //  [DEFAULT]=sldIM_flat4=0
+    double sldIM_flat4;
+    //  [DEFAULT]=sldIM_flat5=0
+    double sldIM_flat5;
+    //  [DEFAULT]=sldIM_flat6=0
+    double sldIM_flat6;
+    //  [DEFAULT]=sldIM_flat7=0
+    double sldIM_flat7;
+    //  [DEFAULT]=sldIM_flat8=0
+    double sldIM_flat8;
+    //  [DEFAULT]=sldIM_flat9=0
+    double sldIM_flat9;
+    //  [DEFAULT]=sldIM_flat10=0
+    double sldIM_flat10;
+    //  [DEFAULT]=sldIM_sub0=0
+    double sldIM_sub0;
+    //  [DEFAULT]=sldIM_medium=0
+    double sldIM_medium;
 
 } ReflParameters;
