diff --git a/reference_tracker.admin.inc b/reference_tracker.admin.inc
index ba0dbf4..ac64961 100644
--- a/reference_tracker.admin.inc
+++ b/reference_tracker.admin.inc
@@ -1,4 +1,8 @@
 <?php
+/**
+ * @file
+ * Administrative page callbacks for Reference Tracker module.
+ */
 
 /**
  * Configuration form.
@@ -28,7 +32,7 @@ function reference_tracker_settings_form($form, &$form_state) {
 
   $form['extra_settings']['reference_tracker_local_paths'] = array(
     '#type' => 'textarea',
-    '#title' =>  t('Base paths considered internal'),
+    '#title' => t('Base paths considered internal'),
     '#default_value' => variable_get('reference_tracker_local_paths'),
     '#description' => t('References to entities are also searched in text values, based upon the "href" attributes in HTML anchors. If this site is available at more than one base path or URL, enter them here, separated by line breaks. For example, if both <code>http://example.com/</code> and <code>http://anotherdomain.org/example/</code> could point to internal entities, you would enter both those URLs here (one on each line).'),
   );
@@ -132,7 +136,10 @@ function reference_tracker_rebuild_form_submit($form, &$form_state) {
 
   foreach ($entity_types as $entity_type) {
     $batch['operations'][] = array('reference_tracker_rebuild_batch_clear', array($entity_type));
-    $batch['operations'][] = array('reference_tracker_rebuild_batch_worker', array($entity_type, $batch_process_limit));
+    $batch['operations'][] = array(
+      'reference_tracker_rebuild_batch_worker',
+      array($entity_type, $batch_process_limit),
+    );
   }
 
   batch_set($batch);
diff --git a/reference_tracker.api.inc b/reference_tracker.api.inc
index a5f555d..040c9c2 100644
--- a/reference_tracker.api.inc
+++ b/reference_tracker.api.inc
@@ -1,14 +1,18 @@
 <?php
+/**
+ * @file
+ * API documentation for the Reference tracker module.
+ */
 
 /**
- * Decide wether an entity is allowed to be parsed or not.
+ * Decide whether an entity is allowed to be parsed or not.
  *
  * @param string $entity_type
  *   The entity type.
  * @param object $entity
  *   The entity object.
  * @param bool $save
- *   Wether the parsed results are to be saved to the database or not.
+ *   Whether the parsed results are to be saved to the database or not.
  *
  * @return bool
  *   TRUE if this entity may be parsed, FALSE if not.
@@ -33,7 +37,7 @@ function hook_reference_tracker_parse_entity($entity_type, $entity, $save) {
  *   array(
  *     field name => array(
  *       language => array(
- *         refernced entity_type => array(
+ *         referenced entity_type => array(
  *           referenced entity id,
  *           referenced entity id,
  *           ...
@@ -64,7 +68,7 @@ function hook_reference_tracker_entity_references_alter(&$references, $context)
  *   Associative multidimensional array in the following structure:
  *   array(
  *     language => array(
- *       refernced entity_type => array(
+ *       referenced entity_type => array(
  *         referenced entity id,
  *         referenced entity id,
  *         ...
@@ -130,10 +134,12 @@ function hook_reference_tracker_field_types_parse_info() {
 }
 
 /**
- * Alter field types parse info collected by the various
+ * Alter field types parse info.
+ *
+ * This info is collected by the various
  * hook_reference_tracker_field_types_parse_info() hook implementations.
  *
- * @see hook_reference_tracker_field_types_parse_info().
+ * @see hook_reference_tracker_field_types_parse_info()
  */
 function hook_reference_tracker_field_types_parse_info_alter(&$field_type_parse_info) {
   // Ignore the 'summary' value for text_with_summary field types.
@@ -173,20 +179,23 @@ function hook_reference_tracker_value_types_parse_info() {
 }
 
 /**
- * Alter value types parse info collected by the various
+ * Alter value types parse info.
+ *
+ * This info is collected by the various
  * hook_reference_tracker_value_types_parse_info() hook implementations.
  *
- * @see hook_reference_tracker_value_types_parse_info().
+ * @see hook_reference_tracker_value_types_parse_info()
  */
 function hook_reference_tracker_value_types_parse_info_alter(&$field_type_parse_info) {
   // Use our own custom value type parser for 'text' values.
-    $value_types_parse_info['text']['parser_callback'] = 'my_custom_text_value_parser';
+  $value_types_parse_info['text']['parser_callback'] = 'my_custom_text_value_parser';
 }
 
 /**
- * Define one or more supported entity path parts. Entity path parts are used
- * by the 'text' parser to identify references to entities based on a part of
- * their path.
+ * Define one or more supported entity path parts.
+ *
+ * Entity path parts are used by the 'text' parser to identify references to
+ * entities based on a part of their path.
  *
  * @return array
  *   An associative array keyed by the entity type and as value the entity path.
@@ -202,10 +211,11 @@ function hook_reference_tracker_entity_path_parts() {
 }
 
 /**
- * Alter entity paths collected by the various
+ * Alter entity paths collected by the various.
+ *
  * hook_reference_tracker_entity_path_parts() hook implementations.
  *
- * @see hook_reference_tracker_entity_path_parts().
+ * @see hook_reference_tracker_entity_path_parts()
  */
 function hook_reference_tracker_entity_path_parts_alter(&$entity_path_parts) {
   // Not interested in user paths.
diff --git a/reference_tracker.drush.inc b/reference_tracker.drush.inc
index ed07c73..6df060a 100644
--- a/reference_tracker.drush.inc
+++ b/reference_tracker.drush.inc
@@ -1,7 +1,11 @@
 <?php
+/**
+ * @file
+ * Drush integration for the Reference Tracker module.
+ */
 
 /**
- * Implementation of hook_drush_help().
+ * Implements hook_drush_help().
  */
 function reference_tracker_drush_help($section) {
   switch ($section) {
@@ -10,6 +14,7 @@ function reference_tracker_drush_help($section) {
       $help .= dt('If no entity types are specified, you will be presented with a list of valid entity types to choose from.');
       $help .= dt('To rebuild all entity types, do not specify any entity types, and choose the option "All" from the options presented.');
       return $help;
+
     case 'drush:reference-tracker-clear':
       $help  = dt('This will clear all entries in the Reference Tracker table.');
       $help .= dt('If no entity types are specified, you will be presented with a list of valid entity types to choose from.');
@@ -19,7 +24,7 @@ function reference_tracker_drush_help($section) {
 }
 
 /**
- * Implementation of hook_drush_command().
+ * Implements hook_drush_command().
  */
 function reference_tracker_drush_command() {
   $items = array();
@@ -33,7 +38,7 @@ function reference_tracker_drush_command() {
     'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
     'aliases' => array('rtr'),
     'options' => array(
-      'batch_process_limit' => dt('Amount of entities to be parsed per process.')
+      'batch_process_limit' => dt('Amount of entities to be parsed per process.'),
     ),
     'examples' => array(
       'drush rtr node' => dt('Parses all node entities.'),
@@ -107,12 +112,15 @@ function drush_reference_tracker_rebuild() {
     'title' => dt('Rebuilding the Reference Tracker table.'),
     'init_message' => dt('Started rebuilding the Reference Tracker table.'),
     'progress_message' => dt('Rebuilding the Reference Tracker table.'),
-    'error_message' => dt('An error occured during rebuild of the Reference Tracker table.'),
+    'error_message' => dt('An error occurred during rebuild of the Reference Tracker table.'),
   );
 
   foreach ($entity_types as $entity_type) {
     $batch['operations'][] = array('reference_tracker_rebuild_batch_clear', array($entity_type));
-    $batch['operations'][] = array('reference_tracker_rebuild_batch_worker', array($entity_type, $batch_process_limit));
+    $batch['operations'][] = array(
+      'reference_tracker_rebuild_batch_worker',
+      array($entity_type, $batch_process_limit),
+    );
   }
 
   batch_set($batch);
diff --git a/reference_tracker.install b/reference_tracker.install
index 685a374..53fa7da 100644
--- a/reference_tracker.install
+++ b/reference_tracker.install
@@ -1,4 +1,8 @@
 <?php
+/**
+ * @file
+ * Install, uninstall, update and schema hooks for Reference Tracker.
+ */
 
 /**
  * Implements hook_install().
@@ -7,7 +11,13 @@ function reference_tracker_install() {
   // Enable some entity types by default.
   $entity_info = entity_get_info();
   $entity_types = array();
-  foreach (array('node', 'taxonomy_term', 'field_collection_item', 'paragraphs_itm') as $entity_type) {
+  $types = array(
+    'node',
+    'taxonomy_term',
+    'field_collection_item',
+    'paragraphs_itm',
+  );
+  foreach ($types as $entity_type) {
     if (!empty($entity_info[$entity_type])) {
       $entity_types[] = $entity_type;
     }
@@ -81,16 +91,45 @@ function reference_tracker_schema() {
         'not null' => TRUE,
       ),
     ),
-    'primary key' => array('entity_type', 'entity_id', 'field_instance_id', 'language', 'reference_entity_type', 'reference_entity_id'),
+    'primary key' => array(
+      'entity_type',
+      'entity_id',
+      'field_instance_id',
+      'language',
+      'reference_entity_type',
+      'reference_entity_id',
+    ),
     'indexes' => array(
       'entity_type_id' => array('entity_type', 'entity_id'),
       'entity_type_id_language' => array('entity_type', 'entity_id', 'language'),
-      'entity_type_id_field' => array('entity_type', 'entity_id', 'field_instance_id'),
-      'entity_type_id_field_language' => array('entity_type', 'entity_id', 'field_instance_id', 'language'),
+      'entity_type_id_field' => array(
+        'entity_type',
+        'entity_id',
+        'field_instance_id',
+      ),
+      'entity_type_id_field_language' => array(
+        'entity_type',
+        'entity_id',
+        'field_instance_id',
+        'language',
+      ),
       'reference_entity_type_id' => array('reference_entity_type', 'reference_entity_id'),
-      'reference_entity_type_id_language' => array('reference_entity_type', 'reference_entity_id', 'language'),
-      'reference_entity_type_id_field' => array('reference_entity_type', 'reference_entity_id', 'field_instance_id'),
-      'reference_entity_type_id_field_language' => array('reference_entity_type', 'reference_entity_id', 'field_instance_id', 'language'),
+      'reference_entity_type_id_language' => array(
+        'reference_entity_type',
+        'reference_entity_id',
+        'language',
+      ),
+      'reference_entity_type_id_field' => array(
+        'reference_entity_type',
+        'reference_entity_id',
+        'field_instance_id',
+      ),
+      'reference_entity_type_id_field_language' => array(
+        'reference_entity_type',
+        'reference_entity_id',
+        'field_instance_id',
+        'language',
+      ),
     ),
   );
 
diff --git a/reference_tracker.module b/reference_tracker.module
index 4d8e4c5..edde476 100644
--- a/reference_tracker.module
+++ b/reference_tracker.module
@@ -1,4 +1,8 @@
 <?php
+/**
+ * @file
+ * Main functions and hook implementations for the Reference Tracker module.
+ */
 
 /**
  * Defined the default batch process limit.
@@ -104,7 +108,7 @@ function reference_tracker_entity_delete($entity, $type) {
  *   array(
  *     field name => array(
  *       language => array(
- *         refernced entity_type => array(
+ *         referenced entity_type => array(
  *           referenced entity id,
  *           referenced entity id,
  *           ...
@@ -129,7 +133,7 @@ function reference_tracker_parse_entity($entity_type, $entity, $save = TRUE, $by
     }
   }
 
-  // Allow other modules to decide wether this entity may be parsed or not.
+  // Allow other modules to decide whether this entity may be parsed or not.
   foreach (module_implements('reference_tracker_parse_entity') as $module) {
     $function = $module . '_reference_tracker_parse_entity';
     $result = $function($entity_type, $entity, $save);
@@ -188,7 +192,7 @@ function reference_tracker_parse_entity($entity_type, $entity, $save = TRUE, $by
  *   Associative multidimensional array in the following structure:
  *   array(
  *     language => array(
- *       refernced entity_type => array(
+ *       referenced entity_type => array(
  *         referenced entity id,
  *         referenced entity id,
  *         ...
@@ -475,7 +479,7 @@ function reference_tracker_text_value_parser($value, $context) {
   // Collect all URL's containing entity path parts.
   $matches = array();
   $pattern = '~href="*.*?(' . str_replace('/', '\/', implode('|', $entity_path_parts)) . ')\/(\d*)\/*.*?"~i';
-  preg_match_all($pattern , $value, $matches, PREG_PATTERN_ORDER + PREG_OFFSET_CAPTURE);
+  preg_match_all($pattern, $value, $matches, PREG_PATTERN_ORDER + PREG_OFFSET_CAPTURE);
 
   // Collect all references from the URL's.
   $references = array();
@@ -638,7 +642,7 @@ function reference_tracker_enabled_entity_types($rebuild = FALSE) {
 }
 
 /**
- * Check wether a given entity type is valid for parsing.
+ * Check whether a given entity type is valid for parsing.
  *
  * @param string $entity_type
  *   The entity type to check.
@@ -694,8 +698,16 @@ function reference_tracker_save($entity_type, $entity_id, $references) {
 
   // Save the results to the database.
   if (!empty($values)) {
+    $fields = array(
+      'entity_type',
+      'entity_id',
+      'field_instance_id',
+      'language',
+      'reference_entity_type',
+      'reference_entity_id',
+    );
     $insert = db_insert('reference_tracker')
-                ->fields(array('entity_type', 'entity_id', 'field_instance_id', 'language', 'reference_entity_type', 'reference_entity_id'));
+                ->fields($fields);
     foreach ($values as $value) {
       $insert->values($value);
     }
@@ -704,8 +716,7 @@ function reference_tracker_save($entity_type, $entity_id, $references) {
 }
 
 /**
- * Normalizes entity data parsed by Reference Tracker to an easy to use
- * structure.
+ * Normalizes data parsed by Reference Tracker to an easy to use structure.
  *
  * @param array $references
  *   Parsed entity results generated by reference_tracker_parse_entity().
@@ -741,8 +752,6 @@ function reference_tracker_normalize_parsed_data($references) {
  *   The amount of entries that were deleted from the Reference Tracker table.
  */
 function reference_tracker_clear($entity_types = NULL, $entity_ids = NULL) {
-  $count = 0;
-
   // For performance reasons, we are using the TRUNCATE command if a full
   // table clear is requested.
   if (empty($entity_types) && empty($entity_ids)) {
@@ -774,8 +783,9 @@ function reference_tracker_clear($entity_types = NULL, $entity_ids = NULL) {
 }
 
 /**
- * Batch callback for clearing the Reference Tracker table for a specific
- * entity type.
+ * Batch callback.
+ *
+ * This clears the Reference Tracker table for a specific entity type.
  *
  * @param string $entity_type
  *   The entity type to rebuild.
@@ -868,7 +878,6 @@ function reference_tracker_reference_tracker_parse_entity($entity_type, $entity,
  */
 function reference_tracker_reference_tracker_entity_references_alter(&$references, $context) {
   if (module_exists('field_collection') && variable_get('reference_tracker_field_collection_use_host')) {
-    $field_collection_references = array();
     foreach ($references as $items) {
       foreach ($items as $language => $field_references) {
         if (!empty($field_references['field_collection_item'])) {
@@ -888,9 +897,9 @@ function reference_tracker_reference_tracker_entity_references_alter(&$reference
                 }
               }
 
-              // Merge the field collection item references with the host entity's
-              // references. Can't use array_merge_recursive here, since we are
-              // dealing with numeric  array keys.
+              // Merge the field collection item references with the host
+              // entity's references. Can't use array_merge_recursive here,
+              // since we are dealing with numeric  array keys.
               foreach ($field_collection_item_references as $field_collection_item_field_instance_id => $field_collection_item_items) {
                 foreach ($field_collection_item_items as $field_collection_item_language => $field_collection_item_entity_types) {
                   foreach ($field_collection_item_entity_types as $field_collection_item_entity_type => $field_collection_item_entity_ids) {
@@ -911,7 +920,6 @@ function reference_tracker_reference_tracker_entity_references_alter(&$reference
   }
 
   if (module_exists('paragraphs') && variable_get('reference_tracker_paragraphs_use_host')) {
-    $paragraph_references = array();
     foreach ($references as $items) {
       foreach ($items as $language => $field_references) {
         if (!empty($field_references['paragraphs_item'])) {
@@ -919,9 +927,9 @@ function reference_tracker_reference_tracker_entity_references_alter(&$reference
             $paragraphs_item = paragraphs_item_load($paragraphs_item_id);
             if ($paragraphs_item) {
               $paragraphs_item_references = reference_tracker_parse_entity('paragraphs_item', $paragraphs_item, FALSE, TRUE);
-              // Paragraphs field values are always saved under the LANGUAGE_NONE
-              // language. We change this manually to the language of the
-              // paragraphs reference field.
+              // Paragraphs field values are always saved under the
+              // LANGUAGE_NONE language. We change this manually to the language
+              // of the paragraphs reference field.
               if ($language !== LANGUAGE_NONE) {
                 foreach ($paragraphs_item_references as $paragraphs_item_field_instance_id => $paragraphs_item_items) {
                   if (!empty($paragraphs_item_references[$paragraphs_item_field_instance_id][LANGUAGE_NONE])) {
@@ -1003,7 +1011,7 @@ function reference_tracker_get_outbound_references($entity_type, $entity_id, $fi
 }
 
 /**
- * Returns inboud references of the given entity.
+ * Returns inbound references of the given entity.
  *
  * @param string $entity_type
  *   The entity type of the entity referenced to.
@@ -1129,8 +1137,8 @@ function reference_tracker_block_view($delta) {
       }
       $block['subject'] = $delta === 'reference_tracker_inbound' ? t('References to this entity') : t('References made from this entity');
       $block['content'] = array(
-       '#theme' => 'item_list',
-       '#items' => $items,
+        '#theme' => 'item_list',
+        '#items' => $items,
       );
     }
   }
@@ -1162,8 +1170,7 @@ function _reference_tracker_array_unique_recursive($array) {
 }
 
 /**
- * Helper function to determine if a given URL points to an internal or an
- * external source.
+ * Determines whether a given URL points to an internal or an external source.
  *
  * Credit where credit's due. Most part of this code is taken from the
  * very nice Pathologic module.
@@ -1212,7 +1219,7 @@ function _reference_tracker_is_local_path($url) {
                 // Noobs (like me): "xor" means "true if one or the other are
                 // true, but not both."
                 (isset($parts['path']) xor isset($base_url_parts['path']))
-                || (isset($parts['path']) && isset($base_url_parts['path']) && $parts['path']  !== $base_url_parts['path'])
+                || (isset($parts['path']) && isset($base_url_parts['path']) && $parts['path'] !== $base_url_parts['path'])
               )
             )
           ) ||
@@ -1278,7 +1285,7 @@ function _reference_tracker_is_local_path($url) {
     // that might more fully match the beginning of our url's path
     // e.g.: if our url is /foo/bar we'll mark this as a match for
     // http://example.com but want to keep searching and would prefer a match
-    // to http://example.com/foo if that's configured as a local path
+    // to http://example.com/foo if that's configured as a local path.
     elseif (!isset($parts['host']) && (!isset($exploded['path']) || $exploded['path'] == '/')) {
       return TRUE;
     }
