diff --git a/bin/test_hg_beam.py b/bin/test_hg_beam.py
index 370407fdbaff41b0cb74ba768068d722b25c43fa..a071c4c5503e657bf5e712bf518682e52a19a79c 100644
--- a/bin/test_hg_beam.py
+++ b/bin/test_hg_beam.py
@@ -8,4 +8,6 @@ beam = HG_beam(gx,gy,0,0)
 beam.n = 5
 beam.m = 6
 
-beam.plot()
\ No newline at end of file
+beam.plot()
+
+
diff --git a/pykat/commands.py b/pykat/commands.py
index bf546c04f3841e2a0d3b581e20440997f413e260..a8d95cf0c209004085216a03ea7a04b401044e74 100644
--- a/pykat/commands.py
+++ b/pykat/commands.py
@@ -20,7 +20,7 @@ class Command(object):
     def __init__(self, name):
         self.tag = None
         self.__removed = False
-        self.__name = name
+        self.__name = name.strip("*")
         
     def getFinesseText(self):
         """ Base class for individual finesse optical components """
diff --git a/pykat/finesse.py b/pykat/finesse.py
index 272d28f1038a61a652f451224c8435df96c9103c..1ea7aaf348e8fc9175b8f740dbdcb8db67b66fa5 100644
--- a/pykat/finesse.py
+++ b/pykat/finesse.py
@@ -484,15 +484,15 @@ class kat(object):
   (        '::;;+;;:      `-"' =" /,`"" `) /
   L.        \\`:::a:f            c_/     n_'
   ..`--...___`.  .    ,  
-   `^-....____:   +.      {1}""".format(pykat.__version__, pykat_web)
+   `^-....____:   +.      {1}\n""".format(pykat.__version__, pykat_web)
     
-    def loadKatFile(self, katfile):
+    def loadKatFile(self, katfile, blocks=None):
         commands=open(katfile).read()
-        self.parseCommands(commands)
+        self.parseCommands(commands, blocks=blocks)
     
-    def parseKatCode(self, code):
+    def parseKatCode(self, code, blocks=None):
         #commands = code.split("\n")
-        self.parseCommands(code)
+        self.parseCommands(code, blocks=blocks)
 
     def processConstants(self, commands):
         """
@@ -547,7 +547,7 @@ class kat(object):
         
         return commands_new
         
-    def parseCommands(self, commands):
+    def parseCommands(self, commands, blocks=None):
         blockComment = False
         
         commands=self.remove_comments(commands)
@@ -558,153 +558,163 @@ class kat(object):
                            # objects have been set and created
         
         for line in commands:
-            #for line in commands:
-            if len(line.strip()) >= 2:
-                line = line.strip()
-
-                # Looking for block start or end
-                values = line.split()
-                if values[0] == "%%%":
-                    if values[1] == "FTblock":
-                        newTag = values[2]
+            try:
+                if len(line.strip()) >= 2:
+                    line = line.strip()
+
+                    # Looking for block start or end
+                    values = line.split()
+                
+                    if values[0] == "%%%":
+                        if values[1] == "FTblock":
+                            newTag = values[2]
                         
-                        if self.__currentTag != None and self.__currentTag != NO_BLOCK: 
-                            warnings.warn("found block {0} before block {1} ended".format(newTag, self.__currentTag))    
+                            if self.__currentTag != None and self.__currentTag != NO_BLOCK: 
+                                warnings.warn("found block {0} before block {1} ended".format(newTag, self.__currentTag))    
                             
-                        if newTag in self.__blocks:
-                            raise pkex.BasePyKatException("Block `{0}` has already been read".format(newTag))
+                            if newTag in self.__blocks:
+                                raise pkex.BasePyKatException("Block `{0}` has already been read".format(newTag))
                             
-                        self.__blocks[newTag] = Block(newTag) # create new list to store all references to components in block
-                        self.__currentTag = newTag
+                            self.__blocks[newTag] = Block(newTag) # create new list to store all references to components in block
+                            self.__currentTag = newTag
                         
-                    if values[1] == "FTend":
-                        self.__currentTag = NO_BLOCK
+                        if values[1] == "FTend":
+                            self.__currentTag = NO_BLOCK
                         
-                    continue
-                #warnings.warn("current tag {0}".format(self.__currentTag))    
+                        continue
 
-                # don't read comment lines
-                if line[0] == "#" or line[0] == "%":
-                    continue
+                    # only include listed blocks, if we have specfied them
+                    if blocks != None and self.__currentTag not in blocks:
+                        continue
+                    
+                    # don't read comment lines
+                    if line[0] == "#" or line[0] == "%":
+                        continue
                 
-                # check if block comment is being used
-                if not blockComment and line[0:2] == "/*":
-                    blockComment = True
-                    continue
-                elif blockComment and line[0:2] == "*/":
-                    blockComment = False
-                    continue
+                    # check if block comment is being used
+                    if not blockComment and line[0:2] == "/*":
+                        blockComment = True
+                        continue
+                    elif blockComment and line[0:2] == "*/":
+                        blockComment = False
+                        continue
                 
-                first = line.split(" ",1)[0]
-                obj = None
-                if(first == "m" or first == "m1" or first == "m2"):
-                    obj = pykat.components.mirror.parseFinesseText(line)
-                elif(first == "s"):
-                    obj = pykat.components.space.parseFinesseText(line)
-                elif(first == "l"):
-                    obj = pykat.components.laser.parseFinesseText(line)
-                elif(first == "sq"):
-                    obj = pykat.components.squeezer.parseFinesseText(line)
-                elif(first[0:2] == "bs"):
-                    obj = pykat.components.beamSplitter.parseFinesseText(line)
-                elif(first[0:2] == "gr"):
-                    obj = pykat.components.grating.parseFinesseText(line)
-                elif(first[0:4] == "isol"):
-                    obj = pykat.components.isolator.parseFinesseText(line)
-                elif(first[0:4] == "lens"):
-                    obj = pykat.components.lens.parseFinesseText(line)
-                elif(first[0:3] == "mod"):
-                    obj = pykat.components.modulator.parseFinesseText(line)
-                elif(first[0:2] == "ad"):
-                    obj = pykat.detectors.ad.parseFinesseText(line)
-                elif(first[0:2] == "bp"):
-                    obj = pykat.detectors.bp.parseFinesseText(line)
-                elif(first[0:4] == "gouy"):
-                    obj = pykat.detectors.gouy.parseFinesseText(line)
-                elif(first[0:2] == "pd" and first != "pdtype"):
-                    obj = pykat.detectors.pd.parseFinesseText(line)
-                elif(first == "qshot" or first == "qshotS" or first == "qshotN"):
-                    obj = pykat.detectors.qshot.parseFinesseText(line)
-                elif(first == "qnoised" or first == "qnoisedS" or first == "qnoisedN"):
-                    obj = pykat.detectors.qnoised.parseFinesseText(line)
-                elif(first == "xaxis" or first == "xaxis*"):
-                    obj = pykat.commands.xaxis.parseFinesseText(line)
-                elif(first == "x2axis" or first == "x2axis*"):
-                    obj = pykat.commands.x2axis.parseFinesseText(line)
-                elif(first == "gauss" or first == "gauss*" or first == "gauss**"):
-                    after_process.append(line)
-                elif(first == "scale"):
-                    after_process.append(line)
-                elif(first == "pdtype"):
-                    after_process.append(line)
-                elif(first == "attr"):
-                    after_process.append(line)
-                elif(first == "noxaxis"):
-                    self.noxaxis = True
-                elif(first == "lambda"):
-                    v = line.split()
-                    self.lambda0 = SIfloat(v[-1])
-                elif(first == "yaxis"):
-                    v = line.split()
+                    first = line.split(" ",1)[0]
+                    obj = None
                     
-                    self.yaxis = v[-1]
-                elif(first == "phase"):
-                    v = line.split()
-                    if len(v) != 2:
-                        raise pkex.BasePyKatException("phase command `{0}` is incorrect.".format(line))
-                    else:
-                        self.phase = int(v[1])
-                elif(first == "maxtem"):
-                    v = line.split()
-                    if len(v) != 2:
-                        raise pkex.BasePyKatException("maxtem command `{0}` is incorrect.".format(line))
-                    else:
-                        if v[1] == "off":
-                        	self.maxtem = -1
+                    if(first == "m" or first == "m1" or first == "m2"):
+                        obj = pykat.components.mirror.parseFinesseText(line)
+                    elif(first == "s"):
+                        obj = pykat.components.space.parseFinesseText(line)
+                    elif(first == "l"):
+                        obj = pykat.components.laser.parseFinesseText(line)
+                    elif(first == "sq"):
+                        obj = pykat.components.squeezer.parseFinesseText(line)
+                    elif(first[0:2] == "bs"):
+                        obj = pykat.components.beamSplitter.parseFinesseText(line)
+                    elif(first[0:2] == "gr"):
+                        obj = pykat.components.grating.parseFinesseText(line)
+                    elif(first[0:4] == "isol"):
+                        obj = pykat.components.isolator.parseFinesseText(line)
+                    elif(first[0:4] == "lens"):
+                        obj = pykat.components.lens.parseFinesseText(line)
+                    elif(first[0:3] == "mod"):
+                        obj = pykat.components.modulator.parseFinesseText(line)
+                    elif(first[0:2] == "ad"):
+                        obj = pykat.detectors.ad.parseFinesseText(line)
+                    elif(first[0:2] == "bp"):
+                        obj = pykat.detectors.bp.parseFinesseText(line)
+                    elif(first[0:4] == "gouy"):
+                        obj = pykat.detectors.gouy.parseFinesseText(line)
+                    elif(first[0:2] == "pd" and first != "pdtype"):
+                        obj = pykat.detectors.pd.parseFinesseText(line)
+                    elif(first == "qshot" or first == "qshotS" or first == "qshotN"):
+                        obj = pykat.detectors.qshot.parseFinesseText(line)
+                    elif(first == "qnoised" or first == "qnoisedS" or first == "qnoisedN"):
+                        obj = pykat.detectors.qnoised.parseFinesseText(line)
+                    elif(first == "xaxis" or first == "xaxis*"):
+                        obj = pykat.commands.xaxis.parseFinesseText(line)
+                    elif(first == "x2axis" or first == "x2axis*"):
+                        obj = pykat.commands.x2axis.parseFinesseText(line)
+                    elif(first == "gauss" or first == "gauss*" or first == "gauss**"):
+                        after_process.append(line)
+                    elif(first == "scale"):
+                        after_process.append(line)
+                    elif(first == "pdtype"):
+                        after_process.append(line)
+                    elif(first == "attr"):
+                        after_process.append(line)
+                    elif(first == "noxaxis"):
+                        self.noxaxis = True
+                    elif(first == "lambda"):
+                        v = line.split()
+                        self.lambda0 = SIfloat(v[-1])
+                    elif(first == "yaxis"):
+                        v = line.split()
+                    
+                        self.yaxis = v[-1]
+                    elif(first == "phase"):
+                        v = line.split()
+                        if len(v) != 2:
+                            raise pkex.BasePyKatException("phase command `{0}` is incorrect.".format(line))
+                        else:
+                            self.phase = int(v[1])
+                    elif(first == "maxtem"):
+                        v = line.split()
+                        if len(v) != 2:
+                            raise pkex.BasePyKatException("maxtem command `{0}` is incorrect.".format(line))
+                        else:
+                            if v[1] == "off":
+                            	self.maxtem = -1
+                            else:
+    	                        self.maxtem = int(v[1])
+                    elif(first == "trace"):
+                        v = line.split()
+                        if len(v) > 2:
+                            raise pkex.BasePyKatException("Trace command `{0}` is incorrect.".format(line))
+                        elif len(v) == 2:
+                            self.trace = v[1]
+                    elif(first == "retrace"):
+                        v = line.split()
+                        if len(v) > 2:
+                            raise pkex.BasePyKatException("Retrace command `{0}` is incorrect.".format(line))
+                        elif len(v) == 2:
+                            self.retrace = v[1]                        
+                    elif(first == "deriv_h"):
+                        v = line.split()
+                        if len(v) != 2:
+                            raise pkex.BasePyKatException("deriv_h command `{0}` is incorrect.".format(line))
                         else:
-	                        self.maxtem = int(v[1])
-                elif(first == "trace"):
-                    v = line.split()
-                    if len(v) > 2:
-                        raise pkex.BasePyKatException("Trace command `{0}` is incorrect.".format(line))
-                    elif len(v) == 2:
-                        self.trace = v[1]
-                elif(first == "retrace"):
-                    v = line.split()
-                    if len(v) > 2:
-                        raise pkex.BasePyKatException("Retrace command `{0}` is incorrect.".format(line))
-                    elif len(v) == 2:
-                        self.retrace = v[1]                        
-                elif(first == "deriv_h"):
-                    v = line.split()
-                    if len(v) != 2:
-                        raise pkex.BasePyKatException("deriv_h command `{0}` is incorrect.".format(line))
+                            self.deriv_h = float(v[1])
+                    elif(first == "gnuterm" or first == "pyterm"):
+                        if self.verbose:
+                            print "Ignoring Gnuplot/Python terminal command '{0}'".format(line)
+                    #elif(first == "fsig"):
+                    #    after_process.append(line)
+                    elif(first == "noplot"):
+                        obj = line
+                        self.__blocks[self.__currentTag].contents.append(line) 
                     else:
-                        self.deriv_h = float(v[1])
-                elif(first == "gnuterm" or first == "pyterm"):
-                    if self.verbose:
-                        print "Ignoring Gnuplot/Python terminal command '{0}'".format(line)
-                #elif(first == "fsig"):
-                #    after_process.append(line)
-                elif(first == "noplot"):
-                    obj = line
-                    self.__blocks[self.__currentTag].contents.append(line) 
-                else:
-                    if self.verbose:
-                        print "Parsing `{0}` into pykat object not implemented yet, added as extra line.".format(line)
+                        if self.verbose:
+                            print "Parsing `{0}` into pykat object not implemented yet, added as extra line.".format(line)
                         
-                    obj = line
-                    # manually add the line to the block contents
-                    self.__blocks[self.__currentTag].contents.append(line) 
+                        obj = line
+                        # manually add the line to the block contents
+                        self.__blocks[self.__currentTag].contents.append(line) 
                 
-                if obj != None and not isinstance(obj, str):
-                    if self.hasNamedObject(obj.name):
-                        getattr(self, obj.name).remove()
-                        print "Removed existing object '{0}' of type {1} to add line '{2}'".format(obj.name, obj.__class__, line)
+                    if obj != None and not isinstance(obj, str):
+                        if self.hasNamedObject(obj.name):
+                            getattr(self, obj.name).remove()
+                            print "Removed existing object '{0}' of type {1} to add line '{2}'".format(obj.name, obj.__class__, line)
                         
-                    self.add(obj)
-                    
-                    
+                        self.add(obj)
+            except:
+                print "--------------------------------------------------------"
+                print "Error parsing line: " + line
+                print "--------------------------------------------------------"
+                raise
+                
+                
         # now process all the varous gauss/attr etc. commands which require
         # components to exist first before they can be processed
         for line in after_process:
@@ -888,13 +898,13 @@ class kat(object):
                     # remove any ANSI commands
                     ansi = re.compile(r'\x1b[^m]*m')
                     line = ansi.sub('', line)
-                    
+
                     # warnings and errors start with an asterisk 
                     # so if verbose show them
                     if line.lstrip().startswith('*'):
                         if self.verbose: sys.stdout.write(line)
                         
-                    elif line.rstrip().endswith('s') and line.contains('%'):
+                    elif line.rstrip().endswith('s') and '%' in line:
                         vals = line.split("-")
                         action = vals[0].strip()
                         prc = vals[1].strip()[:]
diff --git a/pykat/testing/web_server.py b/pykat/testing/web_server.py
index 165897c69bcc6ce3fdd397f5a84e3a379518d47a..30b482e0ea6447823df6582e0f123d74c779abb2 100644
--- a/pykat/testing/web_server.py
+++ b/pykat/testing/web_server.py
@@ -43,6 +43,7 @@ def start(instance_path,port=5000, debug=True, ip="0.0.0.0", git_bin="/usr/bin/g
     if not os.path.exists(os.path.join(app.instance_path,"finesse_test")):
         print "finesse test folder didn't exist, cloning now..."
         utils.git(["clone","git://gitmaster.atlas.aei.uni-hannover.de/finesse/test.git","finesse_test"])
+        utils.git(["config","core.sharedRepository","true"], cwd="./finesse_test/")
     
     # load up the actual interface code
     import pykat.testing.web.web_interface
diff --git a/pykat/utilities/optics/gaussian_beams.py b/pykat/utilities/optics/gaussian_beams.py
index ac62b382bd3b1015a8ae407f14a39c2d00824d10..a0ecbe15bf9876d1033547f2f988647a7ad64c14 100644
--- a/pykat/utilities/optics/gaussian_beams.py
+++ b/pykat/utilities/optics/gaussian_beams.py
@@ -319,12 +319,12 @@ class HG_beam(object):
             
     def _calc_constants(self):
         self.__xpre_const = math.pow(2.0/math.pi, 0.25)
-        self.__xpre_const *= np.sqrt(1.0/(self._qx.w0 * 2**(self._n) * np.factorial(self._n)))
+        self.__xpre_const *= np.sqrt(1.0/(self._qx.w0 * 2**(self._n) * np.math.factorial(self._n)))
         self.__xpre_const *= np.sqrt(1j*self._qx.imag / self._qx.q)
         self.__xpre_const *= ((1j*self._qx.imag * self._qx.q.conjugate())/(-1j*self._qx.imag * self._qx.q)) ** ( self._n/2.0)
         
         self.__ypre_const = math.pow(2.0/math.pi, 0.25)
-        self.__ypre_const *= np.sqrt(1.0/(self._qy.w0 * 2**(self._m) * np.factorial(self._m)))
+        self.__ypre_const *= np.sqrt(1.0/(self._qy.w0 * 2**(self._m) * np.math.factorial(self._m)))
         self.__ypre_const *= np.sqrt(1j*self._qy.imag / self._qy.q)
         self.__ypre_const *= ((1j*self._qy.imag * self._qy.q.conjugate())/(-1j*self._qy.imag * self._qy.q)) **(self._m/2.0)