Index: src/sas/_config.py
===================================================================
--- src/sas/_config.py	(revision b963b2066d6a76fe5073000c5a596a6fd0130ac4)
+++ src/sas/_config.py	(revision 93b34cc20c889f8987e6e4767a8fefae8cea7f78)
@@ -86,4 +86,5 @@
 def setup_custom_config(app_dir, user_dir):
     path = make_custom_config_path(user_dir)
+    #logger.info("custom config path %s", path)
     if not os.path.isfile(path):
         try:
@@ -94,15 +95,16 @@
             logger.error("Could not copy default custom config.")
 
+    custom_config = load_custom_config(path)
+
     #Adding SAS_OPENCL if it doesn't exist in the config file
     # - to support backcompability
-    if not "SAS_OPENCL" in open(path).read():
+    if not hasattr(custom_config, "SAS_OPENCL"):
+        custom_config.SAS_OPENCL = None
         try:
-            open(config_file, "a+").write("SAS_OPENCL = \"None\"\n")
+            open(path, "a+").write("SAS_OPENCL = \"None\"\n")
         except Exception:
             logger.error("Could not update custom config with SAS_OPENCL.")
 
-    custom_config = load_custom_config(path)
     return custom_config
-
 
 def load_custom_config(path):
Index: src/sas/sasgui/guiframe/gui_manager.py
===================================================================
--- src/sas/sasgui/guiframe/gui_manager.py	(revision 9220e89c31ca5156d9c3a40634b4257084d139a2)
+++ src/sas/sasgui/guiframe/gui_manager.py	(revision 9220e89c31ca5156d9c3a40634b4257084d139a2)
@@ -63,47 +63,35 @@
 SPLASH_SCREEN_HEIGHT = config.SPLASH_SCREEN_HEIGHT
 SS_MAX_DISPLAY_TIME = config.SS_MAX_DISPLAY_TIME
-if not WELCOME_PANEL_ON:
-    WELCOME_PANEL_SHOW = False
+
+def custom_value(name, default=None):
+    """
+    Fetch a config value from custom_config.  Fallback to config, and then
+    to default if it doesn't exist in config.
+    """
+    default = getattr(config, name, default)
+    return getattr(custom_config, name, default)
+
+# Custom config values in the order they appear.
+DATAPANEL_WIDTH = custom_value('DATAPANEL_WIDTH', -1)
+CLEANUP_PLOT = custom_value('CLEANUP_PLOT', False)
+FIXED_PANEL = custom_value('FIXED_PANEL', True)
+PLOPANEL_WIDTH = custom_value('PLOPANEL_WIDTH', -1)
+DATALOADER_SHOW = custom_value('DATALOADER_SHOW', True)
+GUIFRAME_HEIGHT = custom_value('GUIFRAME_HEIGHT', -1)
+GUIFRAME_WIDTH = custom_value('GUIFRAME_WIDTH', -1)
+CONTROL_WIDTH = custom_value('CONTROL_WIDTH', -1)
+CONTROL_HEIGHT = custom_value('CONTROL_HEIGHT', -1)
+open_folder = custom_value('DEFAULT_OPEN_FOLDER', None)
+if open_folder is not None and os.path.isdir(open_folder):
+    DEFAULT_OPEN_FOLDER = os.path.abspath(open_folder)
 else:
-    WELCOME_PANEL_SHOW = True
-try:
-    DATALOADER_SHOW = custom_config.DATALOADER_SHOW
-    TOOLBAR_SHOW = custom_config.TOOLBAR_SHOW
-    FIXED_PANEL = custom_config.FIXED_PANEL
-    if WELCOME_PANEL_ON:
-        WELCOME_PANEL_SHOW = custom_config.WELCOME_PANEL_SHOW
-    PLOPANEL_WIDTH = custom_config.PLOPANEL_WIDTH
-    DATAPANEL_WIDTH = custom_config.DATAPANEL_WIDTH
-    GUIFRAME_WIDTH = custom_config.GUIFRAME_WIDTH
-    GUIFRAME_HEIGHT = custom_config.GUIFRAME_HEIGHT
-    CONTROL_WIDTH = custom_config.CONTROL_WIDTH
-    CONTROL_HEIGHT = custom_config.CONTROL_HEIGHT
-    DEFAULT_PERSPECTIVE = custom_config.DEFAULT_PERSPECTIVE
-    CLEANUP_PLOT = custom_config.CLEANUP_PLOT
-    # custom open_path
-    open_folder = custom_config.DEFAULT_OPEN_FOLDER
-    if open_folder is not None and os.path.isdir(open_folder):
-        DEFAULT_OPEN_FOLDER = os.path.abspath(open_folder)
-    else:
-        DEFAULT_OPEN_FOLDER = get_app_dir()
-    SAS_OPENCL = custom_config.SAS_OPENCL
-except:
-    DATALOADER_SHOW = True
-    TOOLBAR_SHOW = True
-    FIXED_PANEL = True
-    WELCOME_PANEL_SHOW = False
-    PLOPANEL_WIDTH = config.PLOPANEL_WIDTH
-    DATAPANEL_WIDTH = config.DATAPANEL_WIDTH
-    GUIFRAME_WIDTH = config.GUIFRAME_WIDTH
-    GUIFRAME_HEIGHT = config.GUIFRAME_HEIGHT
-    CONTROL_WIDTH = -1
-    CONTROL_HEIGHT = -1
-    DEFAULT_PERSPECTIVE = None
-    CLEANUP_PLOT = False
     DEFAULT_OPEN_FOLDER = get_app_dir()
-    DEFAULT_OPEN_FOLDER = PATH_APP
-    SAS_OPENCL = None
+WELCOME_PANEL_SHOW = (custom_value('WELCOME_PANEL_SHOW', False)
+                      if WELCOME_PANEL_ON else False)
+TOOLBAR_SHOW = custom_value('TOOLBAR_SHOW', True)
+DEFAULT_PERSPECTIVE = custom_value('DEFAULT_PERSPECTIVE', 'Fitting')
+SAS_OPENCL = custom_value('SAS_OPENCL', 'None')
+
 DEFAULT_STYLE = config.DEFAULT_STYLE
-
 PLUGIN_STATE_EXTENSIONS = config.PLUGIN_STATE_EXTENSIONS
 OPEN_SAVE_MENU = config.OPEN_SAVE_PROJECT_MENU
@@ -2171,5 +2159,5 @@
         # original 2.x tutorial.
         # Code below, implemented from 4.2.0, redirects
-        # action to the Tutorials page of the help 
+        # action to the Tutorials page of the help
         # documentation to give access to all available
         # tutorials
Index: src/sas/sasgui/perspectives/calculator/model_editor.py
===================================================================
--- src/sas/sasgui/perspectives/calculator/model_editor.py	(revision 9bf40e7da42d4112c3098b54d9c3b12081500c84)
+++ src/sas/sasgui/perspectives/calculator/model_editor.py	(revision 1752f38b456a43e18ad070757b9e3f32528721ca)
@@ -965,9 +965,9 @@
         out_f.write('    """Absolute scattering"""\n')
         if "scipy." in func_str:
-            out_f.write('    import scipy')
+            out_f.write('    import scipy\n')
         if "numpy." in func_str:
-            out_f.write('    import numpy')
+            out_f.write('    import numpy\n')
         if "np." in func_str:
-            out_f.write('    import numpy as np')
+            out_f.write('    import numpy as np\n')
         for func_line in func_str.split('\n'):
             out_f.write('%s%s\n' % ('    ', func_line))
Index: src/sas/sasgui/perspectives/fitting/fitting.py
===================================================================
--- src/sas/sasgui/perspectives/fitting/fitting.py	(revision aba455916c90b078a4a7d77651680d2dbf1b959f)
+++ src/sas/sasgui/perspectives/fitting/fitting.py	(revision a5cffe570a689752aa7b74ce8a71d2b1704e624f)
@@ -776,8 +776,6 @@
         :param weight: current dy data
         """
-        # If we are not dealing with a specific fit problem, then
-        # there is no point setting the weights.
-        if fid is None:
-            return
+        # Note: this is used to set the data weights for the fit based on
+        # the weight selection in the GUI.
         if uid in self.page_finder.keys():
             self.page_finder[uid].set_weight(flag=flag, is2d=is2d)
Index: src/sas/sasgui/perspectives/fitting/gpu_options.py
===================================================================
--- src/sas/sasgui/perspectives/fitting/gpu_options.py	(revision 8e109f9b4b47319e1f698a4c5e4e57a3a51656d3)
+++ src/sas/sasgui/perspectives/fitting/gpu_options.py	(revision 895703d186f0963beb7b46058e022d7f4b7ae9d4)
@@ -23,5 +23,5 @@
 import sasmodels
 import sasmodels.model_test
-import sasmodels.kernelcl
+import sasmodels.sasview_model
 
 from sas.sasgui.guiframe.documentation_window import DocumentationWindow
@@ -239,5 +239,5 @@
             if "SAS_OPENCL" in os.environ:
                 del os.environ["SAS_OPENCL"]
-        sasmodels.kernelcl.reset_environment()
+        sasmodels.sasview_model.reset_environment()
         event.Skip()
 
@@ -265,5 +265,5 @@
             if "SAS_OPENCL" in os.environ:
                 del os.environ["SAS_OPENCL"]
-        sasmodels.kernelcl.reset_environment()
+        sasmodels.sasview_model.reset_environment()
 
         try:
