Index: run.py
===================================================================
--- run.py	(revision 952ea1fd0d931d2eae09831204ea057abfe5450f)
+++ run.py	(revision bc8b8a1eb1a0f65ae6814fb0a8aabf3e2dce40b6)
@@ -67,5 +67,5 @@
 
 
-def prepare(rebuild=True):
+def prepare():
     # Don't create *.pyc files
     sys.dont_write_bytecode = True
@@ -95,15 +95,15 @@
     try:
         import periodictable
-    except ImportError:
+    except:
         addpath(joinpath(root, '..', 'periodictable'))
 
     try:
         import bumps
-    except ImportError:
+    except:
         addpath(joinpath(root, '..', 'bumps'))
 
     try:
         import tinycc
-    except ImportError:
+    except:
         addpath(joinpath(root, '../tinycc/build/lib'))
 
@@ -111,22 +111,9 @@
     #addpath(os.path.join(root, '..','wxPython-src-3.0.0.0','wxPython'))
 
-    # Put the sas source tree on the path
-    addpath(joinpath(root, 'src'))
-
-    # Put sasmodels on the path
-    addpath(joinpath(root, '../sasmodels/'))
-
-    # Check if the C extensions are already built
-    try:
-        from sas.sascalc.pr import _pr_inversion
-        from sas.sascalc.calculator import _sld2i
-        from sas.sascalc.file_converter import _bsl_loader
-    except ImportError:
-        rebuild = True
-
-    # Build C extensions if necessary.  Do an inplace build to simplify path.
-    if rebuild:
+    # Build project if the build directory does not already exist.
+    # PAK: with "update" we can always build since it is fast
+    if True or not os.path.exists(build_path):
         import subprocess
-        build_cmd = [sys.executable, "setup.py", "build_ext", "--inplace", "update"]
+        build_cmd = [sys.executable, "setup.py", "build", "update"]
         if os.name == 'nt':
             build_cmd.append('--compiler=tinycc')
@@ -135,4 +122,31 @@
         with cd(root):
             subprocess.call(build_cmd, shell=shell)
+
+    # Put the source trees on the path
+    addpath(joinpath(root, 'src'))
+
+    # sasmodels on the path
+    addpath(joinpath(root, '../sasmodels/'))
+
+    # The sas.models package Compiled Model files should be pulled in from the build directory even though
+    # the source is stored in src/sas/models.
+
+    # Compiled modules need to be pulled from the build directory.
+    # Some packages are not where they are needed, so load them explicitly.
+    import sas.sascalc.pr
+    sas.sascalc.pr.core = import_package('sas.sascalc.pr.core',
+                                         joinpath(build_path, 'sas', 'sascalc', 'pr', 'core'))
+
+    # Compiled modules need to be pulled from the build directory.
+    # Some packages are not where they are needed, so load them explicitly.
+    import sas.sascalc.file_converter
+    sas.sascalc.file_converter.core = import_package('sas.sascalc.file_converter.core',
+                                                     joinpath(build_path, 'sas', 'sascalc', 'file_converter', 'core'))
+
+    import sas.sascalc.calculator
+    sas.sascalc.calculator.core = import_package('sas.sascalc.calculator.core',
+                                                 joinpath(build_path, 'sas', 'sascalc', 'calculator', 'core'))
+
+    sys.path.append(build_path)
 
     set_git_tag()
Index: setup.py
===================================================================
--- setup.py	(revision 952ea1fd0d931d2eae09831204ea057abfe5450f)
+++ setup.py	(revision c16172d313e67da70e771029395ec7bd2bdba4e6)
@@ -12,10 +12,9 @@
 import shutil
 import sys
+from distutils.command.build_ext import build_ext
+from distutils.core import Command
 
 import numpy as np
-
 from setuptools import Extension, setup
-from setuptools import Command
-from setuptools.command.build_ext import build_ext
 
 try:
@@ -23,7 +22,4 @@
 except ImportError:
     pass
-
-# Convert "test" argument to "pytest" so 'python setup.py test' works
-sys.argv = [("pytest" if s == "test" else s) for s in sys.argv]
 
 # Manage version number ######################################
@@ -250,8 +246,9 @@
 # sas.sascalc.calculator
 gen_dir = os.path.join("src", "sas", "sascalc", "calculator", "c_extensions")
+package_dir["sas.sascalc.calculator.core"] = gen_dir
 package_dir["sas.sascalc.calculator"] = os.path.join(
     "src", "sas", "sascalc", "calculator")
-packages.append("sas.sascalc.calculator")
-ext_modules.append(Extension("sas.sascalc.calculator._sld2i",
+packages.extend(["sas.sascalc.calculator", "sas.sascalc.calculator.core"])
+ext_modules.append(Extension("sas.sascalc.calculator.core.sld2i",
                              sources=[
                                  os.path.join(gen_dir, "sld2i_module.c"),
@@ -261,11 +258,13 @@
                              ],
                              include_dirs=[gen_dir],
-                             ))
+                             )
+                   )
 
 # sas.sascalc.pr
 srcdir = os.path.join("src", "sas", "sascalc", "pr", "c_extensions")
+package_dir["sas.sascalc.pr.core"] = srcdir
 package_dir["sas.sascalc.pr"] = os.path.join("src", "sas", "sascalc", "pr")
-packages.append("sas.sascalc.pr")
-ext_modules.append(Extension("sas.sascalc.pr._pr_inversion",
+packages.extend(["sas.sascalc.pr", "sas.sascalc.pr.core"])
+ext_modules.append(Extension("sas.sascalc.pr.core.pr_inversion",
                              sources=[os.path.join(srcdir, "Cinvertor.c"),
                                       os.path.join(srcdir, "invertor.c"),
@@ -277,8 +276,10 @@
 # sas.sascalc.file_converter
 mydir = os.path.join("src", "sas", "sascalc", "file_converter", "c_ext")
+package_dir["sas.sascalc.file_converter.core"] = mydir
 package_dir["sas.sascalc.file_converter"] = os.path.join(
     "src", "sas", "sascalc", "file_converter")
-packages.append("sas.sascalc.file_converter")
-ext_modules.append(Extension("sas.sascalc.file_converter._bsl_loader",
+packages.extend(["sas.sascalc.file_converter",
+                 "sas.sascalc.file_converter.core"])
+ext_modules.append(Extension("sas.sascalc.file_converter.core.bsl_loader",
                              sources=[os.path.join(mydir, "bsl_loader.c")],
                              include_dirs=[np.get_include()],
@@ -442,6 +443,4 @@
     cmdclass={'build_ext': build_ext_subclass,
               'docs': BuildSphinxCommand,
-              'disable_openmp': DisableOpenMPCommand},
-    setup_requires=['pytest-runner'] if 'pytest' in sys.argv else [],
-    tests_require=['pytest'],
+              'disable_openmp': DisableOpenMPCommand}
 )
Index: src/sas/sascalc/calculator/c_extensions/__init__.py
===================================================================
--- src/sas/sascalc/calculator/c_extensions/__init__.py	(revision a57ae0704487b63fbba07d89eff101d45ec4a470)
+++ src/sas/sascalc/calculator/c_extensions/__init__.py	(revision a57ae0704487b63fbba07d89eff101d45ec4a470)
@@ -0,0 +1,3 @@
+"""
+    C extensions to provide the sas_gen computations.
+"""
Index: src/sas/sascalc/calculator/c_extensions/sld2i_module.c
===================================================================
--- src/sas/sascalc/calculator/c_extensions/sld2i_module.c	(revision 7ba64705ddaa18ab8bce14ae2ac2e767b23eb313)
+++ src/sas/sascalc/calculator/c_extensions/sld2i_module.c	(revision a1daf86c0d7d0aba84e29d778ffd6148e933d93a)
@@ -2,9 +2,6 @@
   SLD2I module to perform point and I calculations
  */
+#include <Python.h>
 #include <stdio.h>
-
-//#define Py_LIMITED_API 0x03020000
-#include <Python.h>
-
 #include "sld2i.h"
 
@@ -16,24 +13,20 @@
 #endif
 
-// Vector binding glue
-#if (PY_VERSION_HEX > 0x03000000) && !defined(Py_LIMITED_API)
-  // Assuming that a view into a writable vector points to a 
-  // non-changing pointer for the duration of the C call, capture 
-  // the view pointer and immediately free the view.
-  #define VECTOR(VEC_obj, VEC_buf, VEC_len) do { \
-    Py_buffer VEC_view; \
-    int VEC_err = PyObject_GetBuffer(VEC_obj, &VEC_view, PyBUF_WRITABLE|PyBUF_FORMAT); \
-    if (VEC_err < 0 || sizeof(*VEC_buf) != VEC_view.itemsize) return NULL; \
-    VEC_buf = (typeof(VEC_buf))VEC_view.buf; \
-    VEC_len = VEC_view.len/sizeof(*VEC_buf); \
-    PyBuffer_Release(&VEC_view); \
-  } while (0)
-#else
-  #define VECTOR(VEC_obj, VEC_buf, VEC_len) do { \
-    int VEC_err = PyObject_AsWriteBuffer(VEC_obj, (void **)(&VEC_buf), &VEC_len); \
-    if (VEC_err < 0) return NULL; \
-    VEC_len /= sizeof(*VEC_buf); \
-  } while (0)
-#endif
+
+// Utilities
+#define INVECTOR(obj,buf,len)										\
+    do { \
+        int err = PyObject_AsReadBuffer(obj, (const void **)(&buf), &len); \
+        if (err < 0) return NULL; \
+        len /= sizeof(*buf); \
+    } while (0)
+
+#define OUTVECTOR(obj,buf,len) \
+    do { \
+        int err = PyObject_AsWriteBuffer(obj, (void **)(&buf), &len); \
+        if (err < 0) return NULL; \
+        len /= sizeof(*buf); \
+    } while (0)
+
 
 /**
@@ -80,12 +73,12 @@
 	//printf("new GenI\n");
 	if (!PyArg_ParseTuple(args, "iOOOOOOOOddd", &is_avg, &x_val_obj, &y_val_obj, &z_val_obj, &sldn_val_obj, &mx_val_obj, &my_val_obj, &mz_val_obj, &vol_pix_obj, &inspin, &outspin, &stheta)) return NULL;
-	VECTOR(x_val_obj, x_val, n_x);
-	VECTOR(y_val_obj, y_val, n_y);
-	VECTOR(z_val_obj, z_val, n_z);
-	VECTOR(sldn_val_obj, sldn_val, n_sld);
-	VECTOR(mx_val_obj, mx_val, n_mx);
-	VECTOR(my_val_obj, my_val, n_my);
-	VECTOR(mz_val_obj, mz_val, n_mz);
-	VECTOR(vol_pix_obj, vol_pix, n_vol_pix);
+	INVECTOR(x_val_obj, x_val, n_x);
+	INVECTOR(y_val_obj, y_val, n_y);
+	INVECTOR(z_val_obj, z_val, n_z);
+	INVECTOR(sldn_val_obj, sldn_val, n_sld);
+	INVECTOR(mx_val_obj, mx_val, n_mx);
+	INVECTOR(my_val_obj, my_val, n_my);
+	INVECTOR(mz_val_obj, mz_val, n_mz);
+	INVECTOR(vol_pix_obj, vol_pix, n_vol_pix);
 	sld2i = PyMem_Malloc(sizeof(GenI));
 	//printf("sldi:%p\n", sld2i);
@@ -115,7 +108,7 @@
 	if (!PyArg_ParseTuple(args, "OOOO",  &gen_obj, &qx_obj, &qy_obj, &I_out_obj)) return NULL;
 	sld2i = (GenI *)PyCapsule_GetPointer(gen_obj, "GenI");
-	VECTOR(qx_obj, qx, n_qx);
-	VECTOR(qy_obj, qy, n_qy);
-	VECTOR(I_out_obj, I_out, n_out);
+	INVECTOR(qx_obj, qx, n_qx);
+	INVECTOR(qy_obj, qy, n_qy);
+	OUTVECTOR(I_out_obj, I_out, n_out);
 	//printf("qx, qy, I_out: %d %d %d, %d %d %d\n", qx, qy, I_out, n_qx, n_qy, n_out);
 
@@ -143,6 +136,6 @@
 	if (!PyArg_ParseTuple(args, "OOO",  &gen_obj, &q_obj, &I_out_obj)) return NULL;
 	sld2i = (GenI *)PyCapsule_GetPointer(gen_obj, "GenI");
-	VECTOR(q_obj, q, n_q);
-	VECTOR(I_out_obj, I_out, n_out);
+	INVECTOR(q_obj, q, n_q);
+	OUTVECTOR(I_out_obj, I_out, n_out);
 
 	// Sanity check
@@ -167,7 +160,7 @@
 
 #define MODULE_DOC "Sld2i C Library"
-#define MODULE_NAME "_sld2i"
-#define MODULE_INIT2 init_sld2i
-#define MODULE_INIT3 PyInit__sld2i
+#define MODULE_NAME "sld2i"
+#define MODULE_INIT2 initsld2i
+#define MODULE_INIT3 PyInit_sld2i
 #define MODULE_METHODS module_methods
 
Index: src/sas/sascalc/calculator/sas_gen.py
===================================================================
--- src/sas/sascalc/calculator/sas_gen.py	(revision 952ea1fd0d931d2eae09831204ea057abfe5450f)
+++ src/sas/sascalc/calculator/sas_gen.py	(revision 144e032af2559d8208e907563f404ab479862dbf)
@@ -14,5 +14,5 @@
 import numpy as np
 
-from . import _sld2i
+from .core import sld2i as mod
 from .BaseComponent import BaseComponent
 
@@ -145,15 +145,15 @@
             self.params['Up_frac_out'],
             self.params['Up_theta'])
-        model = _sld2i.new_GenI(*args)
+        model = mod.new_GenI(*args)
         if len(qy):
             qx, qy = _vec(qx), _vec(qy)
             I_out = np.empty_like(qx)
             #print("npoints", qx.shape, "npixels", pos_x.shape)
-            _sld2i.genicomXY(model, qx, qy, I_out)
+            mod.genicomXY(model, qx, qy, I_out)
             #print("I_out after", I_out)
         else:
             qx = _vec(qx)
             I_out = np.empty_like(qx)
-            _sld2i.genicom(model, qx, I_out)
+            mod.genicom(model, qx, I_out)
         vol_correction = self.data_total_volume / self.params['total_volume']
         result = (self.params['scale'] * vol_correction * I_out
@@ -304,6 +304,6 @@
                 z_dir2 *= z_dir2
                 mask = (x_dir2 + y_dir2 + z_dir2) <= 1.0
-            except Exception as exc:
-                logger.error(exc)
+            except Exception:
+                logger.error(sys.exc_value)
         self.output = MagSLD(self.pos_x[mask], self.pos_y[mask],
                              self.pos_z[mask], self.sld_n[mask],
@@ -600,6 +600,6 @@
                         y_lines.append(y_line)
                         z_lines.append(z_line)
-                except Exception as exc:
-                    logger.error(exc)
+                except Exception:
+                    logger.error(sys.exc_value)
 
             output = MagSLD(pos_x, pos_y, pos_z, sld_n, sld_mx, sld_my, sld_mz)
@@ -691,9 +691,9 @@
                             _vol_pix = float(toks[7])
                             vol_pix = np.append(vol_pix, _vol_pix)
-                        except Exception as exc:
+                        except Exception:
                             vol_pix = None
-                    except Exception as exc:
+                    except Exception:
                         # Skip non-data lines
-                        logger.error(exc)
+                        logger.error(sys.exc_value)
             output = MagSLD(pos_x, pos_y, pos_z, sld_n,
                             sld_mx, sld_my, sld_mz)
Index: src/sas/sascalc/file_converter/bsl_loader.py
===================================================================
--- src/sas/sascalc/file_converter/bsl_loader.py	(revision 952ea1fd0d931d2eae09831204ea057abfe5450f)
+++ src/sas/sascalc/file_converter/bsl_loader.py	(revision f00691d4eb5ea44608db5bc5dba2511a65165909)
@@ -1,3 +1,3 @@
-from sas.sascalc.file_converter._bsl_loader import CLoader
+from sas.sascalc.file_converter.core.bsl_loader import CLoader
 from sas.sascalc.dataloader.data_info import Data2D
 from copy import deepcopy
@@ -67,5 +67,5 @@
                     'swap_bytes': int(metadata[3])
                 }
-            except Exception:
+            except:
                 is_valid = False
                 err_msg = "Invalid metadata in header file for {}"
Index: src/sas/sascalc/file_converter/c_ext/__init__.py
===================================================================
--- src/sas/sascalc/file_converter/c_ext/__init__.py	(revision a26f67f1457e7e39b79d4c3800c03bcaa208dff7)
+++ src/sas/sascalc/file_converter/c_ext/__init__.py	(revision a26f67f1457e7e39b79d4c3800c03bcaa208dff7)
@@ -0,0 +1,3 @@
+"""
+    Data loader for the Diamond BSL beamline.
+"""
Index: src/sas/sascalc/file_converter/c_ext/bsl_loader.c
===================================================================
--- src/sas/sascalc/file_converter/c_ext/bsl_loader.c	(revision 952ea1fd0d931d2eae09831204ea057abfe5450f)
+++ src/sas/sascalc/file_converter/c_ext/bsl_loader.c	(revision d5aeaa3a97e3a88347ad8b3aad7acfd95e97de89)
@@ -1,11 +1,8 @@
+#include <Python.h>
+#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
+#include <numpy/arrayobject.h>
 #include <stdio.h>
 #include <stdlib.h>
-
-//#define Py_LIMITED_API 0x03020000
-#include <Python.h>
-#include <structmember.h>
-#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
-#include <numpy/arrayobject.h>
-
+#include "structmember.h"
 #include "bsl_loader.h"
 
@@ -295,7 +292,7 @@
 
 #define MODULE_DOC "C module for loading bsl."
-#define MODULE_NAME "_bsl_loader"
-#define MODULE_INIT2 init_bsl_loader
-#define MODULE_INIT3 PyInit__bsl_loader
+#define MODULE_NAME "bsl_loader"
+#define MODULE_INIT2 initbsl_loader
+#define MODULE_INIT3 PyInit_bsl_loader
 #define MODULE_METHODS module_methods
 
Index: src/sas/sascalc/pr/c_extensions/Cinvertor.c
===================================================================
--- src/sas/sascalc/pr/c_extensions/Cinvertor.c	(revision 7ba64705ddaa18ab8bce14ae2ac2e767b23eb313)
+++ src/sas/sascalc/pr/c_extensions/Cinvertor.c	(revision a52f32f0dbf9ba217a21de95ba57c8862a042cad)
@@ -5,4 +5,6 @@
  *
  */
+#include <Python.h>
+#include "structmember.h"
 #include <stdio.h>
 #include <stdlib.h>
@@ -10,33 +12,24 @@
 #include <time.h>
 
-//#define Py_LIMITED_API 0x03050000
-#include <Python.h>
-#include <structmember.h>
-
-// Vector binding glue
-#if (PY_VERSION_HEX > 0x03000000) && !defined(Py_LIMITED_API)
-  // Assuming that a view into a writable vector points to a
-  // non-changing pointer for the duration of the C call, capture
-  // the view pointer and immediately free the view.
-  #define VECTOR(VEC_obj, VEC_buf, VEC_len) do { \
-    Py_buffer VEC_view; \
-    int VEC_err = PyObject_GetBuffer(VEC_obj, &VEC_view, PyBUF_WRITABLE|PyBUF_FORMAT); \
-    if (VEC_err < 0 || sizeof(*VEC_buf) != VEC_view.itemsize) return NULL; \
-    VEC_buf = (typeof(VEC_buf))VEC_view.buf; \
-    VEC_len = VEC_view.len/sizeof(*VEC_buf); \
-    PyBuffer_Release(&VEC_view); \
-  } while (0)
-#else
-  #define VECTOR(VEC_obj, VEC_buf, VEC_len) do { \
-    int VEC_err = PyObject_AsWriteBuffer(VEC_obj, (void **)(&VEC_buf), &VEC_len); \
-    if (VEC_err < 0) return NULL; \
-    VEC_len /= sizeof(*VEC_buf); \
-  } while (0)
-#endif
-
 #include "invertor.h"
+
 
 /// Error object for raised exceptions
 PyObject * CinvertorError;
+
+#define INVECTOR(obj,buf,len)										\
+    do { \
+        int err = PyObject_AsReadBuffer(obj, (const void **)(&buf), &len); \
+        if (err < 0) return NULL; \
+        len /= sizeof(*buf); \
+    } while (0)
+
+#define OUTVECTOR(obj,buf,len) \
+    do { \
+        int err = PyObject_AsWriteBuffer(obj, (void **)(&buf), &len); \
+        if (err < 0) return NULL; \
+        len /= sizeof(*buf); \
+    } while (0)
+
 
 // Class definition
@@ -106,5 +99,5 @@
 
 	if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL;
-	VECTOR(data_obj,data,ndata);
+	OUTVECTOR(data_obj,data,ndata);
 
 	free(self->params.x);
@@ -138,5 +131,5 @@
 
 	if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL;
-	VECTOR(data_obj, data, ndata);
+	OUTVECTOR(data_obj, data, ndata);
 
 	// Check that the input array is large enough
@@ -171,5 +164,5 @@
 
 	if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL;
-	VECTOR(data_obj,data,ndata);
+	OUTVECTOR(data_obj,data,ndata);
 
 	free(self->params.y);
@@ -203,5 +196,5 @@
 
 	if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL;
-	VECTOR(data_obj, data, ndata);
+	OUTVECTOR(data_obj, data, ndata);
 
 	// Check that the input array is large enough
@@ -236,5 +229,5 @@
 
 	if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL;
-	VECTOR(data_obj,data,ndata);
+	OUTVECTOR(data_obj,data,ndata);
 
 	free(self->params.err);
@@ -268,5 +261,5 @@
 
 	if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL;
-	VECTOR(data_obj, data, ndata);
+	OUTVECTOR(data_obj, data, ndata);
 
 	// Check that the input array is large enough
@@ -524,5 +517,5 @@
 	if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL;
 
-	VECTOR(data_obj,pars,npars);
+	OUTVECTOR(data_obj,pars,npars);
 
     // PyList of residuals
@@ -575,5 +568,5 @@
 	if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL;
 
-	VECTOR(data_obj,pars,npars);
+	OUTVECTOR(data_obj,pars,npars);
 
 	// Should create this list only once and refill it
@@ -616,5 +609,5 @@
 
 	if (!PyArg_ParseTuple(args, "Od", &data_obj, &q)) return NULL;
-	VECTOR(data_obj,pars,npars);
+	OUTVECTOR(data_obj,pars,npars);
 
 	iq_value = iq(pars, self->params.d_max, (int)npars, q);
@@ -641,5 +634,5 @@
 
 	if (!PyArg_ParseTuple(args, "Od", &data_obj, &q)) return NULL;
-	VECTOR(data_obj,pars,npars);
+	OUTVECTOR(data_obj,pars,npars);
 
 	iq_value = iq_smeared(pars, self->params.d_max, (int)npars,
@@ -666,5 +659,5 @@
 
 	if (!PyArg_ParseTuple(args, "Od", &data_obj, &r)) return NULL;
-	VECTOR(data_obj,pars,npars);
+	OUTVECTOR(data_obj,pars,npars);
 
 	pr_value = pr(pars, self->params.d_max, (int)npars, r);
@@ -693,5 +686,5 @@
 
 	if (!PyArg_ParseTuple(args, "OOd", &data_obj, &err_obj, &r)) return NULL;
-	VECTOR(data_obj,pars,npars);
+	OUTVECTOR(data_obj,pars,npars);
 
 	if (err_obj == Py_None) {
@@ -699,5 +692,5 @@
 		pr_err_value = 0.0;
 	} else {
-		VECTOR(err_obj,pars_err,npars2);
+		OUTVECTOR(err_obj,pars_err,npars2);
 		pr_err(pars, pars_err, self->params.d_max, (int)npars, r, &pr_value, &pr_err_value);
 	}
@@ -733,5 +726,5 @@
 
 	if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL;
-	VECTOR(data_obj,pars,npars);
+	OUTVECTOR(data_obj,pars,npars);
 
 	oscill = reg_term(pars, self->params.d_max, (int)npars, 100);
@@ -754,5 +747,5 @@
 
 	if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL;
-	VECTOR(data_obj,pars,npars);
+	OUTVECTOR(data_obj,pars,npars);
 
 	count = npeaks(pars, self->params.d_max, (int)npars, 100);
@@ -775,5 +768,5 @@
 
 	if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL;
-	VECTOR(data_obj,pars,npars);
+	OUTVECTOR(data_obj,pars,npars);
 
 	fraction = positive_integral(pars, self->params.d_max, (int)npars, 100);
@@ -799,6 +792,6 @@
 
 	if (!PyArg_ParseTuple(args, "OO", &data_obj, &err_obj)) return NULL;
-	VECTOR(data_obj,pars,npars);
-	VECTOR(err_obj,pars_err,npars2);
+	OUTVECTOR(data_obj,pars,npars);
+	OUTVECTOR(err_obj,pars_err,npars2);
 
 	fraction = positive_errors(pars, pars_err, self->params.d_max, (int)npars, 51);
@@ -820,5 +813,5 @@
 
 	if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL;
-	VECTOR(data_obj,pars,npars);
+	OUTVECTOR(data_obj,pars,npars);
 
 	value = rg(pars, self->params.d_max, (int)npars, 101);
@@ -840,5 +833,5 @@
 
 	if (!PyArg_ParseTuple(args, "O", &data_obj)) return NULL;
-	VECTOR(data_obj,pars,npars);
+	OUTVECTOR(data_obj,pars,npars);
 
 	value = 4.0*acos(-1.0)*int_pr(pars, self->params.d_max, (int)npars, 101);
@@ -881,6 +874,6 @@
 
 	if (!PyArg_ParseTuple(args, "iiOO", &nfunc, &nr, &a_obj, &b_obj)) return NULL;
-	VECTOR(a_obj,a,n_a);
-	VECTOR(b_obj,b,n_b);
+	OUTVECTOR(a_obj,a,n_a);
+	OUTVECTOR(b_obj,b,n_b);
 
 	assert(n_b>=nfunc);
@@ -954,6 +947,6 @@
 
 	if (!PyArg_ParseTuple(args, "iiOO", &nfunc, &nr, &a_obj, &cov_obj)) return NULL;
-	VECTOR(a_obj,a,n_a);
-	VECTOR(cov_obj,inv_cov,n_cov);
+	OUTVECTOR(a_obj,a,n_a);
+	OUTVECTOR(cov_obj,inv_cov,n_cov);
 
 	assert(n_cov>=nfunc*nfunc);
@@ -988,5 +981,5 @@
 
 	if (!PyArg_ParseTuple(args, "iiO", &nfunc, &nr, &a_obj)) return NULL;
-	VECTOR(a_obj,a,n_a);
+	OUTVECTOR(a_obj,a,n_a);
 
 	assert(n_a>=nfunc*(nr+self->params.npoints));
@@ -1128,7 +1121,7 @@
 
 #define MODULE_DOC "C extension module for inversion to P(r)."
-#define MODULE_NAME "_pr_inversion"
-#define MODULE_INIT2 init_pr_inversion
-#define MODULE_INIT3 PyInit__pr_inversion
+#define MODULE_NAME "pr_inversion"
+#define MODULE_INIT2 initpr_inversion
+#define MODULE_INIT3 PyInit_pr_inversion
 #define MODULE_METHODS module_methods
 
Index: src/sas/sascalc/pr/c_extensions/__init__.py
===================================================================
--- src/sas/sascalc/pr/c_extensions/__init__.py	(revision 959eb0181ad06828a748f04512f953aad5b31659)
+++ src/sas/sascalc/pr/c_extensions/__init__.py	(revision 959eb0181ad06828a748f04512f953aad5b31659)
@@ -0,0 +1,3 @@
+"""
+    C extensions to provide the P(r) inversion computations.
+"""
Index: src/sas/sascalc/pr/fit/BumpsFitting.py
===================================================================
--- src/sas/sascalc/pr/fit/BumpsFitting.py	(revision 3e6829d03839dc7a60382a887dc7f27da1c50c8f)
+++ src/sas/sascalc/pr/fit/BumpsFitting.py	(revision 9a5097cd1c76689d1f997b85ba43d12a95d8f243)
@@ -2,6 +2,4 @@
 BumpsFitting module runs the bumps optimizer.
 """
-from __future__ import division
-
 import os
 from datetime import timedelta, datetime
@@ -36,5 +34,5 @@
 class Progress(object):
     def __init__(self, history, max_step, pars, dof):
-        remaining_time = int(history.time[0]*(max_step/history.step[0]-1))
+        remaining_time = int(history.time[0]*(float(max_step)/history.step[0]-1))
         # Depending on the time remaining, either display the expected
         # time of completion, or the amount of time remaining.  Use precision
Index: src/sas/sascalc/pr/fit/Loader.py
===================================================================
--- src/sas/sascalc/pr/fit/Loader.py	(revision 57e48ca3fba05a5ace7a3f2a5b6ff8f1a9f4206c)
+++ src/sas/sascalc/pr/fit/Loader.py	(revision 574adc767a9e86744546f8edd6a23dc4f81914ad)
@@ -1,8 +1,7 @@
-"""
-class Loader  to load any kind of file
-"""
-
 from __future__ import print_function
 
+# class Loader  to load any king of file
+#import wx
+#import string
 import numpy as np
 
Index: src/sas/sascalc/pr/invertor.py
===================================================================
--- src/sas/sascalc/pr/invertor.py	(revision 57e48ca3fba05a5ace7a3f2a5b6ff8f1a9f4206c)
+++ src/sas/sascalc/pr/invertor.py	(revision 2469df7fc9ffa047115c5bffe589ed307b12c363)
@@ -6,5 +6,4 @@
 FIXME: The way the Invertor interacts with its C component should be cleaned up
 """
-from __future__ import division
 
 import numpy as np
@@ -18,5 +17,5 @@
 from numpy.linalg import lstsq
 from scipy import optimize
-from sas.sascalc.pr._pr_inversion import Cinvertor
+from sas.sascalc.pr.core.pr_inversion import Cinvertor
 
 logger = logging.getLogger(__name__)
@@ -72,5 +71,5 @@
         A[j][i] = (Fourier transformed base function for point j)
 
-    We then choose a number of r-points, n_r, to evaluate the second
+    We them choose a number of r-points, n_r, to evaluate the second
     derivative of P(r) at. This is used as our regularization term.
     For a vector r of length n_r, the following n_r rows are set to ::
@@ -145,5 +144,5 @@
         x, y, err, d_max, q_min, q_max and alpha
         """
-        if name == 'x':
+        if   name == 'x':
             if 0.0 in value:
                 msg = "Invertor: one of your q-values is zero. "
@@ -269,5 +268,5 @@
             A[i][j] = (Fourier transformed base function for point j)
 
-        We then choose a number of r-points, n_r, to evaluate the second
+        We them choose a number of r-points, n_r, to evaluate the second
         derivative of P(r) at. This is used as our regularization term.
         For a vector r of length n_r, the following n_r rows are set to ::
@@ -417,5 +416,5 @@
             A[i][j] = (Fourier transformed base function for point j)
 
-        We then choose a number of r-points, n_r, to evaluate the second
+        We them choose a number of r-points, n_r, to evaluate the second
         derivative of P(r) at. This is used as our regularization term.
         For a vector r of length n_r, the following n_r rows are set to ::
@@ -474,5 +473,5 @@
 
         # Perform the inversion (least square fit)
-        c, chi2, _, _ = lstsq(a, b, rcond=-1)
+        c, chi2, _, _ = lstsq(a, b)
         # Sanity check
         try:
@@ -497,9 +496,9 @@
         try:
             cov = np.linalg.pinv(inv_cov)
-            err = math.fabs(chi2 / (npts - nfunc)) * cov
-        except Exception as exc:
+            err = math.fabs(chi2 / float(npts - nfunc)) * cov
+        except:
             # We were not able to estimate the errors
             # Return an empty error matrix
-            logger.error(exc)
+            logger.error(sys.exc_value)
 
         # Keep a copy of the last output
@@ -538,13 +537,13 @@
 
         """
-        from .num_term import NTermEstimator
+        from num_term import NTermEstimator
         estimator = NTermEstimator(self.clone())
         try:
             return estimator.num_terms(isquit_func)
-        except Exception as exc:
+        except:
             # If we fail, estimate alpha and return the default
             # number of terms
             best_alpha, _, _ = self.estimate_alpha(self.nfunc)
-            logger.warning("Invertor.estimate_numterms: %s" % exc)
+            logger.warning("Invertor.estimate_numterms: %s" % sys.exc_value)
             return self.nfunc, best_alpha, "Could not estimate number of terms"
 
@@ -632,6 +631,6 @@
                 return best_alpha, message, elapsed
 
-        except Exception as exc:
-            message = "Invertor.estimate_alpha: %s" % exc
+        except:
+            message = "Invertor.estimate_alpha: %s" % sys.exc_value
             return 0, message, elapsed
 
@@ -749,6 +748,6 @@
                         self.cov[i][i] = float(toks2[1])
 
-            except Exception as exc:
-                msg = "Invertor.from_file: corrupted file\n%s" % exc
+            except:
+                msg = "Invertor.from_file: corrupted file\n%s" % sys.exc_value
                 raise RuntimeError(msg)
         else:
Index: src/sas/sascalc/pr/num_term.py
===================================================================
--- src/sas/sascalc/pr/num_term.py	(revision 3e6829d03839dc7a60382a887dc7f27da1c50c8f)
+++ src/sas/sascalc/pr/num_term.py	(revision 2469df7fc9ffa047115c5bffe589ed307b12c363)
@@ -1,3 +1,3 @@
-from __future__ import print_function, division
+from __future__ import print_function
 
 import math
@@ -51,5 +51,5 @@
         osc = self.sort_osc()
         dv = len(osc)
-        med = 0.5*dv
+        med = float(dv) / 2.0
         odd = self.is_odd(dv)
         medi = 0
@@ -140,5 +140,5 @@
             nts = self.compare_err()
             div = len(nts)
-            tem = 0.5*div
+            tem = float(div) / 2.0
             if self.is_odd(div):
                 nt = nts[int(tem)]
