Index: .gitignore
===================================================================
--- .gitignore	(revision bc87305316c560a93eeaf77db05eb6721733d636)
+++ .gitignore	(revision f0d720b734f4a3a6e4bcb409bb0571f8c8e4983b)
@@ -13,10 +13,19 @@
 .pydevproject
 .vagrant
+.idea
+build
+dist
+sasview.egg-info
+sasview.egg-info
+
 .mplconfig
+doctrees
+html
+build
 
 /setup.cfg
 
 /dist
-/build
+**/build
 sasview.egg-info
 sasview-install
@@ -41,2 +50,3 @@
 /test/sasdataloader/test/plugins.zip
 /test/sasdataloader/test/test_log.txt
+
Index: run.py
===================================================================
--- run.py	(revision b699768550de9d4b35b087234ec1d2a461922bab)
+++ run.py	(revision b699768550de9d4b35b087234ec1d2a461922bab)
@@ -104,4 +104,7 @@
     addpath(joinpath(root, 'src'))
 
+    # sasmodels on the path
+    addpath(joinpath(root, '../sasmodels/'))
+
     # Import the sasview package from root/sasview as sas.sasview.  It would
     # be better to just store the package in src/sas/sasview.
Index: setup.py
===================================================================
--- setup.py	(revision 4adf48e6377f8f7256f7048f4bb7a48df44c8007)
+++ setup.py	(revision 4adf48e6377f8f7256f7048f4bb7a48df44c8007)
@@ -244,15 +244,15 @@
 model_dir = os.path.join("src", "sas","models")
 
-if os.path.isdir(wrapper_dir):
-    for file in os.listdir(wrapper_dir): 
-        file_path =  os.path.join(wrapper_dir, file)
-        os.remove(file_path)
-else:
-    os.makedirs(wrapper_dir)
-sys.path.append(os.path.join("src", "sas", "models", "c_extension", "python_wrapper"))
-from wrapping import generate_wrappers
-generate_wrappers(header_dir = includedir, 
-                  output_dir = model_dir,
-                  c_wrapper_dir = wrapper_dir)
+#if os.path.isdir(wrapper_dir):
+#    for file in os.listdir(wrapper_dir):
+#        file_path =  os.path.join(wrapper_dir, file)
+#        os.remove(file_path)
+#else:
+#    os.makedirs(wrapper_dir)
+#sys.path.append(os.path.join("src", "sas", "models", "c_extension", "python_wrapper"))
+#from wrapping import generate_wrappers
+#generate_wrappers(header_dir = includedir,
+#                  output_dir = model_dir,
+#                  c_wrapper_dir = wrapper_dir)
 
 IGNORED_FILES = [".svn"]
@@ -283,6 +283,6 @@
 model_sources = []
 append_file(file_list=model_sources, dir_path=igordir)
-append_file(file_list=model_sources, dir_path=c_model_dir)
-append_file(file_list=model_sources, dir_path=wrapper_dir)
+#append_file(file_list=model_sources, dir_path=c_model_dir)
+#append_file(file_list=model_sources, dir_path=wrapper_dir)
 
 smear_sources = []
@@ -303,10 +303,10 @@
 
 c_models = [ 
-    Extension("sas.models.sas_extension.c_models",
-        sources=model_sources,                 
-        include_dirs=[
-            igordir, includedir, c_model_dir, numpy_incl_path, cephes_dir
-        ],
-    ),
+    #Extension("sas.models.sas_extension.c_models",
+    #    sources=model_sources,
+    #    include_dirs=[
+    #        igordir, includedir, c_model_dir, numpy_incl_path, cephes_dir
+    #    ],
+    #),
 
     # Smearer extension
@@ -340,4 +340,5 @@
 ext_modules.extend(c_models)
 
+packages.append("sas.models")
 # SasView
 
@@ -350,5 +351,5 @@
                                'test/save_states/*',
                                'test/upcoming_formats/*', 
-                               'default_categories.json']
+                                 'default_categories.json']
 packages.append("sas.sasview")
 
Index: src/sas/models/dispersion_models.py
===================================================================
--- src/sas/models/dispersion_models.py	(revision fd5ac0db8089df5bd882587f157d4bf317cfcf67)
+++ src/sas/models/dispersion_models.py	(revision 0e4e5544c592682046c086f1a922482f5159c525)
@@ -154,5 +154,5 @@
         c_models.set_dispersion_weights(self.cdisp, values, weights)
         
-models = {"gaussian":GaussianDispersion,  "rectangula":RectangleDispersion,
+models = {"gaussian":GaussianDispersion,  "rectangular":RectangleDispersion,
           "array":ArrayDispersion, "schulz":SchulzDispersion, 
           "lognormal":LogNormalDispersion}       
Index: src/sas/sasgui/perspectives/fitting/basepage.py
===================================================================
--- src/sas/sasgui/perspectives/fitting/basepage.py	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sasgui/perspectives/fitting/basepage.py	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -57,4 +57,5 @@
     ## Title to appear on top of the window
     window_caption = "Fit Page "
+
     # These two buttons have specific IDs since they seem to be created more
     # frequently than they need to.  In particular, set_dispers_sizer() is
@@ -1379,5 +1380,5 @@
             if disp.__class__.__name__ == 'str':
                 disp_model = None
-                com_str = "from sas.models.dispersion_models "
+                com_str = "from sasmodels.weights "
                 com_str += "import %s as disp_func \ndisp_model = disp_func()"
                 exec com_str % disp
@@ -1944,5 +1945,7 @@
             name = model.__class__.__name__
             if models.__name__ != "NoStructure":
-                if hasattr(model, "name"):
+                if hasattr(model, "oldname"):
+                    name = model.oldname
+                elif hasattr(model, "name"):
                     name = model.name
                 mlist.append((name, models))
@@ -2458,6 +2461,7 @@
         self.values = {}
         self.weights = {}
-
-        from sas.models.dispersion_models import GaussianDispersion
+      
+        #from sas.models.dispersion_models import GaussianDispersion
+        from sasmodels.weights import GaussianDispersion
         if len(self.disp_cb_dict) == 0:
             self.save_current_state()
@@ -3587,15 +3591,15 @@
         cat_tip = "Modify model categories \n"
         cat_tip += "(also accessible from the menu bar)."
-        show_cat_button.SetToolTip(wx.ToolTip(cat_tip))
+        show_cat_button.SetToolTip( wx.ToolTip(cat_tip) )
         show_cat_button.Bind(wx.EVT_BUTTON, self._on_modify_cat)
         sizer_cat_box.Add(self.categorybox, 1, wx.RIGHT, 3)
-        sizer_cat_box.Add((10, 10))
+        sizer_cat_box.Add((10,10))
         sizer_cat_box.Add(show_cat_button)
         #self.shape_rbutton.SetValue(True)
-
+      
         sizer_radiobutton = wx.GridSizer(2, 2, 5, 5)
         #sizer_radiobutton.Add(self.shape_rbutton)
         #sizer_radiobutton.Add(self.shape_indep_rbutton)
-        sizer_radiobutton.Add((5, 5))
+        sizer_radiobutton.Add((5,5))
         sizer_radiobutton.Add(self.model_view, 1, wx.RIGHT, 5)
         #sizer_radiobutton.Add(self.plugin_rbutton)
Index: src/sas/sasgui/perspectives/fitting/models.py
===================================================================
--- src/sas/sasgui/perspectives/fitting/models.py	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sasgui/perspectives/fitting/models.py	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
@@ -6,4 +6,5 @@
 import os
 import sys
+import math
 import os.path
 # Time is needed by the log method
@@ -12,10 +13,14 @@
 import py_compile
 import shutil
+from sas.guiframe.events import StatusEvent
 # Explicitly import from the pluginmodel module so that py2exe
 # places it in the distribution. The Model1DPlugin class is used
 # as the base class of plug-in models.
 from sas.models.pluginmodel import Model1DPlugin
+from sas.models.BaseComponent import BaseComponent
 from sas.sasgui.guiframe.CategoryInstaller import CategoryInstaller
 
+from sasmodels.sasview_model import make_class
+   
 PLUGIN_DIR = 'plugin_models'
 
@@ -314,14 +319,30 @@
 
         # regular model names only
-        base_message = "Unable to load model {0}"
         self.model_name_list = []
-        try:
-            from sas.models.SphereModel import SphereModel
-            self.model_dictionary[SphereModel.__name__] = SphereModel
-            #        self.shape_list.append(SphereModel)
-            self.multiplication_factor.append(SphereModel)
-            self.model_name_list.append(SphereModel.__name__)
-        except:
-            logging.error(base_message.format(SphereModel.__name__))
+
+        #Build list automagically from sasmodels package
+        import pkgutil
+        from importlib import import_module
+        import sasmodels.models
+        for importer,modname,ispkg in pkgutil.iter_modules(sasmodels.models.__path__):
+            if not ispkg:
+                module = import_module('.'+modname,'sasmodels.models')
+                self.model_dictionary[module.oldname] = make_class(module, dtype='single',namestyle='oldname')
+                self.model_name_list.append(module.oldname)
+
+
+        ### NASTY HACK - Comment out most of these lines as models are added to sasmodels.
+        ### Still need the lines that put models into multiplication etc
+
+        try:
+        #     # from sas.models.SphereModel import SphereModel
+        #     from sasmodels.models import sphere
+        #     SphereModel = make_class(sphere, dtype='single',namestyle='oldname')
+        #     self.model_dictionary[SphereModel.__name__] = SphereModel
+        #     #        self.shape_list.append(SphereModel)
+             self.multiplication_factor.append(SphereModel)
+        #     self.model_name_list.append(SphereModel.__name__)
+        except:
+            pass
 
         try:
@@ -1077,5 +1098,5 @@
         new_plugins = _findModels(dir)
         for name, plug in  new_plugins.iteritems():
-            for stored_name, _ in self.stored_plugins.iteritems():
+            for stored_name, stored_plug in self.stored_plugins.iteritems():
                 if name == stored_name:
                     del self.stored_plugins[name]
