diff --git a/apachesolr_attachments.module b/apachesolr_attachments.module
index d8428a2..eae1baf 100644
--- a/apachesolr_attachments.module
+++ b/apachesolr_attachments.module
@@ -85,8 +85,8 @@ function apachesolr_attachments_solr_document(ApacheSolrDocument $document, $fil
 
   // Get list of nodes that are linked to this particular file
   // A single file might be attached to multiple nodes.
-  $references = file_get_file_references($file);
-  $reference_list = reset($references);
+  $references = file_get_file_references($file, NULL, FIELD_LOAD_CURRENT);
+  $reference_list = $references ? reset($references) : NULL;
   if (!empty($reference_list)) {
     foreach ($reference_list as $reference_entity_type => $reference) {
       foreach ($reference as $reference_entity_id => $reference_info) {
@@ -100,13 +100,13 @@ function apachesolr_attachments_solr_document(ApacheSolrDocument $document, $fil
         $filedocument = clone $document;
         //Get the callback array to add stuff to the document
         $callbacks = apachesolr_entity_get_callback($reference_entity_type, 'document callback');
-        $documents = array();
+        $build_documents = array();
         foreach ($callbacks as $callback) {
           // Call a type-specific callback to add stuff to the document.
-          $documents = array_merge($documents, $callback($filedocument, $referenced_entity, $reference_entity_type, $env_id));
+          $build_documents = array_merge($build_documents, $callback($filedocument, $referenced_entity, $reference_entity_type, $env_id));
         }
         // Take the top document from the stack
-        $filedocument = reset($documents);
+        $filedocument = reset($build_documents);
 
         // Build our separate document and overwrite basic information
         $filedocument->id = apachesolr_document_id($file->fid . '-' . $reference_entity_id, 'file');
@@ -135,7 +135,6 @@ function apachesolr_attachments_solr_document(ApacheSolrDocument $document, $fil
       }
     }
   }
-  dsm($documents);
   return $documents;
 }
 
@@ -225,8 +224,8 @@ function apachesolr_attachments_excluded_entities($entity_id, $entity_type) {
   $status = TRUE;
 
   $file = file_load($entity_id);
-  $references = file_get_file_references($file);
-  $reference_list = reset($references);
+  $references = file_get_file_references($file, NULL, FIELD_LOAD_CURRENT);
+  $reference_list = $references ? reset($references) : NULL;
 
   if (!empty($reference_list)) {
     foreach ($reference_list as $reference_entity_type => $reference) {
