diff --git a/include/api.tickets.php b/include/api.tickets.php
index c209086a9d57a682462f2d2966c5fd41db69b176..8d20e391cfa1aebb66ad5d154a16f2fd1510d1ef 100644
--- a/include/api.tickets.php
+++ b/include/api.tickets.php
@@ -14,7 +14,8 @@ class TicketApiController extends ApiController {
             "attachments" => array("*" =>
                 array("name", "type", "data", "encoding", "size")
             ),
-            "message", "ip", "priorityId"
+            "message", "ip", "priorityId",
+            "system_emails", "thread_entry_recipients"
         );
         # Fetch dynamic form field names for the given help topic and add
         # the names to the supported request structure
diff --git a/include/class.config.php b/include/class.config.php
index 004a1e8e8a44d2be9fdcc1cde54acd0a03300d73..d7518a91f947786ba15ba69a345f5ee2018a7281 100644
--- a/include/class.config.php
+++ b/include/class.config.php
@@ -30,10 +30,6 @@ class Config {
     # new settings and the corresponding default values.
     var $defaults = array();                # List of default values
 
-
-    # Items
-    var $items = null;
-
     function __construct($section=null, $defaults=array()) {
         if ($section)
             $this->section = $section;
@@ -133,18 +129,11 @@ class Config {
 
     function destroy() {
         unset($this->session);
-        if ($this->items)
-            $this->items->delete();
-
-        return true;
+        return $this->items()->delete() > 0;
     }
 
     function items() {
-
-        if (!isset($this->items))
-            $this->items = ConfigItem::items($this->section, $this->section_column);
-
-        return $this->items;
+        return ConfigItem::items($this->section, $this->section_column);
     }
 }
 
diff --git a/include/class.export.php b/include/class.export.php
index 85f021328a2d4a0ac7dccc9aa96f3b6738e3d8e1..b30ceb858203be3b9fb38ee1b8c245f8b1756a9d 100644
--- a/include/class.export.php
+++ b/include/class.export.php
@@ -76,7 +76,7 @@ class Export {
                     ->aggregate(array('count' => SqlAggregate::COUNT('entries__attachments__id'))),
                 'reopen_count' => TicketThread::objects()
                     ->filter(array('ticket__ticket_id' => new SqlField('ticket_id', 1)))
-                    ->filter(array('events__annulled' => 0, 'events__state' => 'reopened'))
+                    ->filter(array('events__annulled' => 0, 'events__event_id' => Event::getIdByName('reopened')))
                     ->aggregate(array('count' => SqlAggregate::COUNT('events__id'))),
                 'thread_count' => TicketThread::objects()
                     ->filter(array('ticket__ticket_id' => new SqlField('ticket_id', 1)))
diff --git a/include/class.queue.php b/include/class.queue.php
index e3212c502929ddbaa93785eca9f72a9f46007617..6397d34d7fa6d3e28e4635da3264ef4676ed704c 100644
--- a/include/class.queue.php
+++ b/include/class.queue.php
@@ -1637,7 +1637,7 @@ extends QueueColumnAnnotation {
         return $query->annotate(array(
             $name => TicketThread::objects()
             ->filter(array('ticket__ticket_id' => new SqlField('ticket_id', 1)))
-            ->filter(array('events__annulled' => 0, 'events__state' => 'reopened'))
+            ->filter(array('events__annulled' => 0, 'events__event_id' => Event::getIdByName('reopened')))
             ->aggregate(array('count' => SqlAggregate::COUNT('events__id')))
         ));
     }
diff --git a/include/class.user.php b/include/class.user.php
index f2d3e2fd0e8c9e4cff961248ce1abe51a062a646..8d6bd1a7bb76f9197d1b6b1844271aec337121d2 100644
--- a/include/class.user.php
+++ b/include/class.user.php
@@ -635,12 +635,11 @@ implements TemplateVariable, Searchable {
     }
 
     function deleteAllTickets() {
-        $event_id = Event::getIdByName('deleted');
-        $deleted = TicketStatus::lookup(array('event_id' => $event_id));
+        $status_id = TicketStatus::lookup(array('state' => 'deleted'));
         foreach($this->tickets as $ticket) {
             if (!$T = Ticket::lookup($ticket->getId()))
                 continue;
-            if (!$T->setStatus($deleted))
+            if (!$T->setStatus($status_id))
                 return false;
         }
         $this->tickets->reset();
diff --git a/include/cli/modules/upgrade.php b/include/cli/modules/upgrade.php
index 297d6d56f84d36dcdc1ad23c42410a09d483b165..383c47f5c66226ac32f6ae102f502e27fcbe1645 100644
--- a/include/cli/modules/upgrade.php
+++ b/include/cli/modules/upgrade.php
@@ -51,12 +51,12 @@ class CliUpgrader extends Module {
         $cfg = $ost->getConfig();
 
         while (true) {
-            if ($upgrader->getTask()) {
-                // If there's anythin in the model cache (like a Staff
-                // object or something), ensure that changes to the database
-                // model won't cause crashes
-                ModelInstanceManager::flushCache();
+            // If there's anythin in the model cache (like a Staff
+            // object or something), ensure that changes to the database
+            // model won't cause crashes
+            ModelInstanceManager::flushCache();
 
+            if ($upgrader->getTask()) {
                 // More pending tasks - doTasks returns the number of pending tasks
                 $this->stdout->write("... {$upgrader->getNextAction()}\n");
                 $upgrader->doTask();