diff --git a/flag.inc b/flag.inc
index c7b7a17..a30a767 100644
--- a/flag.inc
+++ b/flag.inc
@@ -1411,6 +1411,28 @@ class flag_comment extends flag_flag  {
     return $comment->cid;
   }
 
+  function is_flagged($content_id, $uid = NULL, $sid = NULL) {
+    $content = $this->fetch_content($content_id);
+    return (bool) $this->get_flagging_record($content_id, $uid, $sid, $content);
+  }
+
+  function get_flagging_record($content_id, $uid = NULL, $sid = NULL, $content = NULL) {
+    $uid = $this->global ? 0 : (!isset($uid) ? $GLOBALS['user']->uid : $uid);
+    $sid = $this->global ? 0 : (!isset($sid) ? flag_get_sid($uid) : $sid);
+
+    // We should only pre-fill the static cache from flag_get_user_flags() once.
+    $prefill_cache = FALSE;
+    if (!isset($this->cached_nids[$content->nid])) {
+      $prefill_cache = TRUE;
+      $this->cached_nids[$content->nid] = $content->nid;
+    }
+
+    // flag_get_user_flags() does caching. For comment flags, pre-fill the cache
+    // with all the comments from this node.
+    $user_flags = flag_get_user_flags($this->content_type, $content_id, $uid, $sid, FALSE, $content, $prefill_cache);
+    return isset($user_flags[$this->name]) ? $user_flags[$this->name] : NULL;
+  }
+
   function uses_hook_link($teaser) {
     return $this->show_on_comment;
   }
diff --git a/flag.module b/flag.module
index 06f98db..ba5e2d3 100644
--- a/flag.module
+++ b/flag.module
@@ -1496,6 +1496,10 @@ function flag_get_content_id($fcid) {
  *   logged in users.
  * @param $reset
  *   Reset the internal cache and execute the SQL query another time.
+ * @param $content
+ *   Optional. The content object that corresponds to $content_id.
+ * @param $prefill
+ *   Optional. Pre-fill the static cache for the given $content.
  *
  * @return $flags
  *   If returning a single item's flags (that is, when $content_id isn't NULL),
@@ -1505,8 +1509,8 @@ function flag_get_content_id($fcid) {
  *   If returning all items' flags, an array of arrays for each flag:
  *   [flag_name] => [content_id] => Object from above.
  */
-function flag_get_user_flags($content_type, $content_id = NULL, $uid = NULL, $sid = NULL, $reset = FALSE) {
-  static $flagged_content;
+function flag_get_user_flags($content_type, $content_id = NULL, $uid = NULL, $sid = NULL, $reset = FALSE, $content = NULL, $prefill = FALSE) {
+  static $flagged_content = array();
 
   if ($reset) {
     $flagged_content = array();
@@ -1519,6 +1523,10 @@ function flag_get_user_flags($content_type, $content_id = NULL, $uid = NULL, $si
   $sid = !isset($sid) ? flag_get_sid($uid) : $sid;
 
   if (isset($content_id)) {
+    if ($prefill && isset($content)) {
+      $flagged_content += _flag_preload_user_flags($content_type, $content_id, $uid, $sid, $content);
+    }
+
     if (!isset($flagged_content[$uid][$sid][$content_type][$content_id])) {
       $flag_names = _flag_get_flag_names();
       $flagged_content[$uid][$sid][$content_type][$content_id] = array();
@@ -1545,6 +1553,49 @@ function flag_get_user_flags($content_type, $content_id = NULL, $uid = NULL, $si
 }
 
 /**
+ * Pre-fills the static cache for flag_get_user_flags().
+ *
+ * @param $content_type
+ *   The type of content that will be retrieved. Usually 'node'.
+ * @param $content_id
+ *   The content ID to check for flagging. If none given, all
+ *   content flagged by this user will be returned.
+ * @param $uid
+ *   The user ID whose flags we're checking. If none given, the
+ *   current user will be used.
+ * @param $sid
+ *   The user SID (provided by Session API) whose flags we're
+ *   checking. If none given, the current user will be used. The SID is 0 for
+ *   logged in users.
+ * @param $content
+ *   The node, comment, user, or other flagged object.
+ *
+ * @return $flags
+ *   An array of the structure
+ *   [flag_name] => (fcid => [fcid], uid => [uid], content_id => [content_id], timestamp => [timestamp], ...)
+ */
+function _flag_preload_user_flags($content_type, $content_id, $uid, $sid, $content) {
+  $cached_flag_content = array();
+
+  if ($content_type == 'comment') {
+    $cids = array();
+    $result = db_query('SELECT c.cid FROM {comments} c WHERE c.nid = %d AND c.status = %d', $content->nid, COMMENT_PUBLISHED);
+    while ($comment = db_fetch_object($result)) {
+      $cached_flag_content[$uid][$sid][$content_type][$comment->cid] = array();
+      $cids[] = $comment->cid;
+    }
+
+    $flag_names = _flag_get_flag_names();
+    $result = db_query("SELECT * FROM {flag_content} WHERE content_type = '%s' AND content_id IN (" . implode(',', $cids) . ") AND (uid = %d OR uid = 0) AND sid = %s", $content_type, $uid, $sid);
+    while ($flag_content = db_fetch_object($result)) {
+      $cached_flag_content[$uid][$sid][$content_type][$flag_content->content_id][$flag_names[$flag_content->fid]] = $flag_content;
+    }
+  }
+
+  return $cached_flag_content;
+}
+
+/**
  * Return a list of users who have flagged a piece of content.
  *
  * @param $content_type
