Index: src/sas/dataloader/readers/cansas_reader.py
===================================================================
--- src/sas/dataloader/readers/cansas_reader.py	(revision 682c432d9d62b6579bcdee8cedf8793d5d84f77b)
+++ src/sas/dataloader/readers/cansas_reader.py	(revision 5ce7f17e66dc0bd0cabff37dedf011bc6ec0a929)
@@ -322,5 +322,4 @@
                 value_unit = local_unit
             except:
-                print sys.exc_info()
                 err_msg = "CanSAS reader: unknown error converting "
                 err_msg += "\"{0}\" unit [{1}]"
@@ -990,5 +989,5 @@
                 self.append(node, entry_node)
 
-    def _check_origin(self, entry_node, doc):
+    def _check_origin(self, entry_node, doc, frm):
         """
         Return the document, and the SASentry node associated with
@@ -1000,5 +999,6 @@
         :param doc: entire xml tree
         """
-        frm = inspect.stack()[1]
+        if not frm:
+            frm = inspect.stack()[1]
         mod_name = frm[1].replace("\\", "/").replace(".pyc", "")
         mod_name = mod_name.replace(".py", "")
@@ -1011,5 +1011,5 @@
             node_list = doc.getElementsByTagName(node_name)
             entry_node = node_list.item(0)
-        return entry_node
+        return doc, entry_node
 
     def _to_xml_doc(self, datainfo):
@@ -1061,5 +1061,6 @@
         # If the calling function was not the cansas reader, return a minidom
         #      object rather than an lxml object.
-        entry_node = self._check_origin(entry_node, doc)
+        frm = inspect.stack()[1]
+        doc, entry_node = self._check_origin(entry_node, doc, frm)
         return doc, entry_node
 
Index: src/sas/dataloader/readers/xml_reader.py
===================================================================
--- src/sas/dataloader/readers/xml_reader.py	(revision 794922220f2fb3b23dd08c648aabf87b4850596c)
+++ src/sas/dataloader/readers/xml_reader.py	(revision 5ce7f17e66dc0bd0cabff37dedf011bc6ec0a929)
@@ -1,5 +1,5 @@
 """
     Generic XML read and write utility
-    
+
     Usage: Either extend xml_reader or add as a class variable.
 """
@@ -7,9 +7,9 @@
 #This software was developed by the University of Tennessee as part of the
 #Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-#project funded by the US National Science Foundation. 
-#If you use DANSE applications to do scientific research that leads to 
-#publication, we ask that you acknowledge the use of the software with the 
+#project funded by the US National Science Foundation.
+#If you use DANSE applications to do scientific research that leads to
+#publication, we ask that you acknowledge the use of the software with the
 #following sentence:
-#This work benefited from DANSE software developed under NSF award DMR-0520547. 
+#This work benefited from DANSE software developed under NSF award DMR-0520547.
 #copyright 2008,2009 University of Tennessee
 #############################################################################
@@ -25,9 +25,9 @@
     Generic XML read and write class. Mostly helper functions.
     Makes reading/writing XML a bit easier than calling lxml libraries directly.
-    
+
     :Dependencies:
         This class requires lxml 2.3 or higher.
     """
-    
+
     xml = None
     xmldoc = None
@@ -37,6 +37,6 @@
     encoding = None
     processing_instructions = None
-    
-    def __init__(self, xml = None, schema = None):
+
+    def __init__(self, xml=None, schema=None):
         self.xml = xml
         self.schema = schema
@@ -51,5 +51,5 @@
         else:
             self.schemadoc = None
-    
+
     def reader(self):
         """
@@ -57,9 +57,9 @@
         """
         if self.validate_xml():
-            self.xmldoc = etree.parse(self.xml, parser = PARSER)
+            self.xmldoc = etree.parse(self.xml, parser=PARSER)
         else:
             raise etree.XMLSchemaValidateError(self, self.find_invalid_xml())
         return self.xmldoc
-    
+
     def set_xml_file(self, xml):
         """
@@ -68,5 +68,5 @@
         try:
             self.xml = xml
-            self.xmldoc = etree.parse(self.xml, parser = PARSER)
+            self.xmldoc = etree.parse(self.xml, parser=PARSER)
             self.xmlroot = self.xmldoc.getroot()
         except etree.XMLSyntaxError as xml_error:
@@ -76,5 +76,5 @@
             self.xmldoc = None
             self.xmlroot = None
-    
+
     def set_schema(self, schema):
         """
@@ -83,5 +83,5 @@
         try:
             self.schema = schema
-            self.schemadoc = etree.parse(self.schema, parser = PARSER)
+            self.schemadoc = etree.parse(self.schema, parser=PARSER)
         except etree.XMLSyntaxError as xml_error:
             logging.info(xml_error)
@@ -89,5 +89,5 @@
             self.schema = None
             self.schemadoc = None
-    
+
     def validate_xml(self):
         """
@@ -100,5 +100,5 @@
             valid = schema_check.validate(self.xmldoc)
         return valid
-    
+
     def find_invalid_xml(self):
         """
@@ -113,5 +113,5 @@
             first_error = str(err)
         return first_error
-    
+
     def parse_schema_and_doc(self):
         """
@@ -120,16 +120,16 @@
         self.set_xml_file(self.xml)
         self.set_schema(self.schema)
-        
+
     def to_string(self, elem, pretty_print=False, encoding=None):
         """
         Converts an etree element into a string
         """
-        return etree.tostring(elem, pretty_print = pretty_print, \
-                              encoding = encoding)
-    
+        return etree.tostring(elem, pretty_print=pretty_print, \
+                              encoding=encoding)
+
     def break_processing_instructions(self, string, dic):
         """
         Method to break a processing instruction string apart and add to a dict
-        
+
         :param string: A processing instruction as a string
         :param dic: The dictionary to save the PIs to
@@ -142,5 +142,5 @@
         dic[new_pi_name] = attr
         return dic
-    
+
     def set_processing_instructions(self):
         """
@@ -164,14 +164,14 @@
             del dic['xml']
         self.processing_instructions = dic
-        
+
     def set_encoding(self, attr_str):
         """
         Find the encoding in the xml declaration and save it as a string
-        
+
         :param attr_str: All attributes as a string
             e.g. "foo1="bar1" foo2="bar2" foo3="bar3" ... foo_n="bar_n""
         """
         attr_str = attr_str.replace(" = ", "=")
-        attr_list = attr_str.split( )
+        attr_list = attr_str.split()
         for item in attr_list:
             name_value = item.split("\"=")
@@ -182,6 +182,6 @@
                 return
         self.encoding = None
-        
-    def _create_unique_key(self, dictionary, name, numb = 0):
+
+    def _create_unique_key(self, dictionary, name, numb=0):
         """
         Create a unique key value for any dictionary to prevent overwriting
@@ -198,25 +198,25 @@
             name = self._create_unique_key(dictionary, name, numb)
         return name
-    
+
     def create_tree(self, root):
         """
         Create an element tree for processing from an etree element
-        
+
         :param root: etree Element(s) 
         """
         return etree.ElementTree(root)
-    
+
     def create_element_from_string(self, xml_string):
         """
         Create an element from an XML string
-        
+
         :param xml_string: A string of xml
         """
         return etree.fromstring(xml_string)
-    
+
     def create_element(self, name, attrib=None, nsmap=None):
         """
         Create an XML element for writing to file
-        
+
         :param name: The name of the element to be created
         """
@@ -224,9 +224,9 @@
             attrib = {}
         return etree.Element(name, attrib, nsmap)
-    
+
     def write_text(self, elem, text):
         """
         Write text to an etree Element
-        
+
         :param elem: etree.Element object
         :param text: text to write to the element
@@ -234,9 +234,9 @@
         elem.text = text
         return elem
-    
+
     def write_attribute(self, elem, attr_name, attr_value):
         """
         Write attributes to an Element
-        
+
         :param elem: etree.Element object
         :param attr_name: attribute name to write
@@ -245,9 +245,9 @@
         attr = elem.attrib
         attr[attr_name] = attr_value
-        
+
     def return_processing_instructions(self):
         """
         Get all processing instructions saved when loading the document
-        
+
         :param tree: etree.ElementTree object to write PIs to
         """
@@ -259,9 +259,9 @@
                 pi_list.append(pi_item)
         return pi_list
-    
+
     def append(self, element, tree):
         """
         Append an etree Element to an ElementTree.
-        
+
         :param element: etree Element to append
         :param tree: ElementTree object to append to
@@ -269,9 +269,9 @@
         tree = tree.append(element)
         return tree
-    
+
     def ebuilder(self, parent, elementname, text=None, attrib=None):
         """
         Use lxml E builder class with arbitrary inputs.
-        
+
         :param parnet: The parent element to append a child to
         :param elementname: The name of the child in string form
@@ -285,3 +285,2 @@
         parent = parent.append(elem)
         return parent
-        
Index: src/sas/perspectives/fitting/basepage.py
===================================================================
--- src/sas/perspectives/fitting/basepage.py	(revision 7cd87c2443f7f4bd500bede68980342c174a9588)
+++ src/sas/perspectives/fitting/basepage.py	(revision 5ce7f17e66dc0bd0cabff37dedf011bc6ec0a929)
@@ -175,7 +175,7 @@
         self.orientation_params = []
         self.orientation_params_disp = []
-#       Self.model should ALWAYS be None here.  It was set to none above in 
+#       Self.model should ALWAYS be None here.  It was set to none above in
 #       this long init setting.  no obvious function call in between setting
-#       and this - commenting out on 4/8/2014 by PDB.  Remove once clear 
+#       and this - commenting out on 4/8/2014 by PDB.  Remove once clear
 #       it is pointless.
 #        if self.model != None:
@@ -417,5 +417,5 @@
         _on_set_focus_callback = None
 
-        def __init__(self, parent, id= -1,
+        def __init__(self, parent, id=-1,
                      value=wx.EmptyString,
                      pos=wx.DefaultPosition,
@@ -430,5 +430,5 @@
 
             wx.TextCtrl.__init__(self, parent, id, value, pos,
-                                  size, style, validator, name)
+                                 size, style, validator, name)
 
             # Bind appropriate events
@@ -488,8 +488,8 @@
         set some page important information at once
         """
-#       THIS METHOD/FUNCTION NO LONGE APPEARS TO BE CALLED.  Started up program 
+#       THIS METHOD/FUNCTION NO LONGE APPEARS TO BE CALLED.  Started up program
 #       and started new fit window and PR and Invariant and a fit in fitting
 #       but never entered this routine which should be an initialization
-#       routine.  Leave for a while but probably something to clean up at 
+#       routine.  Leave for a while but probably something to clean up at
 #       some point?
 #
@@ -589,4 +589,5 @@
     def get_state(self):
         """
+        return the current page state
         """
         return self.state
@@ -645,8 +646,8 @@
         ## These are called for first time by formfactor_combo_init
         ## itself called from fitpanel only.  If we find that I'm wrong and
-        ## we DO need to initialize somehow here - do it by a call to 
-        ## formfactor_combo_init 
+        ## we DO need to initialize somehow here - do it by a call to
+        ## formfactor_combo_init
         ## self.formfator_combo_init()
-        ## BUT NOT HERE -- make it last line of this 
+        ## BUT NOT HERE -- make it last line of this
         ## method so that structure box is populated before _show_comboox_helper
         ## is called.  Otherwise wx will complain mightily:-)
@@ -660,5 +661,5 @@
 #                               self.model_list_box["Shapes"])
             self._populate_box(self.structurebox,
-                                self.model_list_box["Structure Factors"])
+                               self.model_list_box["Structure Factors"])
             self.structurebox.Insert("None", 0, None)
             self.structurebox.SetSelection(0)
@@ -686,5 +687,5 @@
         #----------------------------------------------------
         self.disable_disp = wx.RadioButton(self, -1, 'Off', (10, 10),
-                                            style=wx.RB_GROUP)
+                                           style=wx.RB_GROUP)
         self.enable_disp = wx.RadioButton(self, -1, 'On', (10, 30))
         # best size for MAC and PC
@@ -696,12 +697,12 @@
                                       style=wx.BU_EXACTFIT,
                                       size=size_q)
-        self.disp_help_bt.Bind(wx.EVT_BUTTON,
-                        self.on_pd_help_clicked, id=self.disp_help_bt.GetId())
+        self.disp_help_bt.Bind(wx.EVT_BUTTON, self.on_pd_help_clicked,
+                               id=self.disp_help_bt.GetId())
         self.disp_help_bt.SetToolTipString("Helps for Polydispersion.")
 
         self.Bind(wx.EVT_RADIOBUTTON, self._set_dipers_Param,
-                     id=self.disable_disp.GetId())
+                  id=self.disable_disp.GetId())
         self.Bind(wx.EVT_RADIOBUTTON, self._set_dipers_Param,
-                   id=self.enable_disp.GetId())
+                  id=self.enable_disp.GetId())
         #MAC needs SetValue
         self.disable_disp.SetValue(True)
@@ -718,6 +719,6 @@
         ## fill a sizer for dispersion
         boxsizer1.Add(sizer_dispersion, 0,
-                wx.TOP | wx.BOTTOM | wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE,
-                border=5)
+                      wx.TOP|wx.BOTTOM|wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE,
+                      border=5)
         self.sizer4_4 = wx.GridBagSizer(6, 5)
 
@@ -778,5 +779,5 @@
                         self._manager.parent._default_save_location
         dlg = wx.FileDialog(self, "Choose a file", self._default_save_location,
-                                        self.window_caption, "*.fitv", wx.SAVE)
+                            self.window_caption, "*.fitv", wx.SAVE)
 
         if dlg.ShowModal() == wx.ID_OK:
@@ -784,5 +785,5 @@
             self._default_save_location = os.path.dirname(path)
             self._manager.parent._default_save_location = \
-                                 self._default_save_location
+                                self._default_save_location
         else:
             return None
@@ -843,5 +844,5 @@
         # inform msg to wx
         wx.PostEvent(self._manager.parent,
-                    StatusEvent(status=msg, info=infor))
+                     StatusEvent(status=msg, info=infor))
 
     def _get_time_stamp(self):
@@ -912,7 +913,7 @@
         try:
             if path == None:
+                status = " Selected Distribution was not loaded: %s" % path
                 wx.PostEvent(self._manager.parent,
-                            StatusEvent(status=\
-                            " Selected Distribution was not loaded: %s" % path))
+                             StatusEvent(status=status))
                 return None, None
             input_f = open(path, 'r')
@@ -931,5 +932,5 @@
                 except:
                     # Skip non-data lines
-                    logging.error(sys.exc_value)
+                    logging.error(sys.exc_info()[1])
             return numpy.array(angles), numpy.array(weights)
         except:
@@ -1095,10 +1096,10 @@
         ## save checkbutton state and txtcrtl values
         self._copy_parameters_state(self.orientation_params,
-                                     self.state.orientation_params)
+                                    self.state.orientation_params)
         self._copy_parameters_state(self.orientation_params_disp,
-                                     self.state.orientation_params_disp)
+                                    self.state.orientation_params_disp)
         self._copy_parameters_state(self.parameters, self.state.parameters)
         self._copy_parameters_state(self.fittable_param,
-                                             self.state.fittable_param)
+                                    self.state.fittable_param)
         self._copy_parameters_state(self.fixed_param, self.state.fixed_param)
 
@@ -1136,5 +1137,5 @@
             category_pos = 0
             for ind_cat in range(self.categorybox.GetCount()):
-                if self.categorycombobox.GetString(ind_form) == \
+                if self.categorycombobox.GetString(ind_cat) == \
                                         state.categorycombobox:
                     category_pos = int(ind_cat)
@@ -1365,8 +1366,5 @@
             else:
                 self.model_view.SetLabel("1D Mode")
-        # else:
-
-        if self._manager != None and self.engine_type != None:
-            self._manager._on_change_engine(engine=self.engine_type)
+        
         ## set the select all check box to the a given state
         self.cb1.SetValue(state.cb1)
@@ -1480,5 +1478,5 @@
                                  [state.values, state.weights]
             except:
-                logging.error(sys.exc_value)
+                logging.error(sys.exc_info()[1])
             selection = self._find_polyfunc_selection(disp_model)
             for list in self.fittable_param:
@@ -1497,5 +1495,5 @@
                             list[6].Disable()
                         except:
-                            logging.error(sys.exc_value)
+                            logging.error(sys.exc_info()[1])
             # For array, disable all fixed params
             if selection == 1:
@@ -1506,5 +1504,5 @@
                             item[2].Disable()
                         except:
-                            logging.error(sys.exc_value)
+                            logging.error(sys.exc_info()[1])
 
         # Make sure the check box updated when all checked
@@ -1520,6 +1518,6 @@
                         self._manager.parent.get_save_location()
         dlg = wx.FileDialog(self, "Choose a weight file",
-                                self._default_save_location, "",
-                                "*.*", wx.OPEN)
+                            self._default_save_location, "",
+                            "*.*", wx.OPEN)
         path = None
         if dlg.ShowModal() == wx.ID_OK:
@@ -1587,5 +1585,5 @@
             try:
                 is_modified = self._check_value_enter(self.fittable_param,
-                                                     is_modified)
+                                                      is_modified)
                 is_modified = self._check_value_enter(self.fixed_param,
                                                       is_modified)
@@ -1593,5 +1591,5 @@
                                                       is_modified)
             except:
-                logging.error(sys.exc_value)
+                logging.error(sys.exc_info()[1])
 
             # Here we should check whether the boundaries have been modified.
@@ -1659,7 +1657,7 @@
             self._check_value_enter(self.parameters, is_modified)
 
-            # If qmin and qmax have been modified, update qmin and qmax and 
+            # If qmin and qmax have been modified, update qmin and qmax and
             # Here we should check whether the boundaries have been modified.
-            # If qmin and qmax have been modified, update qmin and qmax and 
+            # If qmin and qmax have been modified, update qmin and qmax and
             # set the is_modified flag to True
             self.fitrange = self._validate_qrange(self.qmin, self.qmax)
@@ -1681,4 +1679,5 @@
                         flag = self.update_pinhole_smear()
                     else:
+                        enable_smearer = not self.disable_smearer.GetValue()
                         self._manager.set_smearer(smearer=temp_smearer,
                                                   uid=self.uid,
@@ -1686,6 +1685,6 @@
                                                   qmin=float(self.qmin_x),
                                                   qmax=float(self.qmax_x),
-                            enable_smearer=not self.disable_smearer.GetValue(),
-                                                      draw=False)
+                                                  enable_smearer=enable_smearer,
+                                                  draw=False)
                 elif not self._is_2D():
                     self._manager.set_smearer(smearer=temp_smearer,
@@ -1735,5 +1734,5 @@
             self.save_current_state()
         except:
-            logging.error(sys.exc_value)
+            logging.error(sys.exc_info()[1])
 
         return flag
@@ -1990,5 +1989,5 @@
                     #                 StatusEvent(status=msg, info="error"))
         except:
-            msg = "%s\n" % (sys.exc_value)
+            msg = "%s\n" % (sys.exc_info()[1])
             wx.PostEvent(self._manager.parent,
                          StatusEvent(status=msg, info="error"))
@@ -1996,4 +1995,7 @@
 
     def _on_modify_cat(self, event=None):
+        """
+        Called when category manager is opened
+        """
         self._manager.parent.on_category_panel(event)
 
@@ -2059,10 +2061,11 @@
                 else:
                     tcrtl.SetBackgroundColour("pink")
-                    msg = "Model Error: wrong value entered: %s" % sys.exc_value
+                    msg = "Model Error: wrong value entered: %s" % \
+                                    sys.exc_info()[1]
                     wx.PostEvent(self.parent, StatusEvent(status=msg))
                     return
             except:
                 tcrtl.SetBackgroundColour("pink")
-                msg = "Model Error: wrong value entered: %s" % sys.exc_value
+                msg = "Model Error: wrong value entered: %s" % sys.exc_info()[1]
                 wx.PostEvent(self.parent, StatusEvent(status=msg))
                 return
@@ -2116,10 +2119,11 @@
                 else:
                     tcrtl.SetBackgroundColour("pink")
-                    msg = "Model Error: wrong value entered: %s" % sys.exc_value
+                    msg = "Model Error: wrong value entered: %s" % \
+                                        sys.exc_info()[1]
                     wx.PostEvent(self._manager.parent, StatusEvent(status=msg))
                     return
             except:
                 tcrtl.SetBackgroundColour("pink")
-                msg = "Model Error: wrong value entered: %s" % sys.exc_value
+                msg = "Model Error: wrong value entered: %s" % sys.exc_info()[1]
                 wx.PostEvent(self._manager.parent, StatusEvent(status=msg))
                 return
@@ -2551,5 +2555,5 @@
                     self.model.set_dispersion(p, disp_model)
                 except:
-                    logging.error(sys.exc_value)
+                    logging.error(sys.exc_info()[1])
 
         ## save state into
@@ -2764,5 +2768,5 @@
             del self.state.model._persistency_dict[name.split('.')[0]]
         except:
-            logging.error(sys.exc_value)
+            logging.error(sys.exc_info()[1])
 
     def _lay_out(self):
@@ -2910,5 +2914,5 @@
             except:
                 # Not for control panels
-                logging.error(sys.exc_value)
+                logging.error(sys.exc_info()[1])
         # Make sure the resduals plot goes to the last
         if res_item != None:
@@ -3226,5 +3230,5 @@
                     disfunc = str(item[7].GetValue())
             except:
-                logging.error(sys.exc_value)
+                logging.error(sys.exc_info()[1])
 
             # 2D
@@ -3261,5 +3265,5 @@
                         disfunc += ' ' + str(weight)
             except:
-                logging.error(sys.exc_value)
+                logging.error(sys.exc_info()[1])
             content += name + ',' + str(check) + ',' + value + disfunc + ':'
 
@@ -3462,5 +3466,5 @@
                             is_array = True
                 except:
-                    logging.error(sys.exc_value)
+                    logging.error(sys.exc_info()[1])
                 if not is_array:
                     self._disp_obj_dict[name] = disp_model
@@ -3477,6 +3481,7 @@
 
             except:
-                logging.error(sys.exc_value)
-                print "Error in BasePage._paste_poly_help: %s" % sys.exc_value
+                logging.error(sys.exc_info()[1])
+                print "Error in BasePage._paste_poly_help: %s" % \
+                                        sys.exc_info()[1]
 
     def _set_disp_array_cb(self, item):
@@ -3502,12 +3507,8 @@
         return
 
-
-
-
     def _read_category_info(self):
         """
         Reads the categories in from file
         """
-
         # # ILL mod starts here - July 2012 kieranrcampbell@gmail.com
         self.master_category_dict = defaultdict(list)
@@ -3523,5 +3524,4 @@
             self._regenerate_model_dict()
             cat_file.close()
-
         except IOError:
             raise
@@ -3536,5 +3536,4 @@
         along with the enabled mapping
         """
-
         self.by_model_dict = defaultdict(list)
         for category in self.master_category_dict:
@@ -3564,7 +3563,5 @@
             self.categorybox.SetSelection(\
                 self.categorybox.GetSelection())
-
         #self._on_change_cat(None)
-
 
     def _on_change_cat(self, event):
@@ -3588,7 +3585,4 @@
                 if(enabled):
                     self.model_box.Append(model)
-
-
-
 
     def _fill_model_sizer(self, sizer):
@@ -3654,6 +3648,4 @@
 
         sizer_radiobutton = wx.GridSizer(2, 2, 5, 5)
-
-
         #sizer_radiobutton.Add(self.shape_rbutton)
         #sizer_radiobutton.Add(self.shape_indep_rbutton)
