Index: sasmodels/models/hollow_rectangular_prism.c
===================================================================
--- sasmodels/models/hollow_rectangular_prism.c	(revision 3a48772f136eb2795903c63707474e7527b4a325)
+++ sasmodels/models/hollow_rectangular_prism.c	(revision ab2aea81f7fb392e5f24f1c76dd989914d8f7022)
@@ -5,11 +5,11 @@
 double form_volume(double length_a, double b2a_ratio, double c2a_ratio, double thickness)
 {
-    double b_side = length_a * b2a_ratio;
-    double c_side = length_a * c2a_ratio;
+    double length_b = length_a * b2a_ratio;
+    double length_c = length_a * c2a_ratio;
     double a_core = length_a - 2.0*thickness;
-    double b_core = b_side - 2.0*thickness;
-    double c_core = c_side - 2.0*thickness;
+    double b_core = length_b - 2.0*thickness;
+    double c_core = length_c - 2.0*thickness;
     double vol_core = a_core * b_core * c_core;
-    double vol_total = length_a * b_side * c_side;
+    double vol_total = length_a * length_b * length_c;
     double vol_shell = vol_total - vol_core;
     return vol_shell;
@@ -26,11 +26,13 @@
     double termA1, termA2, termB1, termB2, termC1, termC2;
     
-    double b_side = length_a * b2a_ratio;
-    double c_side = length_a * c2a_ratio;
+    double length_b = length_a * b2a_ratio;
+    double length_c = length_a * c2a_ratio;
     double a_half = 0.5 * length_a;
-    double b_half = 0.5 * b_side;
-    double c_half = 0.5 * c_side;
+    double b_half = 0.5 * length_b;
+    double c_half = 0.5 * length_c;
+    double vol_total = length_a * length_b * length_c;
+    double vol_core = 8.0 * (a_half-thickness) * (b_half-thickness) * (c_half-thickness);
 
-   //Integration limits to use in Gaussian quadrature
+    //Integration limits to use in Gaussian quadrature
     double v1a = 0.0;
     double v1b = M_PI_2;  //theta integration limits
@@ -38,22 +40,16 @@
     double v2b = M_PI_2;  //phi integration limits
     
-    //Order of integration
-    int nordi=76;			        
-    int nordj=76;
+    double outer_sum = 0.0;
+    
+    for(int i=0; i<76; i++) {
 
-    double sumi = 0.0;
-    
-    for(int i=0; i<nordi; i++) {
+        double theta = 0.5 * ( Gauss76Z[i]*(v1b-v1a) + v1a + v1b );    
 
-	    double theta = 0.5 * ( Gauss76Z[i]*(v1b-v1a) + v1a + v1b );	
+        double termC1 = sinc(q * c_half * cos(theta));
+        double termC2 = sinc(q * (c_half-thickness)*cos(theta));
 
-	    double arg = q * c_half * cos(theta);
-	    if (fabs(arg) > 1.e-16) {termC1 = sin(arg)/arg;} else {termC1 = 1.0;}
-	    arg = q * (c_half-thickness)*cos(theta);
-	    if (fabs(arg) > 1.e-16) {termC2 = sin(arg)/arg;} else {termC2 = 1.0;}
-
-	    double sumj = 0.0;
+        double inner_sum = 0.0;
         
-	    for(int j=0; j<nordj; j++) {
+        for(int j=0; j<76; j++) {
 
             double phi = 0.5 * ( Gauss76Z[j]*(v2b-v2a) + v2a + v2b ); 
@@ -61,28 +57,23 @@
             // Amplitude AP from eqn. (13), rewritten to avoid round-off effects when arg=0
 
-	        arg = q * a_half * sin(theta) * sin(phi);
-	        if (fabs(arg) > 1.e-16) {termA1 = sin(arg)/arg;} else {termA1 = 1.0;}
-	        arg = q * (a_half-thickness) * sin(theta) * sin(phi);
-	        if (fabs(arg) > 1.e-16) {termA2 = sin(arg)/arg;} else {termA2 = 1.0;}
+            termA1 = sinc(q * a_half * sin(theta) * sin(phi));
+            termA2 = sinc(q * (a_half-thickness) * sin(theta) * sin(phi));
 
-	        arg = q * b_half * sin(theta) * cos(phi);
-	        if (fabs(arg) > 1.e-16) {termB1 = sin(arg)/arg;} else {termB1 = 1.0;}
-	        arg = q * (b_half-thickness) * sin(theta) * cos(phi);
-	        if (fabs(arg) > 1.e-16) {termB2 = sin(arg)/arg;} else {termB2 = 1.0;}
+            termB1 = sinc(q * b_half * sin(theta) * cos(phi));
+            termB2 = sinc(q * (b_half-thickness) * sin(theta) * cos(phi));
 
-            double AP1 = (length_a*b_side*c_side) * termA1 * termB1 * termC1;
-            double AP2 = 8.0 * (a_half-thickness) * (b_half-thickness) * (c_half-thickness) * termA2 * termB2 * termC2;
-            double AP = AP1 - AP2;
+            double AP1 = vol_total * termA1 * termB1 * termC1;
+            double AP2 = vol_core * termA2 * termB2 * termC2;
 
-	        sumj += Gauss76Wt[j] * (AP*AP);
+            inner_sum += Gauss76Wt[j] * square(AP1-AP2);
 
-	    }
+        }
 
-	    sumj = 0.5 * (v2b-v2a) * sumj;
-	    sumi += Gauss76Wt[i] * sumj * sin(theta);
+        inner_sum = 0.5 * (v2b-v2a) * inner_sum;
+        outer_sum += Gauss76Wt[i] * inner_sum * sin(theta);
 
     }
 
-    double answer = 0.5*(v1b-v1a)*sumi;
+    double answer = 0.5*(v1b-v1a)*outer_sum;
 
     // Normalize as in Eqn. (15) without the volume factor (as cancels with (V*DelRho)^2 normalization)
@@ -91,5 +82,5 @@
 
     // Multiply by contrast^2. Factor corresponding to volume^2 cancels with previous normalization.
-    answer *= (sld-solvent_sld)*(sld-solvent_sld);
+    answer *= square(sld-solvent_sld);
 
     // Convert from [1e-12 A-1] to [cm-1]
