Index: src/sas/sascalc/calculator/c_extensions/sld2i_module.cpp
===================================================================
--- src/sas/sascalc/calculator/c_extensions/sld2i_module.cpp	(revision d04ac056c476a91de374975fdb618e1cf1d27ca1)
+++ src/sas/sascalc/calculator/c_extensions/sld2i_module.cpp	(revision 1d014cbb271bb612a92607b84c582f19f50b2b11)
@@ -158,5 +158,5 @@
 #define MODULE_NAME "sld2i"
 #define MODULE_INIT2 initsld2i
-#define MODULE_INIT3 PyInit_reflmodule
+#define MODULE_INIT3 PyInit_sld2i
 #define MODULE_METHODS module_methods
 
Index: src/sas/sascalc/calculator/sas_gen.py
===================================================================
--- src/sas/sascalc/calculator/sas_gen.py	(revision 574adc767a9e86744546f8edd6a23dc4f81914ad)
+++ src/sas/sascalc/calculator/sas_gen.py	(revision 1d014cbb271bb612a92607b84c582f19f50b2b11)
@@ -5,15 +5,24 @@
 from __future__ import print_function
 
-import sas.sascalc.calculator.core.sld2i as mod
-from sas.sascalc.calculator.BaseComponent import BaseComponent
+import os
+import sys
+import copy
+import logging
+
 from periodictable import formula
 from periodictable import nsf
 import numpy as np
-import os
-import copy
-import sys
-import logging
+
+from .core import sld2i as mod
+from .BaseComponent import BaseComponent
 
 logger = logging.getLogger(__name__)
+
+if sys.version_info[0] < 3:
+    def decode(s):
+        return s
+else:
+    def decode(s):
+        return s.decode() if isinstance(s, bytes) else s
 
 MFACTOR_AM = 2.853E-12
@@ -288,5 +297,5 @@
                 z_dir2 *= z_dir2
                 mask = (x_dir2 + y_dir2 + z_dir2) <= 1.0
-            except:
+            except Exception:
                 logger.error(sys.exc_value)
         self.output = MagSLD(self.pos_x[mask], self.pos_y[mask],
@@ -368,5 +377,5 @@
         try:
             input_f = open(path, 'rb')
-            buff = input_f.read()
+            buff = decode(input_f.read())
             lines = buff.split('\n')
             input_f.close()
@@ -374,19 +383,21 @@
             valueunit = None
             for line in lines:
-                toks = line.split()
+                line = line.strip()
                 # Read data
-                try:
-                    _mx = float(toks[0])
-                    _my = float(toks[1])
-                    _mz = float(toks[2])
-                    _mx = mag2sld(_mx, valueunit)
-                    _my = mag2sld(_my, valueunit)
-                    _mz = mag2sld(_mz, valueunit)
-                    mx = np.append(mx, _mx)
-                    my = np.append(my, _my)
-                    mz = np.append(mz, _mz)
-                except:
-                    # Skip non-data lines
-                    logger.error(sys.exc_value)
+                if line and not line.startswith('#'):
+                    try:
+                        toks = line.split()
+                        _mx = float(toks[0])
+                        _my = float(toks[1])
+                        _mz = float(toks[2])
+                        _mx = mag2sld(_mx, valueunit)
+                        _my = mag2sld(_my, valueunit)
+                        _mz = mag2sld(_mz, valueunit)
+                        mx = np.append(mx, _mx)
+                        my = np.append(my, _my)
+                        mz = np.append(mz, _mz)
+                    except Exception as exc:
+                        # Skip non-data lines
+                        logger.error(str(exc)+" when processing %r"%line)
                 #Reading Header; Segment count ignored
                 s_line = line.split(":", 1)
@@ -472,5 +483,5 @@
             output.set_m(mx, my, mz)
             return output
-        except:
+        except Exception:
             msg = "%s is not supported: \n" % path
             msg += "We accept only Text format OMF file."
@@ -512,5 +523,5 @@
         try:
             input_f = open(path, 'rb')
-            buff = input_f.read()
+            buff = decode(input_f.read())
             lines = buff.split('\n')
             input_f.close()
@@ -526,5 +537,5 @@
                             float(line[12])
                             atom_name = atom_name[1].upper()
-                        except:
+                        except Exception:
                             if len(atom_name) == 4:
                                 atom_name = atom_name[0].upper()
@@ -549,5 +560,5 @@
                             vol = 1.0e+24 * atom.mass / atom.density / NA
                             vol_pix = np.append(vol_pix, vol)
-                        except:
+                        except Exception:
                             print("Error: set the sld of %s to zero"% atom_name)
                             sld_n = np.append(sld_n, 0.0)
@@ -563,5 +574,5 @@
                             try:
                                 int_val = int(val)
-                            except:
+                            except Exception:
                                 break
                             if int_val == 0:
@@ -582,5 +593,5 @@
                         y_lines.append(y_line)
                         z_lines.append(z_line)
-                except:
+                except Exception:
                     logger.error(sys.exc_value)
 
@@ -594,5 +605,5 @@
             output.sld_unit = '1/A^(2)'
             return output
-        except:
+        except Exception:
             raise RuntimeError("%s is not a sld file" % path)
 
@@ -647,8 +658,8 @@
                 elif ncols == 7:
                     vol_pix = None
-            except:
+            except Exception:
                 # For older version of numpy
                 input_f = open(path, 'rb')
-                buff = input_f.read()
+                buff = decode(input_f.read())
                 lines = buff.split('\n')
                 input_f.close()
@@ -673,7 +684,7 @@
                             _vol_pix = float(toks[7])
                             vol_pix = np.append(vol_pix, _vol_pix)
-                        except:
+                        except Exception:
                             vol_pix = None
-                    except:
+                    except Exception:
                         # Skip non-data lines
                         logger.error(sys.exc_value)
@@ -686,5 +697,5 @@
                 output.set_pixel_volumes(vol_pix)
             return output
-        except:
+        except Exception:
             raise RuntimeError("%s is not a sld file" % path)
 
@@ -967,5 +978,5 @@
                 self.ynodes = int(ydist) + 1
                 self.znodes = int(zdist) + 1
-            except:
+            except Exception:
                 self.xnodes = None
                 self.ynodes = None
@@ -1002,5 +1013,5 @@
                 self.set_pixel_volumes(vol)
                 self.has_stepsize = True
-            except:
+            except Exception:
                 self.xstepsize = None
                 self.ystepsize = None
@@ -1047,6 +1058,6 @@
     reader = SLDReader()
     oreader = OMFReader()
-    output = reader.read(tfpath)
-    ooutput = oreader.read(ofpath)
+    output = decode(reader.read(tfpath))
+    ooutput = decode(oreader.read(ofpath))
     foutput = OMF2SLD()
     foutput.set_data(ooutput)
@@ -1089,5 +1100,5 @@
             break
     oreader = OMFReader()
-    ooutput = oreader.read(ofpath)
+    ooutput = decode(oreader.read(ofpath))
     foutput = OMF2SLD()
     foutput.set_data(ooutput)
Index: test/sascalculator/test/utest_sas_gen.py
===================================================================
--- test/sascalculator/test/utest_sas_gen.py	(revision 959eb0181ad06828a748f04512f953aad5b31659)
+++ test/sascalculator/test/utest_sas_gen.py	(revision 1d014cbb271bb612a92607b84c582f19f50b2b11)
@@ -10,13 +10,13 @@
 
 class sas_gen_test(unittest.TestCase):
-    
+
     def setUp(self):
         self.sldloader = sas_gen.SLDReader()
         self.pdbloader = sas_gen.PDBReader()
         self.omfloader = sas_gen.OMFReader()
-        
+
     def test_sldreader(self):
         """
-        Test .sld file loaded 
+        Test .sld file loaded
         """
         f = self.sldloader.read("sld_file.sld")
@@ -24,8 +24,8 @@
         self.assertEqual(f.pos_y[0], -13.5)
         self.assertEqual(f.pos_z[0], -13.5)
-        
+
     def test_pdbreader(self):
         """
-        Test .pdb file loaded 
+        Test .pdb file loaded
         """
         f = self.pdbloader.read("c60.pdb")
@@ -33,8 +33,8 @@
         self.assertEqual(f.pos_y[0], -1.008)
         self.assertEqual(f.pos_z[0], 3.326)
-        
+
     def test_omfreader(self):
         """
-        Test .omf file loaded 
+        Test .omf file loaded
         """
         f = self.omfloader.read("A_Raw_Example-1.omf")
