diff --git a/include/class.team.php b/include/class.team.php
index 116fae3892c3d76d4008414decf48b60460b86fe..48d7b5655ee2066a73811cf76bd3663476b97a0c 100644
--- a/include/class.team.php
+++ b/include/class.team.php
@@ -142,15 +142,22 @@ class Team {
         if(!$thisstaff || !($id=$this->getId()))
             return false;
 
-        # Remove members of this team
-        db_query('DELETE FROM '.TEAM_MEMBER_TABLE
-               .' WHERE team_id='.db_input($id));
-
         # Remove the team
         $res = db_query(
             'DELETE FROM '.TEAM_TABLE.' WHERE team_id='.db_input($id)
           .' LIMIT 1');
-        return (db_affected_rows($res) == 1);
+        if (db_affected_rows($res) != 1)
+            return false;
+
+        # Remove members of this team
+        db_query('DELETE FROM '.TEAM_MEMBER_TABLE
+               .' WHERE team_id='.db_input($id));
+
+        # Reset ticket ownership for tickets owned by this team
+        db_query('UPDATE '.TICKET_TABLE.' SET team_id=0 WHERE team_id='
+            .db_input($id));
+
+        return true;
     }
 
     /* ----------- Static function ------------------*/