Index: sasmodels/models/hollow_rectangular_prism.c
===================================================================
--- sasmodels/models/hollow_rectangular_prism.c	(revision ab2aea81f7fb392e5f24f1c76dd989914d8f7022)
+++ sasmodels/models/hollow_rectangular_prism.c	(revision 6f676fb91e0720edd32b0faa11126cc646a2cad7)
@@ -24,68 +24,62 @@
     double thickness)
 {
-    double termA1, termA2, termB1, termB2, termC1, termC2;
-    
-    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 * 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);
+    const double length_b = length_a * b2a_ratio;
+    const double length_c = length_a * c2a_ratio;
+    const double a_half = 0.5 * length_a;
+    const double b_half = 0.5 * length_b;
+    const double c_half = 0.5 * length_c;
+    const double vol_total = length_a * length_b * length_c;
+    const double vol_core = 8.0 * (a_half-thickness) * (b_half-thickness) * (c_half-thickness);
 
     //Integration limits to use in Gaussian quadrature
-    double v1a = 0.0;
-    double v1b = M_PI_2;  //theta integration limits
-    double v2a = 0.0;
-    double v2b = M_PI_2;  //phi integration limits
+    const double v1a = 0.0;
+    const double v1b = M_PI_2;  //theta integration limits
+    const double v2a = 0.0;
+    const double v2b = M_PI_2;  //phi integration limits
     
     double outer_sum = 0.0;
-    
     for(int i=0; i<76; i++) {
 
-        double theta = 0.5 * ( Gauss76Z[i]*(v1b-v1a) + v1a + v1b );    
+        const double theta = 0.5 * ( Gauss76Z[i]*(v1b-v1a) + v1a + v1b );
+        double sin_theta, cos_theta;
+        SINCOS(theta, sin_theta, cos_theta);
 
-        double termC1 = sinc(q * c_half * cos(theta));
-        double termC2 = sinc(q * (c_half-thickness)*cos(theta));
+        const double termC1 = sinc(q * c_half * cos(theta));
+        const double termC2 = sinc(q * (c_half-thickness)*cos(theta));
 
         double inner_sum = 0.0;
-        
         for(int j=0; j<76; j++) {
 
-            double phi = 0.5 * ( Gauss76Z[j]*(v2b-v2a) + v2a + v2b ); 
+            const double phi = 0.5 * ( Gauss76Z[j]*(v2b-v2a) + v2a + v2b );
+            double sin_phi, cos_phi;
+            SINCOS(phi, sin_phi, cos_phi);
 
             // Amplitude AP from eqn. (13), rewritten to avoid round-off effects when arg=0
 
-            termA1 = sinc(q * a_half * sin(theta) * sin(phi));
-            termA2 = sinc(q * (a_half-thickness) * sin(theta) * sin(phi));
+            const double termA1 = sinc(q * a_half * sin_theta * sin_phi);
+            const double termA2 = sinc(q * (a_half-thickness) * sin_theta * sin_phi);
 
-            termB1 = sinc(q * b_half * sin(theta) * cos(phi));
-            termB2 = sinc(q * (b_half-thickness) * sin(theta) * cos(phi));
+            const double termB1 = sinc(q * b_half * sin_theta * cos_phi);
+            const double termB2 = sinc(q * (b_half-thickness) * sin_theta * cos_phi);
 
-            double AP1 = vol_total * termA1 * termB1 * termC1;
-            double AP2 = vol_core * termA2 * termB2 * termC2;
+            const double AP1 = vol_total * termA1 * termB1 * termC1;
+            const double AP2 = vol_core * termA2 * termB2 * termC2;
 
             inner_sum += Gauss76Wt[j] * square(AP1-AP2);
+        }
+        inner_sum *= 0.5 * (v2b-v2a);
 
-        }
-
-        inner_sum = 0.5 * (v2b-v2a) * inner_sum;
         outer_sum += Gauss76Wt[i] * inner_sum * sin(theta);
-
     }
-
-    double answer = 0.5*(v1b-v1a)*outer_sum;
+    outer_sum *= 0.5*(v1b-v1a);
 
     // Normalize as in Eqn. (15) without the volume factor (as cancels with (V*DelRho)^2 normalization)
     // The factor 2 is due to the different theta integration limit (pi/2 instead of pi)
-    answer /= M_PI_2;
+    const double form = outer_sum/M_PI_2;
 
     // Multiply by contrast^2. Factor corresponding to volume^2 cancels with previous normalization.
-    answer *= square(sld-solvent_sld);
+    const double delrho = sld - solvent_sld;
 
     // Convert from [1e-12 A-1] to [cm-1]
-    answer *= 1.0e-4;
-
-    return answer;
-    
+    return 1.0e-4 * delrho * delrho * form;
 }
