diff --git a/include/class.orm.php b/include/class.orm.php
index 58aeaede544bc124cc7e1cf6a905d6baad12871c..8ed70f452dea4c4fb1525f951e93c815a54c92e2 100644
--- a/include/class.orm.php
+++ b/include/class.orm.php
@@ -535,14 +535,20 @@ class SqlFunction {
         $this->args = array_slice(func_get_args(), 1);
     }
 
+    function input($what, $compiler, $model) {
+        if ($what instanceof SqlFunction)
+            $A = $what->toSql($compiler, $model);
+        elseif ($what instanceof Q)
+            $A = $compiler->compileQ($what, $model);
+        else
+            $A = $compiler->input($what);
+        return $A;
+    }
+
     function toSql($compiler, $model=false, $alias=false) {
         $args = array();
         foreach ($this->args as $A) {
-            if ($A instanceof SqlFunction)
-                $A = $A->toSql($compiler, $model);
-            else
-                $A = $compiler->input($A);
-            $args[] = $A;
+            $args[] = $this->input($A, $compiler, $model);
         }
         return sprintf('%s(%s)%s', $this->func, implode(',', $args),
             $alias && $this->alias ? ' AS '.$compiler->quote($this->alias) : '');
@@ -562,6 +568,40 @@ class SqlFunction {
     }
 }
 
+class SqlCase extends SqlFunction {
+    var $cases = array();
+    var $else = false;
+
+    static function N() {
+        return new static('CASE');
+    }
+
+    function when($expr, $result) {
+        $this->cases[] = array($expr, $result);
+        return $this;
+    }
+    function otherwise($result) {
+        $this->else = $result;
+        return $this;
+    }
+
+    function toSql($compiler, $model=false, $alias=false) {
+        $cases = array();
+        foreach ($this->cases as $A) {
+            list($expr, $result) = $A;
+            $expr = $this->input($expr, $compiler, $model);
+            $result = $this->input($result, $compiler, $model);
+            $cases[] = "WHEN {$expr} THEN {$result}";
+        }
+        if ($this->else) {
+            $else = $this->input($this->else, $compiler, $model);
+            $cases[] = "ELSE {$else}";
+        }
+        return sprintf('CASE %s END%s', implode(' ', $cases),
+            $alias && $this->alias ? ' AS '.$compiler->quote($this->alias) : '');
+    }
+}
+
 class SqlExpr extends SqlFunction {
     function __construct($args) {
         $this->args = $args;
@@ -687,7 +727,12 @@ class SqlAggregate extends SqlFunction {
 
         // For DISTINCT, require a field specification — not a relationship
         // specification.
-        list($field, $rmodel) = $compiler->getField($this->expr, $model, $options);
+        $E = $this->expr;
+        if ($E instanceof SqlFunction) {
+            $field = $E->toSql($compiler, $model, $alias);
+        }
+        else {
+        list($field, $rmodel) = $compiler->getField($E, $model, $options);
         if ($this->distinct) {
             $pk = false;
             foreach ($rmodel::$meta['pk'] as $f) {
@@ -708,6 +753,7 @@ class SqlAggregate extends SqlFunction {
                 }
             }
         }
+        }
 
         return sprintf('%s(%s%s)%s', $this->func,
             $this->distinct ? 'DISTINCT ' : '', $field,
diff --git a/include/staff/templates/thread-entry-edit.tmpl.php b/include/staff/templates/thread-entry-edit.tmpl.php
index 0f1533d70b59f1bd6aa37edebb89ec861b167fba..3283df7701fd6b1b95bfc9a11b67f1b956be904b 100644
--- a/include/staff/templates/thread-entry-edit.tmpl.php
+++ b/include/staff/templates/thread-entry-edit.tmpl.php
@@ -34,7 +34,7 @@
 ?></textarea>
 
 <?php if ($this->entry->type == 'R') { ?>
-<div style="margin:10px 0;"><?php echo __('Signature'); ?>:
+<div style="margin:10px 0;"><strong><?php echo __('Signature'); ?>:</strong>
     <label><input type="radio" name="signature" value="none" checked="checked"> <?php echo __('None');?></label>
     <?php
     if ($thisstaff->getSignature()) {?>
diff --git a/include/staff/templates/thread-entry-view.tmpl.php b/include/staff/templates/thread-entry-view.tmpl.php
index 35c3489c4a871746f077940ebf92099d562ce645..2b76d851f3611a89e452492117593ebf17203b37 100644
--- a/include/staff/templates/thread-entry-view.tmpl.php
+++ b/include/staff/templates/thread-entry-view.tmpl.php
@@ -9,14 +9,15 @@ $E = $entry;
 do { ?>
 <dt>
     <a href="#"><i class="icon-copy"></i>
-    <strong><?php echo Format::htmlchars($E->title); ?></strong>
+    <strong><?php if ($E->title)
+        echo Format::htmlchars($E->title).' — '; ?></strong>
     <em><?php if (strpos($E->updated, '0000-') === false)
         echo sprintf(__('Edited on %s'), Format::datetime($E->updated));
     else
         echo __('Original'); ?></em>
     </a>
 </dt>
-<dd class="hidden">
+<dd class="hidden" style="background-color:transparent">
     <div class="thread-body" style="background-color:transparent">
         <?php echo $E->getBody()->toHtml(); ?>
     </div>
diff --git a/include/staff/tickets.inc.php b/include/staff/tickets.inc.php
index bdab6cd1db6cdbe7d3d7aad223c878c87504b520..9f0fa3db063861dab137ed1a7637a8e6b9d9e2e4 100644
--- a/include/staff/tickets.inc.php
+++ b/include/staff/tickets.inc.php
@@ -150,12 +150,14 @@ if (!$view_all_tickets) {
     if ($teams = array_filter($thisstaff->getTeams()))
         $assigned->add(array('team_id__in' => $teams));
 
-    $visibility = array(
-        new Q(array('status__state'=>'open', $assigned))
-    );
+    if ($status)
+        $visibility = Q::any(array($assigned));
+    else
+        $visibility = Q::any(array('status__state'=>'open', $assigned));
+
     // -- Routed to a department of mine
     if (!$thisstaff->showAssignedOnly() && ($depts=$thisstaff->getDepts()))
-        $visibility[] = new Q(array('dept_id__in' => $depts));
+        $visibility->add(array('dept_id__in' => $depts));
 
     $tickets->filter(Q::any($visibility));
 }
@@ -268,7 +270,12 @@ $tickets->values('lock__staff_id', 'staff_id', 'isoverdue', 'team_id', 'ticket_i
 $tickets->annotate(array(
     'collab_count' => SqlAggregate::COUNT('thread__collaborators'),
     'attachment_count' => SqlAggregate::COUNT('thread__entries__attachments'),
-    'thread_count' => SqlAggregate::COUNT('thread__entries'),
+    'thread_count' => SqlAggregate::COUNT(SqlCase::N()
+        ->when(
+            new Q(array('thread__entries__flags__hasbit'=>ThreadEntry::FLAG_HIDDEN)),
+            null)
+        ->otherwise(1)
+    ),
 ));
 
 // Save the query to the session for exporting