Index: sasmodels/models/core_shell_bicelle_elliptical.c
===================================================================
--- sasmodels/models/core_shell_bicelle_elliptical.c	(revision dedcf34f547ba57a5e8ca3c5e9892ede11d1fcaf)
+++ sasmodels/models/core_shell_bicelle_elliptical.c	(revision 2a0b2b133086c070f586ead5c4a343a7e57ecad5)
@@ -17,29 +17,21 @@
         double thick_face,
         double length,
-        double rhoc,
-        double rhoh,
-        double rhor,
-        double rhosolv)
+        double sld_core,
+        double sld_face,
+        double sld_rim,
+        double sld_solvent)
 {
-    double si1,si2,be1,be2;
      // core_shell_bicelle_elliptical, RKH Dec 2016, based on elliptical_cylinder and core_shell_bicelle
      // tested against limiting cases of cylinder, elliptical_cylinder, stacked_discs, and core_shell_bicelle
-     //    const double uplim = M_PI_4;
     const double halfheight = 0.5*length;
-    //const double va = 0.0;
-    //const double vb = 1.0;
-    // inner integral limits
-    //const double vaj=0.0;
-    //const double vbj=M_PI;
-
     const double r_major = r_minor * x_core;
     const double r2A = 0.5*(square(r_major) + square(r_minor));
     const double r2B = 0.5*(square(r_major) - square(r_minor));
-    const double dr1 = (rhoc-rhoh)   *M_PI*r_minor*r_major*(2.0*halfheight);;
-    const double dr2 = (rhor-rhosolv)*M_PI*(r_minor+thick_rim)*(r_major+thick_rim)*2.0*(halfheight+thick_face);
-    const double dr3 = (rhoh-rhor)   *M_PI*r_minor*r_major*2.0*(halfheight+thick_face);
-    //const double vol1 = M_PI*r_minor*r_major*(2.0*halfheight);
-    //const double vol2 = M_PI*(r_minor+thick_rim)*(r_major+thick_rim)*2.0*(halfheight+thick_face);
-    //const double vol3 = M_PI*r_minor*r_major*2.0*(halfheight+thick_face);
+    const double vol1 = M_PI*r_minor*r_major*(2.0*halfheight);
+    const double vol2 = M_PI*(r_minor+thick_rim)*(r_major+thick_rim)*2.0*(halfheight+thick_face);
+    const double vol3 = M_PI*r_minor*r_major*2.0*(halfheight+thick_face);
+    const double dr1 = vol1*(sld_core-sld_face);
+    const double dr2 = vol2*(sld_rim-sld_solvent);
+    const double dr3 = vol3*(sld_face-sld_rim);
 
     //initialize integral
@@ -47,25 +39,27 @@
     for(int i=0;i<76;i++) {
         //setup inner integral over the ellipsoidal cross-section
-        // since we generate these lots of times, why not store them somewhere?
-        //const double cos_alpha = ( Gauss76Z[i]*(vb-va) + va + vb )/2.0;
-        const double cos_alpha = ( Gauss76Z[i] + 1.0 )/2.0;
-        const double sin_alpha = sqrt(1.0 - cos_alpha*cos_alpha);
-        double inner_sum=0;
-        double sinarg1 = q*halfheight*cos_alpha;
-        double sinarg2 = q*(halfheight+thick_face)*cos_alpha;
-        si1 = sas_sinx_x(sinarg1);
-        si2 = sas_sinx_x(sinarg2);
+        //const double va = 0.0;
+        //const double vb = 1.0;
+        //const double cos_theta = ( Gauss76Z[i]*(vb-va) + va + vb )/2.0;
+        const double cos_theta = ( Gauss76Z[i] + 1.0 )/2.0;
+        const double sin_theta = sqrt(1.0 - cos_theta*cos_theta);
+        const double qab = q*sin_theta;
+        const double qc = q*cos_theta;
+        const double si1 = sas_sinx_x(halfheight*qc);
+        const double si2 = sas_sinx_x((halfheight+thick_face)*qc);
+        double inner_sum=0.0;
         for(int j=0;j<76;j++) {
             //76 gauss points for the inner integral (WAS 20 points,so this may make unecessarily slow, but playing safe)
-            //const double beta = ( Gauss76Z[j]*(vbj-vaj) + vaj + vbj )/2.0;
-            const double beta = ( Gauss76Z[j] +1.0)*M_PI_2;
-            const double rr = sqrt(r2A - r2B*cos(beta));
-            double besarg1 = q*rr*sin_alpha;
-            double besarg2 = q*(rr+thick_rim)*sin_alpha;
-            be1 = sas_2J1x_x(besarg1);
-            be2 = sas_2J1x_x(besarg2);
-            inner_sum += Gauss76Wt[j] *square(dr1*si1*be1 +
-                                              dr2*si2*be2 +
-                                              dr3*si2*be1);
+            // inner integral limits
+            //const double vaj=0.0;
+            //const double vbj=M_PI;
+            //const double phi = ( Gauss76Z[j]*(vbj-vaj) + vaj + vbj )/2.0;
+            const double phi = ( Gauss76Z[j] +1.0)*M_PI_2;
+            const double rr = sqrt(r2A - r2B*cos(phi));
+            const double be1 = sas_2J1x_x(rr*qab);
+            const double be2 = sas_2J1x_x((rr+thick_rim)*qab);
+            const double fq = dr1*si1*be1 + dr2*si2*be2 + dr3*si2*be1;
+
+            inner_sum += Gauss76Wt[j] * fq * fq;
         }
         //now calculate outer integral
@@ -83,18 +77,21 @@
           double thick_face,
           double length,
-          double rhoc,
-          double rhoh,
-          double rhor,
-          double rhosolv,
+          double sld_core,
+          double sld_face,
+          double sld_rim,
+          double sld_solvent,
           double theta,
           double phi,
           double psi)
 {
-       // THIS NEEDS TESTING
     double q, xhat, yhat, zhat;
     ORIENT_ASYMMETRIC(qx, qy, theta, phi, psi, q, xhat, yhat, zhat);
-    const double dr1 = rhoc-rhoh;
-    const double dr2 = rhor-rhosolv;
-    const double dr3 = rhoh-rhor;
+    const double qa = q*xhat;
+    const double qb = q*yhat;
+    const double qc = q*zhat;
+
+    const double dr1 = sld_core-sld_face;
+    const double dr2 = sld_rim-sld_solvent;
+    const double dr3 = sld_face-sld_rim;
     const double r_major = r_minor*x_core;
     const double halfheight = 0.5*length;
@@ -104,13 +101,12 @@
 
     // Compute effective radius in rotated coordinates
-    const double r_hat = sqrt(square(r_major*xhat) + square(r_minor*yhat));
-    const double rshell_hat = sqrt(square((r_major+thick_rim)*xhat)
-                                   + square((r_minor+thick_rim)*yhat));
-    const double be1 = sas_2J1x_x( q*r_hat );
-    const double be2 = sas_2J1x_x( q*rshell_hat );
-    const double si1 = sas_sinx_x( q*halfheight*zhat );
-    const double si2 = sas_sinx_x( q*(halfheight + thick_face)*zhat );
-    const double Aq = square( vol1*dr1*si1*be1 + vol2*dr2*si2*be2 +  vol3*dr3*si2*be1);
-    return 1.0e-4 * Aq;
+    const double qr_hat = sqrt(square(r_major*qa) + square(r_minor*qb));
+    const double qrshell_hat = sqrt(square((r_major+thick_rim)*qa)
+                                   + square((r_minor+thick_rim)*qb));
+    const double be1 = sas_2J1x_x( qr_hat );
+    const double be2 = sas_2J1x_x( qrshell_hat );
+    const double si1 = sas_sinx_x( halfheight*qc );
+    const double si2 = sas_sinx_x( (halfheight + thick_face)*qc );
+    const double fq = vol1*dr1*si1*be1 + vol2*dr2*si2*be2 +  vol3*dr3*si2*be1;
+    return 1.0e-4 * fq*fq;
 }
-
