diff --git a/css/thread.css b/css/thread.css
index 14c0c694d7ce5e76346027181ef3404ee79506e6..6a9ebbd38d8aa81bc266ddb29f083f951f10ff15 100644
--- a/css/thread.css
+++ b/css/thread.css
@@ -410,7 +410,6 @@
     margin-bottom: 0 !important;
 }
 
-.thread-body > div div:not(.caption),
 .thread-body p,
 .thread-body ul,
 .thread-body ol,
@@ -419,7 +418,7 @@
 .thread-body blockquote,
 .thread-body pre {
 	margin: 0;
-	margin-bottom: 10px !important;
+	margin-bottom: 10px;
 	border: none;
 	background: none !important;
 	box-shadow: none !important;
diff --git a/include/class.dept.php b/include/class.dept.php
index 44bf6561ebbb33ae92b357fdd7e2034f6aab4166..0fb59d36faffdbb941275e3f364213062f955b4e 100644
--- a/include/class.dept.php
+++ b/include/class.dept.php
@@ -275,7 +275,11 @@ class Dept {
     function delete() {
         global $cfg;
 
-        if(!$cfg || $this->getId()==$cfg->getDefaultDeptId() || $this->getNumUsers())
+        if(!$cfg
+                // Default department cannot be deleted
+                || $this->getId()==$cfg->getDefaultDeptId()
+                // Department  with users cannot be deleted
+                || $this->getNumUsers())
             return 0;
 
         $id=$this->getId();
@@ -286,8 +290,12 @@ class Dept {
             db_query('UPDATE '.TICKET_TABLE.' SET dept_id='.db_input($cfg->getDefaultDeptId()).' WHERE dept_id='.db_input($id));
             //Move Dept members: This should never happen..since delete should be issued only to empty Depts...but check it anyways
             db_query('UPDATE '.STAFF_TABLE.' SET dept_id='.db_input($cfg->getDefaultDeptId()).' WHERE dept_id='.db_input($id));
-            //make help topic using the dept default to default-dept.
-            db_query('UPDATE '.TOPIC_TABLE.' SET dept_id='.db_input($cfg->getDefaultDeptId()).' WHERE dept_id='.db_input($id));
+
+            // Clear any settings using dept to default back to system default
+            db_query('UPDATE '.TOPIC_TABLE.' SET dept_id=0 WHERE dept_id='.db_input($id));
+            db_query('UPDATE '.EMAIL_TABLE.' SET dept_id=0 WHERE dept_id='.db_input($id));
+            db_query('UPDATE '.FILTER_TABLE.' SET dept_id=0 WHERE dept_id='.db_input($id));
+
             //Delete group access
             db_query('DELETE FROM '.GROUP_DEPT_TABLE.' WHERE dept_id='.db_input($id));
         }
diff --git a/include/class.format.php b/include/class.format.php
index 861f8796dd0768948eb14f321e810b9a69b0ae8f..ac25afb2d01e3fdc6496f632dc66b481046e67ce 100644
--- a/include/class.format.php
+++ b/include/class.format.php
@@ -167,7 +167,7 @@ class Format {
         if (isset($attributes['class'])) {
             $classes = explode(' ', $attributes['class']);
             foreach ($classes as $i=>$a)
-                // Unset all unsupported style classes -- anything by M$
+                // Unset all unsupported style classes -- anything but M$
                 if (strpos($a, 'Mso') !== 0)
                     unset($classes[$i]);
             if ($classes)
@@ -177,14 +177,16 @@ class Format {
         }
         // Clean browser-specific style attributes
         if (isset($attributes['style'])) {
-            $styles = explode(';', $attributes['style']);
-            foreach ($styles as $i=>$s) {
+            $styles = preg_split('/;\s*/S', html_entity_decode($attributes['style']));
+            foreach ($styles as $i=>&$s) {
                 @list($prop, $val) = explode(':', $s);
-                if (!$val || !$prop || $prop[0] == '-')
+                if (!$val || !$prop || $prop[0] == '-' || substr($prop, 0, 4) == 'mso-')
                     unset($styles[$i]);
+                if (!strpos($val, ' '))
+                    $s = str_replace('"','', $s);
             }
             if ($styles)
-                $attributes['style'] = implode(';', $styles);
+                $attributes['style'] = Format::htmlencode(implode(';', $styles));
             else
                 unset($attributes['style']);
         }
@@ -246,7 +248,7 @@ class Format {
     }
 
     function htmlencode($var) {
-        $flags = ENT_COMPAT | ENT_QUOTES;
+        $flags = ENT_COMPAT;
         if (phpversion() >= '5.4.0')
             $flags |= ENT_HTML401;
 
diff --git a/include/class.mailer.php b/include/class.mailer.php
index 4adc2c4b27138f9a1df6c6dd1c32087ca5e251a0..50561652f1e11fbc5c9b58b7a831a95244df422b 100644
--- a/include/class.mailer.php
+++ b/include/class.mailer.php
@@ -157,7 +157,7 @@ class Mailer {
         $mid_token = (isset($options['thread']))
             ? $options['thread']->asMessageId($to) : '';
         if (!(isset($options['text']) && $options['text'])) {
-            if ($cfg->stripQuotedReply() && ($tag=$cfg->getReplySeparator())
+            if ($cfg && $cfg->stripQuotedReply() && ($tag=$cfg->getReplySeparator())
                     && (!isset($options['reply-tag']) || $options['reply-tag']))
                 $message = "<div style=\"display:none\"
                     data-mid=\"$mid_token\">$tag<br/><br/></div>$message";
diff --git a/include/staff/ticket-view.inc.php b/include/staff/ticket-view.inc.php
index e87b0181c0ca603b44982c05a630e9103ae5e55d..a423e02c952d3434ee3c6c3528202ff2e2b2fef2 100644
--- a/include/staff/ticket-view.inc.php
+++ b/include/staff/ticket-view.inc.php
@@ -46,7 +46,9 @@ if($ticket->isOverdue())
         </td>
         <td width="50%" class="right_align has_bottom_border">
             <?php
-            if($thisstaff->canBanEmails() || ($dept && $dept->isManager($thisstaff))) { ?>
+            if ($thisstaff->canBanEmails()
+                    || $thisstaff->canEditTickets()
+                    || ($dept && $dept->isManager($thisstaff))) { ?>
             <span class="action-button" data-dropdown="#action-dropdown-more">
                 <span ><i class="icon-cog"></i> More</span>
                 <i class="icon-caret-down"></i>