Index: compare.py
===================================================================
--- compare.py	(revision 3e6aaad2362ecb76256a261b947334089b1601a0)
+++ compare.py	(revision 076300996fb3c63a832e9a4b72e732f2caf60bed)
@@ -100,6 +100,7 @@
     model = sasview_model(name, **pars)
     smearer = smear_selection(data, model=model)
+    value = None  # silence the linter
     toc = tic()
-    for _ in range(Nevals):
+    for _ in range(max(Nevals, 1)):  # make sure there is at least one eval
         if hasattr(data, 'qx_data'):
             q = np.sqrt(data.qx_data**2 + data.qy_data**2)
@@ -120,5 +121,5 @@
     return value, average_time
 
-def eval_opencl(model_definition, pars, data, dtype='single', Nevals=1, cutoff=0):
+def eval_opencl(model_definition, pars, data, dtype='single', Nevals=1, cutoff=0.):
     try:
         model = core.load_model(model_definition, dtype=dtype, platform="ocl")
@@ -128,6 +129,7 @@
         model = core.load_model(model_definition, dtype='single', platform="ocl")
     problem = Experiment(data, Model(model, **pars), cutoff=cutoff)
+    value = None  # silence the linter
     toc = tic()
-    for _ in range(Nevals):
+    for _ in range(max(Nevals, 1)):  # force at least one eval
         #pars['scale'] = np.random.rand()
         problem.update()
@@ -136,9 +138,10 @@
     return value, average_time
 
-def eval_ctypes(model_definition, pars, data, dtype='double', Nevals=1, cutoff=0):
+def eval_ctypes(model_definition, pars, data, dtype='double', Nevals=1, cutoff=0.):
     model = core.load_model(model_definition, dtype=dtype, platform="dll")
     problem = Experiment(data, Model(model, **pars), cutoff=cutoff)
+    value = None  # silence the linter
     toc = tic()
-    for _ in range(Nevals):
+    for _ in range(max(Nevals, 1)):  # force at least one eval
         problem.update()
         value = problem.theory()
@@ -224,18 +227,6 @@
         #bad = (relerr>1e-4)
         #print relerr[bad],cpu[bad],ocl[bad],data.qx_data[bad],data.qy_data[bad]
-        def stats(label,err):
-            sorted_err = np.sort(abs(err))
-            p50 = int((len(err)-1)*0.50)
-            p98 = int((len(err)-1)*0.98)
-            data = [
-                "max:%.3e"%sorted_err[-1],
-                "median:%.3e"%sorted_err[p50],
-                "98%%:%.3e"%sorted_err[p98],
-                "rms:%.3e"%np.sqrt(np.mean(err**2)),
-                "zero-offset:%+.3e"%np.mean(err),
-                ]
-            print label,"  ".join(data)
-        stats("|ocl-%s|"%comp+(" "*(3+len(comp))), resid)
-        stats("|(ocl-%s)/%s|"%(comp,comp), relerr)
+        _print_stats("|ocl-%s|"%comp+(" "*(3+len(comp))), resid)
+        _print_stats("|(ocl-%s)/%s|"%(comp,comp), relerr)
 
     # Plot if requested
@@ -277,4 +268,19 @@
     plt.show()
 
+def _print_stats(label, err):
+    sorted_err = np.sort(abs(err))
+    p50 = int((len(err)-1)*0.50)
+    p98 = int((len(err)-1)*0.98)
+    data = [
+        "max:%.3e"%sorted_err[-1],
+        "median:%.3e"%sorted_err[p50],
+        "98%%:%.3e"%sorted_err[p98],
+        "rms:%.3e"%np.sqrt(np.mean(err**2)),
+        "zero-offset:%+.3e"%np.mean(err),
+        ]
+    print label,"  ".join(data)
+
+
+
 # ===========================================================================
 #
Index: sasmodels/exception.py
===================================================================
--- sasmodels/exception.py	(revision 9e430d04350cd3bdfb68c113efd3fac7a4b68d84)
+++ sasmodels/exception.py	(revision 076300996fb3c63a832e9a4b72e732f2caf60bed)
@@ -2,4 +2,11 @@
 Utility to add annotations to python exceptions.
 """
+
+# Platform cruft: WindowsError is only defined on Windows.
+try:
+    WindowsError
+except NameError:
+    class WindowsError(Exception):
+        pass
 
 def annotate_exception(exc, msg):
@@ -19,4 +26,9 @@
         KeyError: "hello while accessing 'D'"
     """
+    # Can't extend WindowsError exceptions; instead raise a new exception.
+    # TODO: try to incorporate current stack trace in the raised exception
+    if isinstance(exc, WindowsError):
+        raise OSError(str(exc)+msg)
+
     args = exc.args
     if not args:
@@ -28,3 +40,2 @@
         except:
             exc.args = (" ".join((str(exc),msg)),)
-
Index: sasmodels/kernelcl.py
===================================================================
--- sasmodels/kernelcl.py	(revision af1d68cac8f7b0ba2250ae15d55d7337dd0bb727)
+++ sasmodels/kernelcl.py	(revision 076300996fb3c63a832e9a4b72e732f2caf60bed)
@@ -39,5 +39,4 @@
 
 from . import generate
-from .kernelpy import PyModel
 
 F64_DEFS = """\
Index: sasmodels/kerneldll.py
===================================================================
--- sasmodels/kerneldll.py	(revision f3f46cd0a795337bab22c37b21bde97a2743a5ae)
+++ sasmodels/kerneldll.py	(revision 076300996fb3c63a832e9a4b72e732f2caf60bed)
@@ -148,7 +148,4 @@
         try:
             self.dll = ct.CDLL(self.dllpath)
-	except WindowsError, exc:
-	    # TODO: update annotate_exception so it can handle WindowsError
-	    raise RuntimeError(str(exc)+" while loading "+self.dllpath)
         except Exception, exc:
             annotate_exception(exc, "while loading "+self.dllpath)
