diff --git a/nodeforum.module b/nodeforum.module
index 9467d7b..7230232 100644
--- a/nodeforum.module
+++ b/nodeforum.module
@@ -236,7 +236,7 @@ function nodeforum_admin_settings() {
     '#options' => $forder,
     '#description' => t('The default display order for topics.'),
   );
-  
+
 
   $form['nodeforum_restricted'] = taxonomy_form(
     variable_get('nodeforum_nav_vocabulary', 0),
@@ -768,6 +768,12 @@ function _nodeforum_format($topic) {
  *   Array of object containing the forum information.
  */
 function nodeforum_get_forums($tid = 0) {
+  // See if we can short circuit the query and load a cached version.
+  $cid = 'nodeforum:forums:'. $tid;
+  $cache = cache_get($cid, 'cache');
+  if ($cache && isset($cache->data)) {
+    return $cache->data;
+  }
 
   $forums = array();
   $_nodeforums = taxonomy_get_tree(variable_get('nodeforum_nav_vocabulary', ''), $tid);
@@ -778,7 +784,7 @@ function nodeforum_get_forums($tid = 0) {
 
     $sql = "SELECT r.tid, COUNT(n.nid) AS topic_count, SUM(l.comment_count) AS comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {term_node} r ON n.nid = r.nid WHERE n.status = 1 AND n.type = 'forum' GROUP BY r.tid";
     $sql = db_rewrite_sql($sql);
-    $_counts = db_query($sql, $forum->tid);
+    $_counts = db_query($sql);
     while ($count = db_fetch_object($_counts)) {
       $counts[$count->tid] = $count;
     }
@@ -814,6 +820,9 @@ function nodeforum_get_forums($tid = 0) {
     $forums[$forum->tid] = $forum;
   }
 
+  // Store a copy to avoid the query.
+  cache_set($cid, $forums, 'cache', time() + 60);
+
   return $forums;
 }
 
@@ -1045,7 +1054,7 @@ function theme_nodeforum_list($forums, $parents, $tid) {
         $forum_name = tt("taxonomy:term:{$forum->tid}:name", $forum->name);
         $forum_description = tt("taxonomy:term:{$forum->tid}:description", $forum->description);
       }
-      if ($forum->container) {
+      if (!empty($forum->container)) {
         $description  = '<div style="margin-left: '. ($forum->depth * 30) ."px;\">\n";
         $description .= ' <div class="name">'. l($forum_name, "forum/$forum->tid") ."</div>\n";
 
