Index: sview/default_categories.json
===================================================================
--- sasview/default_categories.json	(revision a7567556686c0843621c2a1fa06625181c2875fe)
+++ 	(revision )
@@ -1,304 +1,0 @@
-{
-    "Shapes": [
-        [
-            "barbell",
-            true
-        ],
-        [
-            "cylinder",
-            true
-        ],
-        [
-            "lamellar_stack_paracrystal",
-            true
-        ],
-        [
-            "multilayer_vesicle",
-            true
-        ],
-        [
-            "core_shell_cylinder",
-            true
-        ],
-        [
-            "lamellar_hg",
-            true
-        ],
-        [
-            "fuzzy_sphere",
-            true
-        ],
-        [
-            "sphere",
-            true
-        ],
-        [
-            "triaxial_ellipsoid",
-            true
-        ],
-        [
-            "rectangular_prism",
-            true
-        ],
-        [
-            "core_shell_bicelle",
-            true
-        ],
-        [
-            "flexible_cylinder",
-            true
-        ],
-        [
-            "flexible_cylinder_elliptical",
-            true
-        ],
-        [
-            "binary_hard_sphere",
-            true
-        ],
-        [
-            "core_multi_shell",
-            true
-        ],
-        [
-            "sc_paracrystal",
-            true
-        ],
-        [
-            "ellipsoid",
-            true
-        ],
-        [
-            "capped_cylinder",
-            true
-        ],
-        [
-            "core_shell_ellipsoid",
-            true
-        ],
-        [
-            "fcc_paracrystal",
-            true
-        ],
-        [
-            "core_shell_parallelepiped",
-            true
-        ],
-        [
-            "core_shell_ellipsoid_xt",
-            true
-        ],
-        [
-            "elliptical_cylinder",
-            true
-        ],
-        [
-            "pringle",
-            true
-        ],
-        [
-            "hollow_rectangular_prism_thin_walls",
-            true
-        ],
-        [
-            "hollow_rectangular_prism",
-            true
-        ],
-        [
-            "vesicle",
-            true
-        ],
-        [
-            "polymer_micelle",
-            true
-        ],
-        [
-            "parallelepiped",
-            true
-        ],
-        [
-            "hollow_cylinder",
-            true
-        ],
-        [
-            "linear_pearls",
-            true
-        ],
-        [
-            "spherical_sld",
-            true
-        ],
-        [
-            "raspberry",
-            true
-        ],
-        [
-            "lamellar_hg_stack_caille",
-            true
-        ],
-        [
-            "pearl_necklace",
-            true
-        ],
-        [
-            "lamellar",
-            true
-        ],
-        [
-            "onion",
-            true
-        ],
-        [
-            "lamellar_stack_caille",
-            true
-        ],
-        [
-            "bcc_paracrystal",
-            true
-        ],
-        [
-            "core_shell_sphere",
-            true
-        ],
-        [
-            "stacked_disks",
-            true
-        ]
-    ],
-    "Structure Factor": [
-        [
-            "hayter_msa",
-            true
-        ],
-        [
-            "squarewell",
-            true
-        ],
-        [
-            "stickyhardsphere",
-            true
-        ],
-        [
-            "hardsphere",
-            true
-        ]
-    ],
-    "Shape-Independent": [
-        [
-            "unified_power_Rg",
-            true
-        ],
-        [
-            "guinier_porod",
-            true
-        ],
-        [
-            "polymer_excl_volume",
-            true
-        ],
-        [
-            "gel_fit",
-            true
-        ],
-        [
-            "teubner_strey",
-            true
-        ],
-        [
-            "mono_gauss_coil",
-            true
-        ],
-        [
-            "mass_surface_fractal",
-            true
-        ],
-        [
-            "mass_fractal",
-            true
-        ],
-        [
-            "adsorbed_layer",
-            true
-        ],
-        [
-            "two_lorentzian",
-            true
-        ],
-        [
-            "fractal",
-            true
-        ],
-        [
-            "fractal_core_shell",
-            true
-        ],
-        [
-            "dab",
-            true
-        ],
-        [
-            "poly_gauss_coil",
-            true
-        ],
-        [
-            "star_polymer",
-            true
-        ],
-        [
-            "broad_peak",
-            true
-        ],
-        [
-            "surface_fractal",
-            true
-        ],
-        [
-            "two_power_law",
-            true
-        ],
-        [
-            "power_law",
-            true
-        ],
-        [
-            "rpa",
-            true
-        ],
-        [
-            "be_polyelectrolyte",
-            true
-        ],
-        [
-            "peak_lorentz",
-            true
-        ],
-        [
-            "guinier",
-            true
-        ],
-        [
-            "correlation_length",
-            true
-        ],
-        [
-            "line",
-            true
-        ],
-        [
-            "gaussian_peak",
-            true
-        ],
-        [
-            "porod",
-            true
-        ],
-        [
-            "gauss_lorentz_gel",
-            true
-        ],
-        [
-            "lorentz",
-            true
-        ]
-    ]
-}
Index: src/sas/sasgui/guiframe/CategoryInstaller.py
===================================================================
--- src/sas/sasgui/guiframe/CategoryInstaller.py	(revision 50008e349254372d579f42bb3ad653d593d7a40b)
+++ src/sas/sasgui/guiframe/CategoryInstaller.py	(revision 212bfc297ca102b648c949f030d3d06a4c569fa3)
@@ -11,7 +11,7 @@
 import os
 import sys
-import shutil
 import json
-from collections import defaultdict
+import logging
+from collections import defaultdict, OrderedDict
 
 USER_FILE = 'categories.json'
@@ -23,5 +23,4 @@
     Note - class is entirely static!
     """
-
 
     def __init__(self):
@@ -43,5 +42,5 @@
         import sas.sasgui.perspectives.fitting.models
         return sas.sasgui.perspectives.fitting.models.get_model_python_path()
-    
+
     @staticmethod
     def _get_default_cat_file_dir():
@@ -54,5 +53,5 @@
         import sas.sasview
         cat_file = "default_categories.json"
-        
+
         possible_cat_file_paths = [
             os.path.join(os.path.split(sas.sasview.__file__)[0], cat_file),           # Source
@@ -64,5 +63,5 @@
             if os.path.isfile(path):
                 return os.path.dirname(path)
-            
+
         raise RuntimeError('CategoryInstaller: Could not find folder containing default categories')
 
@@ -89,7 +88,6 @@
                 by_model_dict[model].append(category)
                 model_enabled_dict[model] = enabled
-    
+
         return (by_model_dict, model_enabled_dict)
-
 
     @staticmethod
@@ -105,6 +103,5 @@
                 master_category_dict[category].append(\
                     (model, model_enabled_dict[model]))
-        
-        return master_category_dict
+        return OrderedDict(sorted(master_category_dict.items(), key=lambda t: t[0]))
 
     @staticmethod
@@ -113,16 +110,10 @@
         returns the user data file, eg .sasview/categories.json.json
         """
-        return os.path.join(CategoryInstaller._get_home_dir(),
-                            USER_FILE)
+        return os.path.join(CategoryInstaller._get_home_dir(), USER_FILE)
 
     @staticmethod
     def get_default_file():
-        """
-        returns the path of the default file
-        e.g. blahblah/default_categories.json
-        """
-        return os.path.join(\
-            CategoryInstaller._get_default_cat_file_dir(), "default_categories.json")
-        
+        logging.warning("CategoryInstaller.get_default_file is deprecated.")
+
     @staticmethod
     def check_install(homedir = None, model_list=None):
@@ -134,8 +125,8 @@
         :param model_list: List of model names except customized models
         """
-        #model_list = []
-        default_file = CategoryInstaller.get_default_file()
+        _model_dict = { model.name: model for model in model_list}
+        _model_list = _model_dict.keys()
+
         serialized_file = None
-        master_category_dict = defaultdict(list)
         if homedir == None:
             serialized_file = CategoryInstaller.get_user_file()
@@ -143,18 +134,17 @@
             serialized_file = os.path.join(homedir, USER_FILE)
         if os.path.isfile(serialized_file):
-            cat_file = open(serialized_file, 'rb')
+            with open(serialized_file, 'rb') as f:
+                master_category_dict = json.load(f)
         else:
-            cat_file = open(default_file, 'rb')
-        master_category_dict = json.load(cat_file)
-#        master_category_dict = pickle.Unpickler(cat_file).load()
+            master_category_dict = defaultdict(list)
+
         (by_model_dict, model_enabled_dict) = \
                 CategoryInstaller._regenerate_model_dict(master_category_dict)
-        cat_file.close()
-        add_list = model_list
+        add_list = _model_list
         del_name = False
         for cat in master_category_dict.keys():
             for ind in range(len(master_category_dict[cat])):
                 model_name, enabled = master_category_dict[cat][ind]
-                if model_name not in model_list:
+                if model_name not in _model_list:
                     del_name = True 
                     try:
@@ -162,5 +152,5 @@
                         model_enabled_dict.pop(model_name)
                     except:
-                        pass
+                        logging.error("CategoryInstaller: %s", sys.exc_value)
                 else:
                     add_list.remove(model_name)
@@ -168,10 +158,19 @@
             for model in add_list:
                 model_enabled_dict[model]= True
-                by_model_dict[model].append('Uncategorized')
-    
+                if _model_dict[model].category is None or len(str(_model_dict[model].category.capitalize())) == 0:
+                    by_model_dict[model].append('Uncategorized')
+                else:
+                    category = _model_dict[model].category
+                    toks = category.split(':')
+                    category = toks[-1]
+                    toks = category.split('-')
+                    capitalized_words = [t.capitalize() for t in toks]
+                    category = ' '.join(capitalized_words)
+
+                    by_model_dict[model].append(category)
+
             master_category_dict = \
                 CategoryInstaller._regenerate_master_dict(by_model_dict,
                                                           model_enabled_dict)
-            
-            json.dump( master_category_dict,
-                         open(serialized_file, 'wb') )
+
+            json.dump(master_category_dict, open(serialized_file, 'wb'))
Index: src/sas/sasgui/guiframe/CategoryManager.py
===================================================================
--- src/sas/sasgui/guiframe/CategoryManager.py	(revision 80b1df3a323cc6cd02a52c2e6e711def31b0024c)
+++ src/sas/sasgui/guiframe/CategoryManager.py	(revision 212bfc297ca102b648c949f030d3d06a4c569fa3)
@@ -13,4 +13,5 @@
 import sys
 import os
+import logging
 from wx.lib.mixins.listctrl import CheckListCtrlMixin, ListCtrlAutoWidthMixin
 from collections import defaultdict
@@ -366,17 +367,11 @@
         """
         try:
-            file = CategoryInstaller.get_user_file()
-            if os.path.isfile(file):
-                cat_file = open(file, 'rb')
-#               self.master_category_dict = pickle.load(cat_file)
-                self.master_category_dict = json.load(cat_file)
-            else:
-                cat_file = open(CategoryInstaller.get_default_file(), 'rb')
-#        		self.master_category_dict = pickle.load(cat_file)
-                self.master_category_dict = json.load(cat_file)
-            cat_file.close()
+            cat_file = CategoryInstaller.get_user_file()
+            self.master_category_dict = {}
+            if os.path.isfile(cat_file):
+                with open(cat_file, 'rb') as f:
+                    self.master_category_dict = json.load(f)
         except IOError:
-            print 'Problem reading in category file. Please review'
-
+            logging.error('Problem reading in category file.')
 
         self._regenerate_model_dict()
Index: src/sas/sasgui/guiframe/customdir.py
===================================================================
--- src/sas/sasgui/guiframe/customdir.py	(revision d85c194ea2f78cb2b9b3de9c969e1b8ebea6b6d2)
+++ src/sas/sasgui/guiframe/customdir.py	(revision 212bfc297ca102b648c949f030d3d06a4c569fa3)
@@ -1,7 +1,5 @@
 # Setup and find Custom config dir
-import sys
 import os.path
 import shutil
-from sas.sasgui.guiframe.CategoryInstaller import CategoryInstaller
 
 CONF_DIR = 'config' 
@@ -12,7 +10,5 @@
     Find and return user/.sasview dir
     """
-    dir = os.path.join(os.path.expanduser("~"), 
-                       ("." + APPLICATION_NAME))
-    return dir
+    return os.path.join(os.path.expanduser("~"), ("." + APPLICATION_NAME))
 
 def _find_customconf_dir():
@@ -22,7 +18,5 @@
     """
     u_dir = _find_usersasview_dir()
-    dir = os.path.join(u_dir, CONF_DIR)
-    
-    return dir
+    return os.path.join(u_dir, CONF_DIR)
 
 def _setup_conf_dir(path):
@@ -30,26 +24,14 @@
     Setup the custom config dir and cat file
     """
-    dir = _find_customconf_dir()
+    conf_dir = _find_customconf_dir()
     # If the plugin directory doesn't exist, create it
-    if not os.path.isdir(dir):
-        os.makedirs(dir)
-    file = os.path.join(dir, "custom_config.py")
-    cat_file = CategoryInstaller.get_user_file()
-    # If the user category file doesn't exist copy the default to
-    # the user directory
-    if not os.path.isfile(cat_file):
-        try:
-            default_cat_file = CategoryInstaller.get_default_file()
-            if os.path.isfile(default_cat_file):
-                shutil.copyfile(default_cat_file, cat_file)
-            else:
-                print "Unable to find/copy default cat file"
-        except:
-            print "Unable to copy default cat file to the user dir."
+    if not os.path.isdir(conf_dir):
+        os.makedirs(conf_dir)
+    config_file = os.path.join(conf_dir, "custom_config.py")
 
     # Place example user models as needed
     try:
-        if not os.path.isfile(file):
-         shutil.copyfile(os.path.join(path, "custom_config.py"), file)
+        if not os.path.isfile(config_file):
+            shutil.copyfile(os.path.join(path, "custom_config.py"), config_file)
     except:
         # Check for data path next to exe/zip file.
@@ -63,13 +45,12 @@
             temp_path = os.path.join(f_dir, "custom_config.py")
             if os.path.isfile(temp_path):
-                shutil.copyfile(temp_path, file)
+                shutil.copyfile(temp_path, config_file)
                 is_dir = True
                 break
         if not is_dir:
             raise
-        
-    return dir
-  
-        
+    return conf_dir
+
+
 class SetupCustom(object):
     """
@@ -81,7 +62,2 @@
     def setup_dir(self, path):
         return _setup_conf_dir(path)
-    
-
-    
-    
-  
Index: src/sas/sasgui/perspectives/fitting/basepage.py
===================================================================
--- src/sas/sasgui/perspectives/fitting/basepage.py	(revision 4c3be25d8a666eaaf1edd8b30db518e151535fe6)
+++ src/sas/sasgui/perspectives/fitting/basepage.py	(revision 212bfc297ca102b648c949f030d3d06a4c569fa3)
@@ -3447,18 +3447,8 @@
         self.by_model_dict = defaultdict(list)
         self.model_enabled_dict = defaultdict(bool)
-
-        try:
-            categorization_file = CategoryInstaller.get_user_file()
-            if not os.path.isfile(categorization_file):
-                categorization_file = CategoryInstaller.get_default_file()
-            cat_file = open(categorization_file, 'rb')
-            self.master_category_dict = json.load(cat_file)
-            self._regenerate_model_dict()
-            cat_file.close()
-        except IOError:
-            raise
-            print 'Problem reading in category file.'
-            print 'We even looked for it, made sure it was there.'
-            print 'An existential crisis if there ever was one.'
+        categorization_file = CategoryInstaller.get_user_file()
+        with open(categorization_file, 'rb') as f:
+            self.master_category_dict = json.load(f)
+        self._regenerate_model_dict()
 
     def _regenerate_model_dict(self):
Index: src/sas/sasgui/perspectives/fitting/models.py
===================================================================
--- src/sas/sasgui/perspectives/fitting/models.py	(revision 6fb559d7e0b3729983ce407aeb8ba9c519a57907)
+++ src/sas/sasgui/perspectives/fitting/models.py	(revision 212bfc297ca102b648c949f030d3d06a4c569fa3)
@@ -412,5 +412,5 @@
     """
     __modelmanager = ModelManagerBase()
-    cat_model_list = [model_name for model_name \
+    cat_model_list = [__modelmanager.model_dictionary[model_name] for model_name \
                       in __modelmanager.model_dictionary.keys() \
                       if model_name not in __modelmanager.stored_plugins.keys()]
