diff --git a/gui/slick/views/config_postProcessing.mako b/gui/slick/views/config_postProcessing.mako
index b51c0e5f514a7cad54158b94c8ec54ef4d41122f..9e4f659c6660601ac5f766c46be0af3cb9798bff 100644
--- a/gui/slick/views/config_postProcessing.mako
+++ b/gui/slick/views/config_postProcessing.mako
@@ -699,7 +699,7 @@
                                                 % if cur_preset == sickbeard.NAMING_SPORTS_PATTERN:
                                                     <% is_sports_custom = False %>
                                                 % endif
-                                                <option id="${cur_preset}" ${('', 'selected="selected"')[NAMING_SPORTS_PATTERN == cur_preset]}>${ek(os.path.join, tmp['dir'], tmp['name'])}</option>
+                                                <option id="${cur_preset}" ${('', 'selected="selected"')[sickbeard.NAMING_SPORTS_PATTERN == cur_preset]}>${ek(os.path.join, tmp['dir'], tmp['name'])}</option>
                                             % endfor
                                             <option id="${sickbeard.NAMING_SPORTS_PATTERN}" ${('', 'selected="selected"')[bool(is_sports_custom)]}>Custom...</option>
                                         </select>
diff --git a/gui/slick/views/displayShow.mako b/gui/slick/views/displayShow.mako
index fd52eb56b48bdacefe2b24b7f4aa5499e0e79b39..3e167a0a44bcea354c769a143371a6a148bc9db9 100644
--- a/gui/slick/views/displayShow.mako
+++ b/gui/slick/views/displayShow.mako
@@ -7,7 +7,7 @@
     from sickbeard import subtitles, sbdatetime, network_timezones
     import sickbeard.helpers
 
-    from sickbeard.common import SKIPPED, WANTED, UNAIRED, ARCHIVED, IGNORED, FAILED
+    from sickbeard.common import SKIPPED, WANTED, UNAIRED, ARCHIVED, IGNORED, FAILED, DOWNLOADED
     from sickbeard.common import Quality, qualityPresets, statusStrings, Overview
     from sickbeard.helpers import anon_url
     from sickrage.helper.common import pretty_file_size
@@ -234,7 +234,7 @@
         % if not sickbeard.USE_FAILED_DOWNLOADS:
         <% availableStatus.remove(FAILED) %>
         % endif
-        % for curStatus in availableStatus + sorted(Quality.DOWNLOADED) + sorted(Quality.ARCHIVED):
+        % for curStatus in availableStatus + Quality.DOWNLOADED + Quality.ARCHIVED:
             % if curStatus not in [DOWNLOADED, ARCHIVED]:
             <option value="${curStatus}">${statusStrings[curStatus]}</option>
             % endif
diff --git a/gui/slick/views/layouts/main.mako b/gui/slick/views/layouts/main.mako
index 9da4508649d58ef1f425dbfef31bd897daf1fe8f..a839a7706455cbf7b1c11bcc940a9db95cb7da56 100644
--- a/gui/slick/views/layouts/main.mako
+++ b/gui/slick/views/layouts/main.mako
@@ -234,8 +234,7 @@
                 </div><!-- /.navbar-collapse -->
             </div><!-- /.container-fluid -->
         </nav>
-
-        % if not submenu is UNDEFINED:
+        % if submenu:
         <div id="SubMenu" class="hidden-print">
             <span>
             <% first = True %>
@@ -261,7 +260,6 @@
             </span>
         </div>
         % endif
-
         % if sickbeard.BRANCH and sickbeard.BRANCH != 'master' and not sickbeard.DEVELOPER and srLogin:
         <div class="alert alert-danger upgrade-notification hidden-print" role="alert">
             <span>You're using the ${sickbeard.BRANCH} branch. Please use 'master' unless specifically asked</span>
diff --git a/gui/slick/views/manage_episodeStatuses.mako b/gui/slick/views/manage_episodeStatuses.mako
index 8eb406cd0bad3960068da18c7f2976587754a572..911d88e2f9376d1578704549a32f8bd0aa3f3c33 100644
--- a/gui/slick/views/manage_episodeStatuses.mako
+++ b/gui/slick/views/manage_episodeStatuses.mako
@@ -26,7 +26,7 @@
 <form action="${srRoot}/manage/episodeStatuses" method="get">
 Manage episodes with status <select name="whichStatus" class="form-control form-control-inline input-sm">
 % for curStatus in [common.SKIPPED, common.SNATCHED, common.WANTED, common.IGNORED] + common.Quality.DOWNLOADED + common.Quality.ARCHIVED:
-    %if surStatus not in [common.ARCHIVED, common.DOWNLOADED]:
+    %if curStatus not in [common.ARCHIVED, common.DOWNLOADED]:
         <option value="${curStatus}">${common.statusStrings[curStatus]}</option>
     %endif
 % endfor
diff --git a/sickbeard/postProcessor.py b/sickbeard/postProcessor.py
index 0e33b65de3d96861666ffd15c0249c4070749584..2d45fc2188e1bd768de517e49f4191555d19ef59 100644
--- a/sickbeard/postProcessor.py
+++ b/sickbeard/postProcessor.py
@@ -487,7 +487,7 @@ class PostProcessor(object):
         myDB = db.DBConnection()
         for curName in names:
             search_name = re.sub(r"[\.\- ]", "_", curName)
-            sql_results = myDB.select("SELECT showid, season, quality, version, resource FROM history WHERE resource LIKE ? AND action LIKE '%4'", [search_name])
+            sql_results = myDB.select("SELECT showid, season, quality, version, resource FROM history WHERE resource LIKE ?", [search_name])
 
             if len(sql_results) == 0:
                 continue
@@ -853,11 +853,6 @@ class PostProcessor(object):
             return True
 
         _, old_ep_quality = common.Quality.splitCompositeStatus(ep_obj.status)
-        self._log(u"old_ep_quality = %s, new_ep_quality %s" % (common.Quality.qualityStrings[old_ep_quality], common.Quality.qualityStrings[new_ep_quality]), logger.DEBUG)
-
-        if old_ep_quality == common.Quality.UNKNOWN and new_ep_quality != common.Quality.UNKNOWN:
-            self._log(u"Old episode has an unknown quality, so any known quality is better", logger.DEBUG)
-            return True
 
         # if SR downloaded this on purpose we likely have a priority download
         if self.in_history or ep_obj.status in common.Quality.SNATCHED + common.Quality.SNATCHED_PROPER + common.Quality.SNATCHED_BEST:
@@ -955,27 +950,18 @@ class PostProcessor(object):
         # check for an existing file
         existing_file_status = self._checkForExistingFile(ep_obj.location)
 
-        # if it's not priority then we don't want to replace smaller files in case it was a mistake
         if not priority_download:
-
-            # Not a priority and the quality is lower than what we already have
-            if (new_ep_quality < old_ep_quality and old_ep_quality != common.Quality.UNKNOWN) and not existing_file_status == PostProcessor.DOESNT_EXIST:
-                self._log(u"File exists and new file quality is lower than existing, marking it unsafe to replace")
+            if existing_file_status == PostProcessor.EXISTS_SAME:
+                self._log(u"File exists and new file is same size, marking it unsafe to replace")
                 return False
 
-            # if there's an existing file that we don't want to replace stop here
-            if existing_file_status == PostProcessor.EXISTS_LARGER:
-                if self.is_proper:
-                    self._log(
-                        u"File exists and new file is smaller, new file is a proper/repack, marking it safe to replace")
+            if new_ep_quality <= old_ep_quality and old_ep_quality != common.Quality.UNKNOWN and existing_file_status != PostProcessor.DOESNT_EXIST:
+                if self.is_proper and new_ep_quality == old_ep_quality:
+                    self._log(u"New file is a proper/repack, marking it safe to replace")
                 else:
-                    self._log(u"File exists and new file is smaller, marking it unsafe to replace")
+                    self._log(u"File exists and new file is the same or lower quality than existing, marking it unsafe to replace")
                     return False
 
-            elif existing_file_status == PostProcessor.EXISTS_SAME:
-                self._log(u"File exists and new file is same size, marking it unsafe to replace")
-                return False
-
             # Check if the processed file season is already in our indexer. If not, the file is most probably mislabled/fake and will be skipped
             # Only proceed if the file season is > 0
             if int(ep_obj.season) > 0:
diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py
index 2ad46f506e5bbbbd589225ba887f5295e5bb31ed..ade8e406648e1083e37c36b1a1d30544aa4ee3e2 100644
--- a/sickbeard/webserve.py
+++ b/sickbeard/webserve.py
@@ -102,7 +102,8 @@ def get_lookup():
     if mako_cache is None:
         mako_cache = ek(os.path.join, sickbeard.CACHE_DIR, 'mako')
     if mako_lookup is None:
-        mako_lookup = TemplateLookup(directories=[mako_path], module_directory=mako_cache, format_exceptions=True)
+        use_strict = sickbeard.BRANCH and sickbeard.BRANCH != 'master'
+        mako_lookup = TemplateLookup(directories=[mako_path], module_directory=mako_cache, format_exceptions=True, strict_undefined=use_strict)
     return mako_lookup
 
 
@@ -143,6 +144,7 @@ class PageTemplate(MakoTemplate):
         self.arguments['title'] = "FixME"
         self.arguments['header'] = "FixME"
         self.arguments['topmenu'] = "FixME"
+        self.arguments['submenu'] = []
         self.arguments['controller'] = "FixME"
         self.arguments['action'] = "FixME"
 
@@ -999,7 +1001,7 @@ class Home(WebRoot):
         size = 0
         for r in rows:
             NotifyList = {'emails':'', 'prowlAPIs':''}
-            if (r['notify_list'] and len(r['notify_list']) > 0):
+            if r['notify_list'] and len(r['notify_list']) > 0:
                 # First, handle legacy format (emails only)
                 if not r['notify_list'][0] == '{':
                     NotifyList['emails'] = r['notify_list']
@@ -2877,7 +2879,9 @@ class Manage(Home, WebRoot):
         if not status_list:
             return t.render(
                 title="Episode Overview", header="Episode Overview",
-                topmenu="manage", whichStatus=whichStatus, controller="manage", action="episodeStatuses")
+                topmenu="manage", show_names=None, whichStatus=whichStatus,
+                ep_counts=None, sorted_show_ids=None,
+                controller="manage", action="episodeStatuses")
 
         myDB = db.DBConnection()
         status_results = myDB.select(
@@ -2978,6 +2982,7 @@ class Manage(Home, WebRoot):
         if not whichSubs:
             return t.render(whichSubs=whichSubs, title='Episode Overview',
                             header='Episode Overview', topmenu='manage',
+                            show_names=None, ep_counts=None, sorted_show_ids=None,
                             controller="manage", action="subtitleMissed")
 
         myDB = db.DBConnection()