diff --git a/SickBeard.py b/SickBeard.py
index 2ea7a99f4800a4c34e22ed13744fced670399e9f..93b5b140cbdecc857388b2096e71873297daa68c 100755
--- a/SickBeard.py
+++ b/SickBeard.py
@@ -301,6 +301,14 @@ class SickRage(object):
         # Build from the DB to start with
         self.loadShowsFromDB()
 
+        if self.consoleLogging:
+            print "Starting up SickRage " + sickbeard.BRANCH + " from " + sickbeard.CONFIG_FILE
+
+        # Clean up after update
+        if sickbeard.GIT_NEWVER:
+            shutil.rmtree(ek(os.path.join, sickbeard.CACHE_DIR, 'mako'))
+            sickbeard.GIT_NEWVER = False
+
         if self.forcedPort:
             logger.log(u"Forcing web server to port " + str(self.forcedPort))
             self.startPort = self.forcedPort
@@ -341,19 +349,6 @@ class SickRage(object):
         self.webserver = SRWebServer(self.web_options)
         self.webserver.start()
 
-        if self.consoleLogging:
-            print "Starting up SickRage " + sickbeard.BRANCH + " from " + sickbeard.CONFIG_FILE
-
-        # Clean up after update
-        if sickbeard.GIT_NEWVER:
-            toclean = ek(os.path.join, sickbeard.CACHE_DIR, 'mako')
-            for root, dirs, files in ek(os.walk, toclean, topdown=False):
-                for name in files:
-                    ek(os.remove, ek(os.path.join, root, name))
-                for name in dirs:
-                    ek(os.rmdir, ek(os.path.join, root, name))
-            sickbeard.GIT_NEWVER = False
-
         # Fire up all our threads
         sickbeard.start()
 
@@ -503,6 +498,12 @@ class SickRage(object):
                 except Exception:
                     pass
 
+            try:
+                logger.log(u"Halt: Trying to remove the cache/mako directory")
+                shutil.rmtree(ek(os.path.join, sickbeard.CACHE_DIR, 'mako'))
+            except Exception:
+                logger.log(u"Halt: Unable to remove the cache/mako directory!", logger.WARNING)
+
             # if run as daemon delete the pidfile
             if self.runAsDaemon and self.CREATEPID:
                 self.remove_pid_file(self.PIDFILE)
diff --git a/sickbeard/__init__.py b/sickbeard/__init__.py
index 6ebb0f92be55e53172deef461f5360e5e530cc43..e6043c7bb84641e262e46e8ea8b0e475c2405d78 100644
--- a/sickbeard/__init__.py
+++ b/sickbeard/__init__.py
@@ -1576,7 +1576,7 @@ def halt():
                     pass
 
             __INITIALIZED__ = False
-            started = False
+        started = False
 
 
 def sig_handler(signum=None, frame=None):