Index: sansmodels/src/sans/models/c_extensions/capcyl.c
===================================================================
--- sansmodels/src/sans/models/c_extensions/capcyl.c	(revision 4628e31d33c0fcf223d4c2cf0eb3acdf634737a2)
+++ sansmodels/src/sans/models/c_extensions/capcyl.c	(revision 890ac7f156aa123d3a2d72d1e43ca2a08af66966)
@@ -6,4 +6,5 @@
 #include "GaussWeights.h"
 #include "libCylinder.h"
+#include <stdio.h>
 
 /**
@@ -133,4 +134,8 @@
 	double answer;
 	double dp[7];
+  //convert angle degree to radian
+  double pi = 4.0*atan(1.0);
+  double theta = pars->theta * pi/180.0;
+  double phi = pars->phi * pi/180.0;
 
 	dp[0] = pars->scale;
@@ -141,9 +146,4 @@
 	dp[5] = pars->sld_solv;
 	dp[6] = pars->background;
-
-	//convert angle degree to radian
-	double pi = 4.0*atan(1.0);
-	double theta = pars->theta * pi/180.0;
-	double phi = pars->phi * pi/180.0;
 
 
Index: sansmodels/src/sans/models/c_extensions/csparallelepiped.c
===================================================================
--- sansmodels/src/sans/models/c_extensions/csparallelepiped.c	(revision 4628e31d33c0fcf223d4c2cf0eb3acdf634737a2)
+++ sansmodels/src/sans/models/c_extensions/csparallelepiped.c	(revision 890ac7f156aa123d3a2d72d1e43ca2a08af66966)
@@ -160,4 +160,14 @@
 double csparallelepiped_analytical_2D_scaled(CSParallelepipedParameters *pars, double q, double q_x, double q_y) {
 	double dp[13];
+  double cparallel_x, cparallel_y, cparallel_z, bparallel_x, bparallel_y, parallel_x, parallel_y, parallel_z;
+  double q_z;
+  double alpha, vol, cos_val_c, cos_val_b, cos_val_a, edgeA, edgeB, edgeC;
+
+  double answer;
+  //convert angle degree to radian
+  double pi = 4.0*atan(1.0);
+  double theta = pars->parallel_theta * pi/180.0;
+  double phi = pars->parallel_phi * pi/180.0;
+  double psi = pars->parallel_psi* pi/180.0;
 
 	// Fill paramater array
@@ -176,9 +186,4 @@
 	dp[12] = 0.0;
 
-	double cparallel_x, cparallel_y, cparallel_z, bparallel_x, bparallel_y, parallel_x, parallel_y, parallel_z;
-	double q_z;
-	double alpha, vol, cos_val_c, cos_val_b, cos_val_a, edgeA, edgeB, edgeC;
-
-	double answer;
 
 	edgeA = pars->shortA;
@@ -186,9 +191,4 @@
 	edgeC = pars->longC;
 
-	//convert angle degree to radian
-	double pi = 4.0*atan(1.0);
-	double theta = pars->parallel_theta * pi/180.0;
-	double phi = pars->parallel_phi * pi/180.0;
-	double psi = pars->parallel_psi* pi/180.0;
 
     // parallelepiped c axis orientation
Index: sansmodels/src/sans/models/c_extensions/fcc.c
===================================================================
--- sansmodels/src/sans/models/c_extensions/fcc.c	(revision 4628e31d33c0fcf223d4c2cf0eb3acdf634737a2)
+++ sansmodels/src/sans/models/c_extensions/fcc.c	(revision 890ac7f156aa123d3a2d72d1e43ca2a08af66966)
@@ -5,5 +5,5 @@
 #include "libSphere.h"
 #include <math.h>
-
+#include <stdio.h>
 
 /**
@@ -68,4 +68,8 @@
 
 	double dp[5];
+  //convert angle degree to radian
+  double theta = pars->theta * Pi/180.0;
+  double phi = pars->phi * Pi/180.0;
+  double psi = pars->psi * Pi/180.0;
 	dp[0] = 1.0;
 	dp[1] = pars->radius;
@@ -73,8 +77,4 @@
 	dp[3] = pars->sldSolv;
 	dp[4] = 0.0;
-	//convert angle degree to radian
-	double theta = pars->theta * Pi/180.0;
-	double phi = pars->phi * Pi/180.0;
-	double psi = pars->psi * Pi/180.0;
 
 	aa = pars->dnn;
Index: sansmodels/src/sans/models/c_extensions/onion.c
===================================================================
--- sansmodels/src/sans/models/c_extensions/onion.c	(revision 0164899a491d20467a714225f7ea955c852265f3)
+++ sansmodels/src/sans/models/c_extensions/onion.c	(revision 890ac7f156aa123d3a2d72d1e43ca2a08af66966)
@@ -22,4 +22,8 @@
 	int fun_type[n+2];
 	int i,j;
+  double bes,fun,alpha,f,vol,vol_pre,vol_sub,qr,r,contr,f2;
+  double sign;
+  double pi;
+  double r0 = 0.0;
 
 	for (i =1; i<=n; i++){
@@ -41,7 +45,4 @@
 	fun_type[n+1] = 0;
 
-    double bes,fun,alpha,f,vol,vol_pre,vol_sub,qr,r,contr,f2;
-    double sign;
-    double pi;
 
     pi = 4.0*atan(1.0);
@@ -51,5 +52,4 @@
     vol_pre = 0.0;
     vol_sub = 0.0;
-    double r0 = 0.0;
 
     for (i =0; i<= n+1; i++){
Index: sansmodels/src/sans/models/c_extensions/parallelepiped.c
===================================================================
--- sansmodels/src/sans/models/c_extensions/parallelepiped.c	(revision 4628e31d33c0fcf223d4c2cf0eb3acdf634737a2)
+++ sansmodels/src/sans/models/c_extensions/parallelepiped.c	(revision 890ac7f156aa123d3a2d72d1e43ca2a08af66966)
@@ -106,12 +106,13 @@
 	double pi = 4.0*atan(1.0);
 
+  //convert angle degree to radian
+  double theta = pars->parallel_theta * pi/180.0;
+  double phi = pars->parallel_phi * pi/180.0;
+  double psi = pars->parallel_psi * pi/180.0;
+
 	edgeA = pars->short_a;
 	edgeB = pars->short_b;
 	edgeC = pars->long_c;
 
-	//convert angle degree to radian
-	double theta = pars->parallel_theta * pi/180.0;
-	double phi = pars->parallel_phi * pi/180.0;
-	double psi = pars->parallel_psi * pi/180.0;
 
     // parallelepiped c axis orientation
Index: sansmodels/src/sans/models/c_extensions/pearlnecklace.c
===================================================================
--- sansmodels/src/sans/models/c_extensions/pearlnecklace.c	(revision 9cc3da6768743c3979f378fe701132b85e3c4b49)
+++ sansmodels/src/sans/models/c_extensions/pearlnecklace.c	(revision 890ac7f156aa123d3a2d72d1e43ca2a08af66966)
@@ -37,13 +37,24 @@
 	//total volume
 	double tot_vol;
-	tot_vol = num_strings * string_vol;
+  //each masses
+  double m_r= contrast_string * string_vol;
+  double m_s= contrast_pearl * pearl_vol;
+  double psi;
+  double gamma;
+  double beta;
+  //form factors
+  double sss; //pearls
+  double srr; //strings
+  double srs; //cross
+  double A_s;
+  double srr_1;
+  double srr_2;
+  double srr_3;
+  double form_factor;
+
+  tot_vol = num_strings * string_vol;
 	tot_vol += num_pearls * pearl_vol;
 
-	//each masses
-	double m_r= contrast_string * string_vol;
-	double m_s= contrast_pearl * pearl_vol;
-
 	//sine functions of a pearl
-	double psi;
 	psi = sin(q*radius);
 	psi -= q * radius * cos(q * radius);
@@ -52,18 +63,12 @@
 
 	// Note take only 20 terms in Si series: 10 terms may be enough though.
-	double gamma;
 	gamma = Si(q* edge_separation);
 	gamma /= (q* edge_separation);
-	double beta;
 	beta = Si(q * (edge_separation + radius));
 	beta -= Si(q * radius);
 	beta /= (q* edge_separation);
 
-	//form factors
-	double sss; //pearls
-	double srr; //strings
-	double srs; //cross
 	// center to center distance between the neighboring pearls
-	double A_s = edge_separation + 2.0 * radius;
+	A_s = edge_separation + 2.0 * radius;
 
 	// form factor for num_pearls
@@ -76,14 +81,11 @@
 
 	// form factor for num_strings (like thin rods)
-	double srr_1;
 	srr_1 = -pow(sinc(q*edge_separation/2.0), 2);
 
 	srr_1 += 2.0 * gamma;
 	srr_1 *= num_strings;
-	double srr_2;
 	srr_2 = 2.0/(1.0-sinc(q*A_s));
 	srr_2 *= num_strings;
 	srr_2 *= pow(beta, 2);
-	double srr_3;
 	srr_3 = 1.0 - pow(sinc(q*A_s), num_strings);
 	srr_3 /= pow((1.0-sinc(q*A_s)), 2);
@@ -104,5 +106,4 @@
 	srs *= (m_r * m_s * beta * psi);
 
-	double form_factor;
 	form_factor = sss + srr + srs;
 	form_factor /= (tot_vol * 1.0e-8); // norm by volume and A^-1 to cm^-1
Index: sansmodels/src/sans/models/c_extensions/refl.c
===================================================================
--- sansmodels/src/sans/models/c_extensions/refl.c	(revision 0164899a491d20467a714225f7ea955c852265f3)
+++ sansmodels/src/sans/models/c_extensions/refl.c	(revision 890ac7f156aa123d3a2d72d1e43ca2a08af66966)
@@ -24,5 +24,11 @@
 
 	double sld[n+2],thick_inter[n+2],thick[n+2],total_thick;
-	fun_type[0] = dp[3];
+  double nsl=21.0; //nsl = Num_sub_layer:
+  int n_s;
+  double sld_i,sldim_i,dz,phi,R,ko2;
+  double sign,erfunc, fun;
+  double pi;
+
+  fun_type[0] = dp[3];
 	for (i =1; i<=n; i++){
 		sld[i] = dp[i+6];
@@ -40,9 +46,4 @@
 	thick_inter[n+1] = 0.0;
 
-	double nsl=21.0; //nsl = Num_sub_layer:
-	int n_s;
-    double sld_i,sldim_i,dz,phi,R,ko2;
-    double sign,erfunc, fun;
-    double pi;
 	complex  inv_n,phi1,alpha,alpha2,kn,fnm,fnp,rn,Xn,nn,nn2,an,nnp1,one,zero,two,n_sub,n_sup,knp1,Xnp1;
 	pi = 4.0*atan(1.0);
Index: sansmodels/src/sans/models/c_extensions/refl_adv.c
===================================================================
--- sansmodels/src/sans/models/c_extensions/refl_adv.c	(revision 96656e3ad6cdb9f8256e2118c60bac29635136af)
+++ sansmodels/src/sans/models/c_extensions/refl_adv.c	(revision 890ac7f156aa123d3a2d72d1e43ca2a08af66966)
@@ -16,4 +16,5 @@
 	int n = dp[0];
 	int i,j,fun_type[n+2];
+	double nsl;
 
 	double scale = dp[1];
@@ -25,5 +26,11 @@
 
 	double sld[n+2],sld_im[n+2],thick_inter[n+2],thick[n+2],fun_coef[n+2],total_thick;
-	fun_type[0] = dp[3];
+
+  int n_s;
+  double sld_i,sldim_i,dz,phi,R,ko2;
+  double sign,erfunc;
+  double pi;
+
+  fun_type[0] = dp[3];
 	fun_coef[0] = fabs(dp[70]);
 	for (i =1; i<=n; i++){
@@ -48,10 +55,6 @@
 	fun_coef[n+1] = 0.0;
 
-	double nsl=npts;//21.0; //nsl = Num_sub_layer:  MUST ODD number in double //no other number works now
-	int n_s;
-
-    double sld_i,sldim_i,dz,phi,R,ko2;
-    double sign,erfunc;
-    double pi;
+	nsl=npts;//21.0; //nsl = Num_sub_layer:  MUST ODD number in double //no other number works now
+
 	complex  inv_n,phi1,alpha,alpha2,kn,fnm,fnp,rn,Xn,nn,nn2,an,nnp1,one,zero,two,n_sub,n_sup,knp1,Xnp1;
 	pi = 4.0*atan(1.0);
Index: sansmodels/src/sans/models/c_extensions/sc.c
===================================================================
--- sansmodels/src/sans/models/c_extensions/sc.c	(revision 4628e31d33c0fcf223d4c2cf0eb3acdf634737a2)
+++ sansmodels/src/sans/models/c_extensions/sc.c	(revision 890ac7f156aa123d3a2d72d1e43ca2a08af66966)
@@ -5,4 +5,5 @@
 #include "libSphere.h"
 #include <math.h>
+#include <stdio.h>
 
 
@@ -67,4 +68,8 @@
 
 	double dp[5];
+  //convert angle degree to radian
+  double theta = pars->theta * Pi/180.0;
+  double phi = pars->phi * Pi/180.0;
+  double psi = pars->psi * Pi/180.0;
 	dp[0] = 1.0;
 	dp[1] = pars->radius;
@@ -73,8 +78,4 @@
 	dp[4] = 0.0;
 
-	//convert angle degree to radian
-	double theta = pars->theta * Pi/180.0;
-	double phi = pars->phi * Pi/180.0;
-	double psi = pars->psi * Pi/180.0;
 
 	aa = pars->dnn;
Index: sansmodels/src/sans/models/c_extensions/sld_cal.c
===================================================================
--- sansmodels/src/sans/models/c_extensions/sld_cal.c	(revision 0164899a491d20467a714225f7ea955c852265f3)
+++ sansmodels/src/sans/models/c_extensions/sld_cal.c	(revision 890ac7f156aa123d3a2d72d1e43ca2a08af66966)
@@ -17,4 +17,5 @@
 double sld_cal_analytical_1D(SLDCalParameters *pars, double x) {
 	double fun, nsl, n_s, fun_coef, sld_l, sld_r, sld_out;
+	int fun_type;
 
 	fun = pars->fun_type;
@@ -25,5 +26,5 @@
 	sld_r = pars-> sld_right;
 
-	int fun_type = floor(fun);
+	fun_type = floor(fun);
 
 	sld_out = intersldfunc(fun_type, nsl, n_s, fun_coef, sld_l, sld_r);
Index: sansmodels/src/sans/models/c_extensions/spheresld.c
===================================================================
--- sansmodels/src/sans/models/c_extensions/spheresld.c	(revision 0164899a491d20467a714225f7ea955c852265f3)
+++ sansmodels/src/sans/models/c_extensions/spheresld.c	(revision 890ac7f156aa123d3a2d72d1e43ca2a08af66966)
@@ -45,7 +45,8 @@
 	int floor_nsl;
 
-    double sld_i,sld_f,dz,bes,fun,f,vol,vol_pre,vol_sub,qr,r,contr,f2;
-    double sign,slope=0.0;
-    double pi;
+  double sld_i,sld_f,dz,bes,fun,f,vol,vol_pre,vol_sub,qr,r,contr,f2;
+  double sign,slope=0.0;
+  double pi;
+  double r0 = 0.0, thick_inter_f;
 
     pi = 4.0*atan(1.0);
@@ -56,5 +57,4 @@
     vol_sub = 0.0;
     sld_f = sld_core;
-    double r0 = 0.0, thick_inter_f;
 
 	//floor_nsl = floor(nsl/2.0);
