diff --git a/FeedsCommentProcessor.inc b/FeedsCommentProcessor.inc
index 1b2d178..d4b0448 100644
--- a/FeedsCommentProcessor.inc
+++ b/FeedsCommentProcessor.inc
@@ -5,14 +5,6 @@
  * Class definition of FeedsCommentProcessor.
  */
 
-// Create or delete FEEDS_COMMENT_BATCH_SIZE at a time.
-define('FEEDS_COMMENT_BATCH_SIZE', 50);
-
-// Deprecated. Use FEEDS_SKIPE_EXISTING, FEEDS_REPLACE_EXISTNG,
-// FEEDS_UPDATE_EXISTING instead.
-define('FEEDS_COMMENT_SKIP_EXISTING', 0);
-define('FEEDS_COMMENT_REPLACE_EXISTING', 1);
-define('FEEDS_COMMENT_UPDATE_EXISTING', 2);
 
 /**
  * Creates comments from feed items.
@@ -20,96 +12,58 @@ define('FEEDS_COMMENT_UPDATE_EXISTING', 2);
 class FeedsCommentProcessor extends FeedsProcessor {
 
   /**
-   * Implementation of FeedsProcessor::process().
+   * Define entity type.
    */
-  public function process(FeedsImportBatch $batch, FeedsSource $source) {
-
-    // Keep track of processed items in this pass.
-    $processed = 0;
-    if (!$batch->getTotal(FEEDS_PROCESSING)) {
-      $batch->setTotal(FEEDS_PROCESSING, $batch->getItemCount());
-    }
-
-    while ($item = $batch->shiftItem()) {
-
-      // Create/update if item does not exist or update existing is enabled.
-      if (!($cid = $this->existingItemId($batch, $source)) || ($this->config['update_existing'] != FEEDS_SKIP_EXISTING)) {
-        // Only proceed if item has actually changed.
-        $hash = $this->hash($item);
-        if (!empty($cid) && $hash == $this->getHash($cid)) {
-          continue;
-        }
-
-        $comment = $this->buildComment($cid, $source->feed_nid);
-        $comment->feeds_comment_item->hash = $hash;
-
-        // Map and save comment. If errors occur don't stop but report them.
-        try {
-          $this->map($batch, $comment);
-          if (empty($comment->nid)) {
-            throw new Exception("Unable create comment with empty NID");
-          }
-          _feeds_comment_save((array)$comment);
-          if (!empty($cid)) {
-            $batch->updated++;
-          }
-          else {
-            $batch->created++;
-          }
-        }
-        catch (Exception $e) {
-          drupal_set_message($e->getMessage(), 'warning');
-          watchdog('feeds', $e->getMessage(), array(), WATCHDOG_WARNING);
-        }
-      }
-
-      $processed++;
-      if ($processed >= variable_get('feeds_comment_batch_size', FEEDS_COMMENT_BATCH_SIZE)) {
-        $batch->setProgress(FEEDS_PROCESSING, $batch->created + $batch->updated);
-        return;
-      }
-    }
-
-    // Set messages.
-    if ($batch->created) {
-      drupal_set_message(format_plural($batch->created, 'Created @number comment', 'Created @number comments.', array('@number' => $batch->created,)));
-    }
-    elseif ($batch->updated) {
-      drupal_set_message(format_plural($batch->updated, 'Updated @number comment.', 'Updated @number comments.', array('@number' => $batch->updated,)));
-    }
-    else {
-      drupal_set_message(t('There are no new comments.'));
-    }
-    $batch->setProgress(FEEDS_PROCESSING, FEEDS_BATCH_COMPLETE);
+  public function entityType() {
+    return 'comment';
   }
 
   /**
-   * Implementation of FeedsProcessor::clear().
+   * Implements parent::entityInfo().
    */
-  public function clear(FeedsBatch $batch, FeedsSource $source) {
-    if (!$batch->getTotal(FEEDS_CLEARING)) {
-      $total = db_result(db_query("SELECT COUNT(cid) FROM {feeds_comment_item} WHERE id = '%s' AND feed_nid = %d", $source->id, $source->feed_nid));
-      $batch->setTotal(FEEDS_CLEARING, $total);
-    }
-    $result = db_query_range("SELECT cid FROM {feeds_comment_item} WHERE id = '%s' AND feed_nid = %d", $source->id, $source->feed_nid, 0, variable_get('feeds_comment_batch_size', FEEDS_COMMENT_BATCH_SIZE));
-    while ($comment = db_fetch_object($result)) {
-      _feeds_comment_delete($comment->cid);
-      $batch->deleted++;
-    }
-    if (db_result(db_query_range("SELECT cid FROM {feeds_comment_item} WHERE id = '%s' AND feed_nid = %d", $source->id, $source->feed_nid, 0, 1))) {
-      $batch->setProgress(FEEDS_CLEARING, $batch->deleted);
-      return;
-    }
-
-    // Set message.
-    drupal_get_messages('status');
-    if ($batch->deleted) {
-      drupal_set_message(format_plural($batch->deleted, 'Deleted @number comment.', 'Deleted @number comments.', array('@number' => $batch->deleted)));
-    }
-    else {
-      drupal_set_message(t('There is no content to be deleted.'));
-    }
-    $batch->setProgress(FEEDS_CLEARING, FEEDS_BATCH_COMPLETE);
+  protected function entityInfo() {
+    $info = parent::entityInfo();
+    $info['label plural'] = t('Comments');
+    return $info;
+  }
+  /**
+   * Creates a new user comment in memory and returns it.
+   */
+  protected function newEntity(FeedsSource $source) {
+    $comment = new stdClass();
+    $comment->cid = NULL;
+    $comment->pid = NULL;
+    $comment->name = '';
+    $comment->mail = '';
+    $comment->homepage = '';
+    $comment->subject = '';
+    $comment->comment = '';
+    $comment->changed = REQUEST_TIME;
+    $comment->created = REQUEST_TIME;
+    $comment->language = LANGUAGE_NONE;
+    $comment->node_type = 'comment_node_' . $this->config['content_type'];
+    $comment->status = $this->config['status'];
+    return $comment;
+  }
+  
+ /**
+   * Loads an existing comment.
+   */
+  protected function entityLoad(FeedsSource $source, $cid) {
+    return comment_load($cid);
+  }
+  /**
+   * Save a comment.
+   */
+  public function entitySave($comment) {
+    comment_save($comment);
+  }
+  
+  /**
+   * Delete multiple comments
+   */
+  protected function entityDeleteMultiple($cids) {
+    comment_delete_multiple($cids);
   }
 
   /**
@@ -122,15 +76,26 @@ class FeedsCommentProcessor extends FeedsProcessor {
     if ($time == FEEDS_EXPIRE_NEVER) {
       return;
     }
-    $result = db_query_range("SELECT c.cid FROM {comments} c INNER JOIN {feeds_comment_item} fci ON c.cid = fni.nid WHERE fci.id = '%s' AND c.timestamp < %d", $this->id, FEEDS_REQUEST_TIME - $time, 0, variable_get('feeds_comment_batch_size', FEEDS_COMMENT_BATCH_SIZE));
-    while ($comment = db_fetch_object($result)) {
-      _feeds_comment_delete($comment->nid);
+    $count = $this->getLimit();
+    $comments = db_query_range("SELECT c.cid FROM {comment} c JOIN {feeds_item} fi ON fi.entity_type = 'comment' AND c.cid = fi.entity_id WHERE fi.id = :id AND c.created < :created", 0, $count, array(':id' => $this->id, ':created' => REQUEST_TIME - $time));
+    $cids = array();
+    foreach ($comments as $comment) {
+      $cids[$comment->cid] = $comment->cid;
     }
-    if (db_result(db_query_range("SELECT c.cid FROM {comment} c INNER JOIN {feeds_comment_item} fci ON c.cid = fci.nid WHERE fci.id = '%s' AND c.timestamp < %d", $this->id, FEEDS_REQUEST_TIME - $time, 0, 1))) {
+    $this->entityDeleteMultiple($cids);
+    if (db_query_range("SELECT 1 FROM {comment} c JOIN {feeds_item} fi ON fi.entity_type = 'comment' AND c.cid = fi.entity_id WHERE fi.id = :id AND c.created < :created", 0, 1, array(':id' => $this->id, ':created' => REQUEST_TIME - $time))->fetchField()) {
       return FEEDS_BATCH_ACTIVE;
     }
+//    $result = db_query_range("SELECT c.cid FROM {comments} c INNER JOIN {feeds_comment_item} fci ON c.cid = fni.nid WHERE fci.id = :fci.id AND c.timestamp < :c.timestamp", array(':fci.id' => $this->id, ':c.timestamp' => FEEDS_REQUEST_TIME - $time));
+//    while ($comment = db_fetch_object($result)) {
+//      _feeds_comment_delete($comment->nid);
+//    }
+//    if (db_query_range("SELECT c.cid FROM {comment} c INNER JOIN {feeds_comment_item} fci ON c.cid = fci.nid WHERE fci.id = :fci.id AND c.timestamp < :c.timestamp", array(':fci.id' => $this->id, ':c.timestamp' => FEEDS_REQUEST_TIME - $time))->fetchField()) {
+//      return FEEDS_BATCH_ACTIVE;
+//    }
     return FEEDS_BATCH_COMPLETE;
   }
+  
 
   /**
    * Return expiry time.
@@ -138,13 +103,16 @@ class FeedsCommentProcessor extends FeedsProcessor {
   public function expiryTime() {
     return $this->config['expire'];
   }
+ 
 
   /**
    * Override parent::configDefaults().
    */
   public function configDefaults() {
+     $types = node_type_get_names();
+    $type = isset($types['article']) ? 'article' : key($types);
     return array(
-      'input_format' => FILTER_FORMAT_DEFAULT,
+      'content_type' => $type,
       'update_existing' => FEEDS_SKIP_EXISTING,
       'expire' => FEEDS_EXPIRE_NEVER,
       'mappings' => array(),
@@ -156,20 +124,18 @@ class FeedsCommentProcessor extends FeedsProcessor {
    * Override parent::configForm().
    */
   public function configForm(&$form_state) {
-    $form = array();
-    $format_options = array(FILTER_FORMAT_DEFAULT => t('Default format'));
-    $formats = filter_formats();
-      foreach ($formats as $format) {
-        $format_options[$format->format] = $format->name;
-      }
-    $form['input_format'] = array(
+    $form = parent::configForm($form_state);
+    $types = node_type_get_names();
+    array_walk($types, 'check_plain');
+    $form = parent::configForm($form_state);
+    $form['content_type'] = array(
       '#type' => 'select',
-      '#title' => t('Input format'),
-      '#description' => t('Select the input format for the comments to be created.'),
-      '#options' => $format_options,
-      '#default_value' => $this->config['input_format'],
+      '#title' => t('Content type'),
+      '#description' => t('Select the content type to which the comments apply.'),
+      '#options' => $types,
+      '#default_value' => $this->config['content_type'],
     );
-    $author = user_load(array('uid' => $this->config['author']));
+    $author = user_load($this->config['author']);
     $form['author'] = array(
       '#type' => 'textfield',
       '#title' => t('Author'),
@@ -185,16 +151,10 @@ class FeedsCommentProcessor extends FeedsProcessor {
       '#description' => t('Select after how much time comments should be deleted. The comment\'s published date will be used for determining the comment\'s age, see Mapping settings.'),
       '#default_value' => $this->config['expire'],
     );
-    $form['update_existing'] = array(
-      '#type' => 'radios',
-      '#title' => t('Update existing comments'),
-      '#description' => t('Select how existing comments should be updated. Existing comments will be determined using mappings that are a "unique target".'),
-      '#options' => array(
+    $form['update_existing']['#options'] = array(
         FEEDS_SKIP_EXISTING => 'Do not update existing comments',
         FEEDS_REPLACE_EXISTING => 'Replace existing comments',
         FEEDS_UPDATE_EXISTING => 'Update existing comments (slower than replacing them)',
-      ),
-      '#default_value' => $this->config['update_existing'],
     );
     return $form;
   }
@@ -203,35 +163,58 @@ class FeedsCommentProcessor extends FeedsProcessor {
    * Override parent::configFormValidate().
    */
   public function configFormValidate(&$values) {
-    if ($author = user_load(array('name' => $values['author']))) {
+     if ($author = user_load_by_name($values['author'])) {
       $values['author'] = $author->uid;
     }
     else {
       $values['author'] = 0;
     }
   }
-
   /**
-   * Override setTargetElement to operate on a target item that is a comment.
+   * Reschedule if expiry time changes.
    */
-  public function setTargetElement($target_comment, $target_element, $value) {
-    if (in_array($target_element, array('guid'))) {
-      $target_comment->feeds_comment_item->$target_element = $value;
+  public function configFormSubmit(&$values) {
+    if ($this->config['expire'] != $values['expire']) {
+      feeds_reschedule($this->id);
     }
-    elseif (array_key_exists($target_element, $this->getMappingTargets())) {
-      $target_comment->$target_element = $value;
+    parent::configFormSubmit($values);
+  }
+  /**
+   * Override setTargetElement to operate on a target item that is a node.
+   */
+  public function setTargetElement_OLD(FeedsSource $source, $target_comment, $target_element, $value) {
+    switch ($target_element) {
+      case 'created':
+        $target_comment->created = feeds_to_unixtime($value, REQUEST_TIME);
+        break;
+      default:
+        parent::setTargetElement($source, $target_comment, $target_element, $value);
+        break;
     }
   }
+//  /**
+//   * Override setTargetElement to operate on a target item that is a comment.
+//   */
+//  public function setTargetElement($target_comment, $target_element, $value) {
+//    if (in_array($target_element, array('guid'))) {
+//      $target_comment->feeds_comment_item->$target_element = $value;
+//    }
+//    elseif (array_key_exists($target_element, $this->getMappingTargets())) {
+//      $target_comment->$target_element = $value;
+//    }
+//  }
 
   /**
    * Return available mapping targets.
    */
   public function getMappingTargets() {
-    $targets = array(
+    $node_type = node_type_get_type($this->config['content_type']);
+    $targets = parent::getMappingTargets();
+    $targets += array(
       'pid' => array(
         'name' => t('Parent ID'),
         'description' => t('The cid to which this comment is a reply.'),
-       ),
+      ),
       'nid' => array(
         'name' => t('Node ID'),
         'description' => t('The nid to which this comment is a reply.'),
@@ -240,22 +223,26 @@ class FeedsCommentProcessor extends FeedsProcessor {
         'name' => t('User ID'),
         'description' => t('The Drupal user ID of the comment author.'),
       ),
+      'thread' => array(
+        'name' => t('Thread ID'),
+        'description' => t('The vancode representation of the comment\'s place in a thread.'),
+      ),
       'subject' => array(
         'name' => t('Title'),
-        'description' => t('The title of the comment.'),
-       ),
-      'comment' => array(
-        'name' => t('Comment'),
-        'description' => t('The comment body.'),
+        'description' => t('The title / subject of the comment.'),
       ),
       'hostname' => array(
         'name' => t('Hostname'),
         'description' => t('The author\'s host name.'),
-       ),
-      'timestamp' => array(
+      ),
+      'created' => array(
         'name' => t('Published date'),
         'description' => t('The UNIX time when a comment has been saved.'),
       ),
+      'changed' => array(
+        'name' => t('Changed date'),
+        'description' => t('The UNIX time when a comment has been saved.'),
+      ),
       'status' => array(
         'name' => t('Published status'),
         'description' => t('The published status of a comment. (0 = Published, 1 = Not Published)'),
@@ -277,26 +264,42 @@ class FeedsCommentProcessor extends FeedsProcessor {
         'description' => t('The external GUID of the comment. E. g. the feed item GUID in the case of a syndication feed. May be unique.'),
         'optional_unique' => TRUE,
       ),
+      'parent_guid' => array(
+        'name' => t('Parent GUID'),
+        'description' => t('The external GUID of the  parent comment.'),
+      ),
+      'content_guid' => array(
+        'name' => t('Content GUID'),
+        'description' => t('The external GUID of the node that the comment is being placed on.'),
+      ),
     );
 
     // Let other modules expose mapping targets.
     self::loadMappers();
-    drupal_alter('feeds_comment_processor_targets', $targets);
-
+    // Load fields associated with the comment entity type and bundled with a particular node type
+    feeds_alter('feeds_processor_targets', $targets, 'comment', 'comment_node_' . $this->config['content_type']);
     return $targets;
   }
 
   /**
-   * Get cid of an existing feed item comment if available.
+   * Get nid of an existing feed item node if available.
    */
-  protected function existingItemId($source_item, FeedsSource $source) {
+  protected function existingEntityId_OLD(FeedsSource $source, FeedsParserResult $result) {
+    if ($cid = parent::existingEntityId($source, $result)) {
+      return $cid;
+    }
 
     // Iterate through all unique targets and test whether they do already
     // exist in the database.
-    foreach ($this->uniqueTargets($source_item) as $target => $value) {
+    foreach ($this->uniqueTargets($source, $result) as $target => $value) {
       switch ($target) {
-        case 'guid':
-          $cid = db_result(db_query("SELECT cid FROM {feeds_comment_item} WHERE feed_nid = %d AND id = '%s' AND guid = '%s'", $source->feed_nid, $source->id, $value));
+        case 'cid':
+          $cid = db_query("SELECT cid FROM {comment} WHERE cid = :cid", array(':cid' => $value))->fetchField();
+          break;
+        case 'feeds_source':
+          if ($id = feeds_get_importer_id($this->config['content_type'])) {
+            $cid = db_query("SELECT fs.feed_nid FROM {comment} c JOIN {feeds_source} fs ON c.cid = fs.feed_nid WHERE fs.id = :id AND fs.source = :source", array(':id' => $id, ':source' => $value))->fetchField();
+          }
           break;
       }
       if ($cid) {
@@ -306,191 +309,4 @@ class FeedsCommentProcessor extends FeedsProcessor {
     }
     return 0;
   }
-
-  /**
-   * Creates a new comment object in memory and returns it.
-   */
-  protected function buildComment($cid, $feed_nid) {
-    $comment = new stdClass();
-    if (empty($cid)) {
-      $comment->created = FEEDS_REQUEST_TIME;
-      $populate = TRUE;
-    }
-    else {
-      if ($this->config['update_existing'] == FEEDS_UPDATE_EXISTING) {
-        $comment = _comment_load($cid);
-      }
-      else {
-        $comment->cid = $cid;
-        $populate = TRUE;
-      }
-    }
-    if ($populate) {
-      $comment->timestamp = FEEDS_REQUEST_TIME;
-      $comment->format = $this->config['input_format'];
-      $comment->feeds_comment_item = new stdClass();
-      $comment->feeds_comment_item->id = $this->id;
-      $comment->feeds_comment_item->imported = FEEDS_REQUEST_TIME;
-      $comment->feeds_comment_item->feed_nid = $feed_nid;
-      $comment->feeds_comment_item->guid = '';
-      $comment->uid = $this->config['author'];
-      $account = user_load(array('uid' => $comment->uid));
-      $comment->name = $account->name;
-      $comment->mail = $account->mail;
-      $comment->status = 0;
-      $comment->pid = 0;
-      $comment->hostname = '127.0.0.1';
-
-    }
-
-    return $comment;
-  }
-
-  /**
-   * Create MD5 hash of item and mappings array.
-   *
-   * Include mappings as a change in mappings may have an affect on the item
-   * produced.
-   *
-   * @return Always returns a hash, even with empty, NULL, FALSE:
-   *  Empty arrays return 40cd750bba9870f18aada2478b24840a
-   *  Empty/NULL/FALSE strings return d41d8cd98f00b204e9800998ecf8427e
-   */
-  protected function hash($item) {
-    static $serialized_mappings;
-    if (!$serialized_mappings) {
-      $serialized_mappings = serialize($this->config['mappings']);
-    }
-    return hash('md5', serialize($item) . $serialized_mappings);
-  }
-
-  /**
-   * Retrieve MD5 hash of $cid from DB.
-   * @return Empty string if no item is found, hash otherwise.
-   */
-  protected function getHash($cid) {
-    $hash = db_result(db_query("SELECT hash FROM {feeds_comment_item} WHERE cid = %d", $cid));
-    if ($hash) {
-      // Return with the hash.
-      return $hash;
-    }
-    return '';
-  }
-}
-
-function _feeds_comment_delete($cid) {
-  module_load_include('inc', 'comment', 'comment.admin');
-  $to_delete = _comment_load($cid);
-  // Delete comment and its replies.
-  _comment_delete_thread($to_delete);
-  _comment_update_node_statistics($to_delete->nid);
-}
-
-/**
- * This function is copied and pasted from comment_save in Drupal core and then
- * modified to get rid of access restrictions and to prevent extraneous dsms.
- *
- * @param $edit
- *   A comment array.
- *
- * @return
- *   If the comment is successfully saved the comment ID is returned. If the comment
- *   is not saved, FALSE is returned.
- */
-function _feeds_comment_save($edit) {
-  global $user;
-
-  $edit += array(
-    'mail' => '',
-    'homepage' => '',
-    'name' => '',
-    'status' => user_access('post comments without approval') ? COMMENT_PUBLISHED : COMMENT_NOT_PUBLISHED,
-  );
-  if ($edit['cid']) {
-    // Update the comment in the database.
-    db_query("UPDATE {comments} SET status = %d, timestamp = %d, subject = '%s', comment = '%s', format = %d, uid = %d, name = '%s', mail = '%s', homepage = '%s' WHERE cid = %d", $edit['status'], $edit['timestamp'], $edit['subject'], $edit['comment'], $edit['format'], $edit['uid'], $edit['name'], $edit['mail'], $edit['homepage'], $edit['cid']);
-
-    // Allow modules to respond to the updating of a comment.
-    comment_invoke_comment($edit, 'update');
-
-    // Add an entry to the watchdog log.
-    watchdog('content', 'Comment: updated %subject.', array('%subject' => $edit['subject']), WATCHDOG_NOTICE, l(t('view'), 'node/'. $edit['nid'], array('fragment' => 'comment-'. $edit['cid'])));
-  }
-  else {
-    // Add the comment to database.
-    // Here we are building the thread field. See the documentation for
-    // comment_render().
-    if ($edit['pid'] == 0) {
-      // This is a comment with no parent comment (depth 0): we start
-      // by retrieving the maximum thread level.
-      $max = db_result(db_query('SELECT MAX(thread) FROM {comments} WHERE nid = %d', $edit['nid']));
-
-      // Strip the "/" from the end of the thread.
-      $max = rtrim($max, '/');
-
-      // Finally, build the thread field for this new comment.
-      $thread = int2vancode(vancode2int($max) + 1) .'/';
-    }
-    else {
-      // This is comment with a parent comment: we increase
-      // the part of the thread value at the proper depth.
-
-      // Get the parent comment:
-      $parent = _comment_load($edit['pid']);
-
-      // Strip the "/" from the end of the parent thread.
-      $parent->thread = (string) rtrim((string) $parent->thread, '/');
-
-      // Get the max value in _this_ thread.
-      $max = db_result(db_query("SELECT MAX(thread) FROM {comments} WHERE thread LIKE '%s.%%' AND nid = %d", $parent->thread, $edit['nid']));
-
-      if ($max == '') {
-        // First child of this parent.
-        $thread = $parent->thread .'.'. int2vancode(0) .'/';
-      }
-      else {
-        // Strip the "/" at the end of the thread.
-        $max = rtrim($max, '/');
-
-        // We need to get the value at the correct depth.
-        $parts = explode('.', $max);
-        $parent_depth = count(explode('.', $parent->thread));
-        $last = $parts[$parent_depth];
-
-        // Finally, build the thread field for this new comment.
-        $thread = $parent->thread .'.'. int2vancode(vancode2int($last) + 1) .'/';
-      }
-    }
-
-    if (empty($edit['timestamp'])) {
-      $edit['timestamp'] = time();
-    }
-
-    if ($edit['uid'] === $user->uid && isset($user->name)) { // '===' Need to modify anonymous users as well.
-      $edit['name'] = $user->name;
-    }
-
-    db_query("INSERT INTO {comments} (nid, pid, uid, subject, comment, format, hostname, timestamp, status, thread, name, mail, homepage) VALUES (%d, %d, %d, '%s', '%s', %d, '%s', %d, %d, '%s', '%s', '%s', '%s')", $edit['nid'], $edit['pid'], $edit['uid'], $edit['subject'], $edit['comment'], $edit['format'], empty($edit['hostname']) ? ip_address() : $edit['hostname'], $edit['timestamp'], $edit['status'], $thread, $edit['name'], $edit['mail'], $edit['homepage']);
-    $edit['cid'] = db_last_insert_id('comments', 'cid');
-
-    // Tell the other modules a new comment has been submitted.
-    comment_invoke_comment($edit, 'insert');
-
-    // Add an entry to the watchdog log.
-    watchdog('content', 'Comment: added %subject.', array('%subject' => $edit['subject']), WATCHDOG_NOTICE, l(t('view'), 'node/'. $edit['nid'], array('fragment' => 'comment-'. $edit['cid'])));
-  }
-  _comment_update_node_statistics($edit['nid']);
-
-  // Clear the cache so an anonymous user can see his comment being added.
-  cache_clear_all();
-
-  // Explain the approval queue if necessary, and then
-  // redirect the user to the node he's commenting on.
-  if ($edit['status'] == COMMENT_NOT_PUBLISHED) {
-    drupal_set_message(t('Your comment has been queued for moderation by site administrators and will be published after approval.'));
-  }
-  else {
-    comment_invoke_comment($edit, 'publish');
-  }
-  return $edit['cid'];
-}
+}
\ No newline at end of file
diff --git a/feeds_comment_processor.info b/feeds_comment_processor.info
index d492d9c..cb4583a 100644
--- a/feeds_comment_processor.info
+++ b/feeds_comment_processor.info
@@ -3,5 +3,8 @@ description = Create and update comments from parsed content.
 package = Feeds
 dependencies[] = feeds
 dependencies[] = comment
-core = 6.x
+core = 7.x
 php = 5.2
+
+files[] = FeedsCommentProcessor.inc
+files[] = feeds_comment_processor.module
diff --git a/feeds_comment_processor.install b/feeds_comment_processor.install
deleted file mode 100644
index 193e349..0000000
--- a/feeds_comment_processor.install
+++ /dev/null
@@ -1,74 +0,0 @@
-<?php
-
-/**
- * Implementation of hook_schema().
- */
-function feeds_comment_processor_schema() {
-  $schema = array();
-  $schema['feeds_comment_item'] = array(
-    'description' => t('Stores additional information about feed item comments. Used by FeedsCommentProcessor.'),
-    'fields' => array(
-      'cid' => array(
-        'type' => 'int',
-        'unsigned' => TRUE,
-        'not null' => TRUE,
-        'description' => t("Primary Key: The feed item comment's cid."),
-      ),
-      'id' => array(
-        'type' => 'varchar',
-        'length' => 128,
-        'not null' => TRUE,
-        'default' => '',
-        'description' => 'The id of the fields object that is the producer of this item.',
-      ),
-      'feed_nid' => array(
-        'type' => 'int',
-        'unsigned' => TRUE,
-        'not null' => TRUE,
-        'description' => t("Node id of the owner feed, if available."),
-      ),
-      'imported' => array(
-        'type' => 'int',
-        'not null' => TRUE,
-        'default' => 0,
-        'description' => t('Import date of the feed item, as a Unix timestamp.'),
-      ),
-      'guid' => array(
-        'type' => 'text',
-        'not null' => TRUE,
-        'description' => t('Unique identifier for the feed item.'),
-      ),
-      'hash' => array(
-        'type' => 'varchar',
-        'length' => 32, // The length of an MD5 hash.
-        'not null' => TRUE,
-        'default' => '',
-        'description' => t('The hash of the item.'),
-      ),
-    ),
-    'primary key' => array('cid'),
-    'indexes' => array(
-      'id' => array('id'),
-      'feed_nid' => array('feed_nid'),
-      'imported' => array('imported'),
-      'guid' => array(array('guid', 255)),
-    ),
-  );
-  return $schema;
-}
-
-/**
- * Implementation of hook_install().
- */
-function feeds_comment_processor_install() {
-  // Create tables.
-  drupal_install_schema('feeds_comment_processor');
-}
-
-/**
- * Implementation of hook_uninstall().
- */
-function feeds_comment_processor_uninstall() {
-  // Remove tables.
-  drupal_uninstall_schema('feeds_comment_processor');
-}
diff --git a/feeds_comment_processor.module b/feeds_comment_processor.module
index ae61f97..eec8aec 100644
--- a/feeds_comment_processor.module
+++ b/feeds_comment_processor.module
@@ -1,7 +1,7 @@
 <?php
 
 /**
- * Implementation of hook_feeds_plugins().
+ * Implements hook_feeds_plugins().
  */
 function feeds_comment_processor_feeds_plugins() {
   $path = drupal_get_path('module', 'feeds_comment_processor');
@@ -39,11 +39,20 @@ function _feeds_comment_processor_comment(&$comment, $op) {
       }
       break;
     case 'delete':
-      db_query("DELETE FROM {feeds_comment_item} WHERE cid = %d", $comment->cid);
+      // TODO Please review the conversion of this statement to the D7 database API syntax.
+      /* db_query("DELETE FROM {feeds_comment_item} WHERE cid = %d", $comment->cid) */
+      db_delete('feeds_comment_item')
+  ->condition('cid', $comment->cid)
+  ->execute();
       break;
   }
 }
 
-function feeds_comment_processor_comment(&$a1, $op) {
+/**
+ * @todo Please document this function.
+ * @see http://drupal.org/node/1354
+ */
+function feeds_comment_processor_comment_OLD(&$a1, $op) {
+  // TODO Remaining code in this function needs to be moved to the appropriate new hook function.
   _feeds_comment_processor_comment($a1, $op);
 }
diff --git a/old-methods.inc b/old-methods.inc
new file mode 100644
index 0000000..e879d5e
--- /dev/null
+++ b/old-methods.inc
@@ -0,0 +1,342 @@
+<?php
+/**
+   * Get id of an existing feed item term if available.
+   */
+  /*protected function existingEntityId(FeedsSource $source, FeedsParserResult $result) {
+    if ($cid = parent::existingEntityId($source, $result)) {
+      return $cid;
+    }
+
+    // Iterate through all unique targets and try to find a user for the
+    // target's value.
+    foreach ($this->uniqueTargets($source, $result) as $target => $value) {
+      switch ($target) {
+        case 'name':
+          $uid = db_query("SELECT uid FROM {users} WHERE name = :name", array(':name' => $value))->fetchField();
+          break;
+        case 'mail':
+          $uid = db_query("SELECT uid FROM {users} WHERE mail = :mail", array(':mail' => $value))->fetchField();
+          break;
+        case 'openid':
+          $uid = db_query("SELECT uid FROM {authmap} WHERE authname = :authname AND module = 'openid'", array(':authname' => $value))->fetchField();
+          break;
+      }
+      if ($uid) {
+        // Return with the first nid found.
+        return $uid;
+      }
+    }
+    return 0;
+  }*/
+  /**
+   * Implementation of FeedsProcessor::process().
+   */
+  public function process_OLD(FeedsImportBatch $batch, FeedsSource $source) {
+    dsm('processing');
+    // Keep track of processed items in this pass.
+    $processed = 0;
+    if (!$batch->getTotal(FEEDS_PROCESSING)) {
+      $batch->setTotal(FEEDS_PROCESSING, $batch->getItemCount());
+    }
+
+    while ($item = $batch->shiftItem()) {
+
+      // Create/update if item does not exist or update existing is enabled.
+      if (!($cid = $this->existingItemId($batch, $source)) || ($this->config['update_existing'] != FEEDS_SKIP_EXISTING)) {
+        // Only proceed if item has actually changed.
+        $hash = $this->hash($item);
+        if (!empty($cid) && $hash == $this->getHash($cid)) {
+          continue;
+        }
+
+        $comment = $this->buildComment($cid, $source->feed_nid);
+        $comment->feeds_comment_item->hash = $hash;
+
+        // Map and save comment. If errors occur don't stop but report them.
+        try {
+          $this->map($batch, $comment);
+          if (empty($comment->nid)) {
+            throw new Exception("Unable create comment with empty NID");
+          }
+          _feeds_comment_save((array) $comment);
+          if (!empty($cid)) {
+            $batch->updated++;
+          }
+          else {
+            $batch->created++;
+          }
+        }
+        catch (Exception $e) {
+          drupal_set_message($e->getMessage(), 'warning');
+          watchdog('feeds', $e->getMessage(), array(), WATCHDOG_WARNING);
+        }
+      }
+
+      $processed++;
+      if ($processed >= variable_get('feeds_comment_batch_size', FEEDS_COMMENT_BATCH_SIZE)) {
+        $batch->setProgress(FEEDS_PROCESSING, $batch->created + $batch->updated);
+        return;
+      }
+    }
+
+    // Set messages.
+    if ($batch->created) {
+      drupal_set_message(format_plural($batch->created, 'Created @number comment', 'Created @number comments.', array('@number' => $batch->created)));
+    }
+    elseif ($batch->updated) {
+      drupal_set_message(format_plural($batch->updated, 'Updated @number comment.', 'Updated @number comments.', array('@number' => $batch->updated)));
+    }
+    else {
+      drupal_set_message(t('There are no new comments.'));
+    }
+    $batch->setProgress(FEEDS_PROCESSING, FEEDS_BATCH_COMPLETE);
+  }
+
+  /**
+   * Implementation of FeedsProcessor::clear().
+   */
+  public function clear(FeedsBatch $batch, FeedsSource $source) {
+    if (!$batch->getTotal(FEEDS_CLEARING)) {
+      $total = db_query("SELECT COUNT(cid) FROM {feeds_comment_item} WHERE id = :id AND feed_nid = :feed_nid", array(':id' => $source->id, ':feed_nid' => $source->feed_nid))->fetchField();
+      $batch->setTotal(FEEDS_CLEARING, $total);
+    }
+    $result = db_query_range("SELECT cid FROM {feeds_comment_item} WHERE id = :id AND feed_nid = :feed_nid", array(':id' => $source->id, ':feed_nid' => $source->feed_nid));
+    while ($comment = db_fetch_object($result)) {
+      _feeds_comment_delete($comment->cid);
+      $batch->deleted++;
+    }
+    if (db_query_range("SELECT cid FROM {feeds_comment_item} WHERE id = :id AND feed_nid = :feed_nid", array(':id' => $source->id, ':feed_nid' => $source->feed_nid))->fetchField()) {
+      $batch->setProgress(FEEDS_CLEARING, $batch->deleted);
+      return;
+    }
+
+    // Set message.
+    drupal_get_messages('status');
+    if ($batch->deleted) {
+      drupal_set_message(format_plural($batch->deleted, 'Deleted @number comment.', 'Deleted @number comments.', array('@number' => $batch->deleted)));
+    }
+    else {
+      drupal_set_message(t('There is no content to be deleted.'));
+    }
+    $batch->setProgress(FEEDS_CLEARING, FEEDS_BATCH_COMPLETE);
+  }
+  /**
+   * Creates a new comment object in memory and returns it.
+   */
+  protected function buildComment($cid, $feed_nid) {
+    $comment = new stdClass();
+    if (empty($cid)) {
+      $comment->created = FEEDS_REQUEST_TIME;
+      $populate = TRUE;
+    }
+    else {
+      if ($this->config['update_existing'] == FEEDS_UPDATE_EXISTING) {
+        $comment = comment_load($cid);
+      }
+      else {
+        $comment->cid = $cid;
+        $populate = TRUE;
+      }
+    }
+    if ($populate) {
+      $comment->timestamp = FEEDS_REQUEST_TIME;
+      $comment->format = $this->config['input_format'];
+      $comment->feeds_comment_item = new stdClass();
+      $comment->feeds_comment_item->id = $this->id;
+      $comment->feeds_comment_item->imported = FEEDS_REQUEST_TIME;
+      $comment->feeds_comment_item->feed_nid = $feed_nid;
+      $comment->feeds_comment_item->guid = '';
+      $comment->uid = $this->config['author'];
+      $account = user_load($comment->uid);
+      $comment->name = $account->name;
+      $comment->mail = $account->mail;
+      $comment->status = 0;
+      $comment->pid = 0;
+      $comment->hostname = '127.0.0.1';
+
+    }
+
+    return $comment;
+  }
+
+  /**
+   * Create MD5 hash of item and mappings array.
+   *
+   * Include mappings as a change in mappings may have an affect on the item
+   * produced.
+   *
+   * @return Always returns a hash, even with empty, NULL, FALSE:
+   *  Empty arrays return 40cd750bba9870f18aada2478b24840a
+   *  Empty/NULL/FALSE strings return d41d8cd98f00b204e9800998ecf8427e
+   */
+  protected function hash($item) {
+    static $serialized_mappings;
+    if (!$serialized_mappings) {
+      $serialized_mappings = serialize($this->config['mappings']);
+    }
+    return hash('md5', serialize($item) . $serialized_mappings);
+  }
+
+  /**
+   * Retrieve MD5 hash of $cid from DB.
+   * @return Empty string if no item is found, hash otherwise.
+   */
+  protected function getHash($cid) {
+    $hash = db_query("SELECT hash FROM {feeds_comment_item} WHERE cid = :cid", array(':cid' => $cid))->fetchField();
+    if ($hash) {
+      // Return with the hash.
+      return $hash;
+    }
+    return '';
+  }
+}
+
+function _feeds_comment_delete($cid) {
+  module_load_include('inc', 'comment', 'comment.admin');
+  $to_delete = comment_load($cid);
+  // Delete comment and its replies.
+  _comment_delete_thread($to_delete);
+  _comment_update_node_statistics($to_delete->nid);
+}
+
+/**
+ * This function is copied and pasted from comment_save in Drupal core and then
+ * modified to get rid of access restrictions and to prevent extraneous dsms.
+ *
+ * @param $edit
+ *   A comment array.
+ *
+ * @return
+ *   If the comment is successfully saved the comment ID is returned. If the comment
+ *   is not saved, FALSE is returned.
+ */
+function _feeds_comment_save($edit) {
+  global $user;
+
+  $edit += array(
+    'mail' => '',
+    'homepage' => '',
+    'name' => '',
+    'status' => user_access('post comments without approval') ? COMMENT_PUBLISHED : COMMENT_NOT_PUBLISHED,
+  );
+  if ($edit['cid']) {
+    // Update the comment in the database.
+    // TODO Please review the conversion of this statement to the D7 database API syntax.
+    /* db_query("UPDATE {comments} SET status = %d, timestamp = %d, subject = '%s', comment = '%s', format = %d, uid = %d, name = '%s', mail = '%s', homepage = '%s' WHERE cid = %d", $edit['status'], $edit['timestamp'], $edit['subject'], $edit['comment'], $edit['format'], $edit['uid'], $edit['name'], $edit['mail'], $edit['homepage'], $edit['cid']) */
+    db_update('comments')
+  ->fields(array(
+      'status' => $edit['status'],
+      'timestamp' => $edit['timestamp'],
+      'subject' => $edit['subject'],
+      'comment' => $edit['comment'],
+      'format' => $edit['format'],
+      'uid' => $edit['uid'],
+      'name' => $edit['name'],
+      'mail' => $edit['mail'],
+      'homepage' => $edit['homepage'],
+    ))
+  ->condition('cid', $edit['cid'])
+  ->execute();
+
+    // Allow modules to respond to the updating of a comment.
+    comment_invoke_comment($edit, 'update');
+
+    // Add an entry to the watchdog log.
+    watchdog('content', 'Comment: updated %subject.', array('%subject' => $edit['subject']), WATCHDOG_NOTICE, l(t('view'), 'node/' . $edit['nid'], array('fragment' => 'comment-' . $edit['cid'])));
+  }
+  else {
+    // Add the comment to database.
+    // Here we are building the thread field. See the documentation for
+    // comment_render().
+    if ($edit['pid'] == 0) {
+      // This is a comment with no parent comment (depth 0): we start
+      // by retrieving the maximum thread level.
+      $max = db_query('SELECT MAX(thread) FROM {comments} WHERE nid = :nid', array(':nid' => $edit['nid']))->fetchField();
+
+      // Strip the "/" from the end of the thread.
+      $max = rtrim($max, '/');
+
+      // Finally, build the thread field for this new comment.
+      $thread = int2vancode(vancode2int($max) + 1) . '/';
+    }
+    else {
+      // This is comment with a parent comment: we increase
+      // the part of the thread value at the proper depth.
+
+      // Get the parent comment:
+      $parent = comment_load($edit['pid']);
+
+      // Strip the "/" from the end of the parent thread.
+      $parent->thread = (string) rtrim((string) $parent->thread, '/');
+
+      // Get the max value in _this_ thread.
+      $max = db_query("SELECT MAX(thread) FROM {comments} WHERE thread LIKE '%s.%%' AND nid = :nid", array(':nid' => $parent->thread, '' => $edit['nid']))->fetchField();
+
+      if ($max == '') {
+        // First child of this parent.
+        $thread = $parent->thread . '.' . int2vancode(0) . '/';
+      }
+      else {
+        // Strip the "/" at the end of the thread.
+        $max = rtrim($max, '/');
+
+        // We need to get the value at the correct depth.
+        $parts = explode('.', $max);
+        $parent_depth = count(explode('.', $parent->thread));
+        $last = $parts[$parent_depth];
+
+        // Finally, build the thread field for this new comment.
+        $thread = $parent->thread . '.' . int2vancode(vancode2int($last) + 1) . '/';
+      }
+    }
+
+    if (empty($edit['timestamp'])) {
+      $edit['timestamp'] = REQUEST_TIME;
+    }
+
+    if ($edit['uid'] === $user->uid && isset($user->name)) { // '===' Need to modify anonymous users as well.
+      $edit['name'] = $user->name;
+    }
+
+    // TODO Please review the conversion of this statement to the D7 database API syntax.
+    /* db_query("INSERT INTO {comments} (nid, pid, uid, subject, comment, format, hostname, timestamp, status, thread, name, mail, homepage) VALUES (%d, %d, %d, '%s', '%s', %d, '%s', %d, %d, '%s', '%s', '%s', '%s')", $edit['nid'], $edit['pid'], $edit['uid'], $edit['subject'], $edit['comment'], $edit['format'], empty($edit['hostname']) ? ip_address() : $edit['hostname'], $edit['timestamp'], $edit['status'], $thread, $edit['name'], $edit['mail'], $edit['homepage']) */
+    $id = db_insert('comments')
+  ->fields(array(
+      'nid' => $edit['nid'],
+      'pid' => $edit['pid'],
+      'uid' => $edit['uid'],
+      'subject' => $edit['subject'],
+      'comment' => $edit['comment'],
+      'format' => $edit['format'],
+      'hostname' => empty($edit['hostname']) ? ip_address() : $edit['hostname'],
+      'timestamp' => $edit['timestamp'],
+      'status' => $edit['status'],
+      'thread' => $thread,
+      'name' => $edit['name'],
+      'mail' => $edit['mail'],
+      'homepage' => $edit['homepage'],
+    ))
+  ->execute();
+    $edit['cid'] = db_last_insert_id('comments', 'cid');
+
+    // Tell the other modules a new comment has been submitted.
+    comment_invoke_comment($edit, 'insert');
+
+    // Add an entry to the watchdog log.
+    watchdog('content', 'Comment: added %subject.', array('%subject' => $edit['subject']), WATCHDOG_NOTICE, l(t('view'), 'node/' . $edit['nid'], array('fragment' => 'comment-' . $edit['cid'])));
+  }
+  _comment_update_node_statistics($edit['nid']);
+
+  // Clear the cache so an anonymous user can see his comment being added.
+  cache_clear_all();
+
+  // Explain the approval queue if necessary, and then
+  // redirect the user to the node he's commenting on.
+  if ($edit['status'] == COMMENT_NOT_PUBLISHED) {
+    drupal_set_message(t('Your comment has been queued for moderation by site administrators and will be published after approval.'));
+  }
+  else {
+    comment_invoke_comment($edit, 'publish');
+  }
+  return $edit['cid'];
+}
