diff --git a/apachesolr.index.inc b/apachesolr.index.inc
index d1e7de6..c854fd7 100644
--- a/apachesolr.index.inc
+++ b/apachesolr.index.inc
@@ -306,7 +306,7 @@ function _apachesolr_index_process_entity_get_document($entity, $entity_type) {
 
   // Path aliases can have important information about the content.
   // Add them to the index as well.
-  if (function_exists('drupal_get_path_alias')) {
+  if (function_exists('drupal_get_path_alias') && !empty($document->path)) {
     // Add any path alias to the index, looking first for language specific
     // aliases but using language neutral aliases otherwise.
     $output = drupal_get_path_alias($document->path, $document->language);
@@ -374,13 +374,13 @@ function apachesolr_index_get_entities_to_index($env_id, $entity_type, $limit) {
     else {
       // Discard this entry
       $rows[] = NULL;
-      // Delete if from the index - Do not use apachesolr_entity_delete because
+      // Delete from the index - Do not use apachesolr_entity_delete because
       // the module does not want to load a complete entity
       if (apachesolr_index_delete_entity_from_index($env_id, $record->entity_type, $record->entity_id)) {
         // There was no exception, so delete from the table.
         db_delete($table)
-          ->condition('entity_type', $entity_type)
-          ->condition('entity_id', $id)
+          ->condition('entity_type', $record->entity_type)
+          ->condition('entity_id', $record->entity_id)
           ->execute();
       }
     }
@@ -621,6 +621,7 @@ function apachesolr_index_node_solr_document(ApacheSolrDocument $document, $node
   }
   $document->ds_created = apachesolr_date_iso($node->created);
   $document->ds_changed = apachesolr_date_iso($node->changed);
+
   if (isset($node->last_comment_timestamp) && !empty($node->comment_count)) {
     $document->ds_last_comment_timestamp = apachesolr_date_iso($node->last_comment_timestamp);
     $document->ds_last_comment_or_change = apachesolr_date_iso(max($node->last_comment_timestamp, $node->changed));
