diff --git a/include/class.ticket.php b/include/class.ticket.php
index 57bfe72fe76c3cca15e7e7813929c390d4b724d5..c8f0d1afd8545b3e4fda99297d569461bbcb4aff 100644
--- a/include/class.ticket.php
+++ b/include/class.ticket.php
@@ -53,9 +53,6 @@ class TicketModel extends VerySimpleModel {
             'dept' => array(
                 'constraint' => array('dept_id' => 'Dept.id'),
             ),
-            'events' => array(
-                'reverse' => 'TicketEvent.ticket',
-            ),
             'sla' => array(
                 'constraint' => array('sla_id' => 'Sla.id'),
                 'null' => true,
@@ -3365,7 +3362,7 @@ implements RestrictedAccess, Threadable {
         $sql='SELECT ticket_id FROM '.TICKET_TABLE.' T1 '
             .' INNER JOIN '.TICKET_STATUS_TABLE.' status
                 ON (status.id=T1.status_id AND status.state="open") '
-            .' LEFT JOIN '.SLA_TABLE.' T2 ON (T1.sla_id=T2.id AND T2.isactive=1) '
+            .' LEFT JOIN '.SLA_TABLE.' T2 ON (T1.sla_id=T2.id AND T2.flags & 1 = 1) '
             .' WHERE isoverdue=0 '
             .' AND ((reopened is NULL AND duedate is NULL AND TIME_TO_SEC(TIMEDIFF(NOW(),T1.created))>=T2.grace_period*3600) '
             .' OR (reopened is NOT NULL AND duedate is NULL AND TIME_TO_SEC(TIMEDIFF(NOW(),reopened))>=T2.grace_period*3600) '
diff --git a/include/staff/settings-agents.inc.php b/include/staff/settings-agents.inc.php
index 874aa2202de8dcc3350368ddd6d63efd95191d1c..bd51beb31f1f1c3e776c1ca8933c09cc216571de 100644
--- a/include/staff/settings-agents.inc.php
+++ b/include/staff/settings-agents.inc.php
@@ -110,7 +110,7 @@ if (!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin() || !$config
     <table class="form_table settings_table" width="940" border="0" cellspacing="0" cellpadding="2">
     <tbody>
 <?php
-$res = db_query('select distinct(`type`), content_id, notes, name, updated from '
+$res = db_query('select distinct(`type`), id, notes, name, updated from '
     .PAGE_TABLE
     .' where isactive=1 group by `type`');
 $contents = array();
diff --git a/include/staff/settings-users.inc.php b/include/staff/settings-users.inc.php
index 382348df225a2680429b409790da0ba7a249d215..62f4161df6ef88142aa8605c47af8261b383ee10 100644
--- a/include/staff/settings-users.inc.php
+++ b/include/staff/settings-users.inc.php
@@ -106,7 +106,7 @@ if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin() || !$config)
     <table class="form_table settings_table" width="940" border="0" cellspacing="0" cellpadding="2">
     <tbody>
 <?php
-$res = db_query('select distinct(`type`), content_id, notes, name, updated from '
+$res = db_query('select distinct(`type`), id, notes, name, updated from '
     .PAGE_TABLE
     .' where isactive=1 group by `type`');
 $contents = array();