diff --git a/smartqueue.module b/smartqueue.module
index be34f2e..16653ba 100644
--- a/smartqueue.module
+++ b/smartqueue.module
@@ -220,17 +220,19 @@ function smartqueue_build_string($arrays) {
  * @param $reference Subqueue reference string (tids imploded with '-').
  */
 function smartqueue_taxonomy_nodequeue_subqueue_title($queue, $reference) {
+  $titles = array();
   $tids = explode('-', $reference);
   foreach ($tids as $tid) {
     // $tid can be 0, specifically meaning this term is unset.
-    if ($tid) {
-      $titles[$tid] = taxonomy_term_load($tid)->name;
+    if ($tid and $term = taxonomy_term_load($tid)) {
+      $titles[$tid] = $term->name;
     }
   }
 
   // Create name using names of all term names. This could be
   // done better, but is OK for now.
-  return implode('-', $titles);
+  $title = implode('-', $titles);
+  return $title ? $title : $reference;
 }
 
 /**
