diff --git a/includes/EntityReferenceSynonymsBehavior.class.inc b/includes/EntityReferenceSynonymsBehavior.class.inc
index d1a1f3d..4aa818c 100644
--- a/includes/EntityReferenceSynonymsBehavior.class.inc
+++ b/includes/EntityReferenceSynonymsBehavior.class.inc
@@ -8,7 +8,7 @@
 /**
  * Definition of EntityReferenceSynonymsBehavior class.
  */
-class EntityReferenceSynonymsBehavior extends AbstractSynonymsSynonymsBehavior implements SynonymsSynonymsBehavior, AutocompleteSynonymsBehavior, SelectSynonymsBehavior {
+class EntityReferenceSynonymsBehavior extends AbstractSynonymsBehavior implements AutocompleteSynonymsBehavior, SelectSynonymsBehavior {
 
   public function extractSynonyms($items, $field, $instance, $entity, $entity_type) {
     $synonyms = array();
diff --git a/includes/SynonymsBehavior.interface.inc b/includes/SynonymsBehavior.interface.inc
index 2c30bca..d264362 100644
--- a/includes/SynonymsBehavior.interface.inc
+++ b/includes/SynonymsBehavior.interface.inc
@@ -11,15 +11,6 @@
  * All synonyms behaviors must extend this interface.
  */
 interface SynonymsBehavior {
-}
-
-/**
- * Interface of "synonyms" behavior.
- *
- * The most basic synonyms behavior.
- */
-interface SynonymsSynonymsBehavior extends SynonymsBehavior {
-
   /**
    * Extract synonyms from a field attached to an entity.
    *
@@ -137,9 +128,9 @@ interface SynonymsSynonymsBehavior extends SynonymsBehavior {
 class SynonymsSynonymsBehaviorException extends Exception {}
 
 /**
- * Starting point for implementing SynonymsSynonymsBehavior interface.
+ * Starting point for implementing SynonymsBehavior interface.
  */
-abstract class AbstractSynonymsSynonymsBehavior implements SynonymsSynonymsBehavior {
+abstract class AbstractSynonymsBehavior implements SynonymsBehavior {
 
   /**
    * Constant which denotes placeholder of a synonym column.
@@ -178,11 +169,11 @@ abstract class AbstractSynonymsSynonymsBehavior implements SynonymsSynonymsBehav
 /**
  * Interface of the autocomplete synonyms behavior.
  */
-interface AutocompleteSynonymsBehavior extends SynonymsSynonymsBehavior {
+interface AutocompleteSynonymsBehavior extends SynonymsBehavior {
 }
 
 /**
  * Interface of the synonyms friendly select behavior.
  */
-interface SelectSynonymsBehavior extends SynonymsSynonymsBehavior {
+interface SelectSynonymsBehavior extends SynonymsBehavior {
 }
diff --git a/includes/TaxonomySynonymsBehavior.class.inc b/includes/TaxonomySynonymsBehavior.class.inc
index 6e58a6c..c3c6f9b 100644
--- a/includes/TaxonomySynonymsBehavior.class.inc
+++ b/includes/TaxonomySynonymsBehavior.class.inc
@@ -8,7 +8,7 @@
 /**
  * Definition of TaxonomySynonymsBehavior class.
  */
-class TaxonomySynonymsBehavior extends AbstractSynonymsSynonymsBehavior implements SynonymsSynonymsBehavior, AutocompleteSynonymsBehavior, SelectSynonymsBehavior {
+class TaxonomySynonymsBehavior extends AbstractSynonymsBehavior implements AutocompleteSynonymsBehavior, SelectSynonymsBehavior {
 
   public function extractSynonyms($items, $field, $instance, $entity, $entity_type) {
     $synonyms = array();
diff --git a/includes/TextSynonymsBehavior.class.inc b/includes/TextSynonymsBehavior.class.inc
index 96472e1..4330a2c 100644
--- a/includes/TextSynonymsBehavior.class.inc
+++ b/includes/TextSynonymsBehavior.class.inc
@@ -8,7 +8,7 @@
 /**
  * Definition of TextSynonymsBehavior class.
  */
-class TextSynonymsBehavior extends AbstractSynonymsSynonymsBehavior implements SynonymsSynonymsBehavior, AutocompleteSynonymsBehavior, SelectSynonymsBehavior {
+class TextSynonymsBehavior extends AbstractSynonymsBehavior implements AutocompleteSynonymsBehavior, SelectSynonymsBehavior {
 
   public function extractSynonyms($items, $field, $instance, $entity, $entity_type) {
     $synonyms = array();
diff --git a/plugins/arguments/term_synonyms.inc b/plugins/arguments/term_synonyms.inc
index bc3e1d8..10edcf5 100644
--- a/plugins/arguments/term_synonyms.inc
+++ b/plugins/arguments/term_synonyms.inc
@@ -66,12 +66,12 @@ function synonyms_term_synonyms_context($arg = NULL, $conf = NULL, $empty = FALS
       foreach ($vocabularies as $vocabulary) {
         $condition = db_and();
         if ($conf['transform']) {
-          $condition->where("REPLACE(" . AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER . ", ' ', '-') = :argument", array(
+          $condition->where("REPLACE(" . AbstractSynonymsBehavior::COLUMN_PLACEHOLDER . ", ' ', '-') = :argument", array(
             ':argument' => $arg,
           ));
         }
         else {
-          $condition->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, $arg);
+          $condition->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, $arg);
         }
         $rows = synonyms_synonyms_find($condition, 'taxonomy_term', $vocabulary->machine_name);
         if (!empty($rows)) {
diff --git a/plugins/behavior/synonyms.inc b/plugins/behavior/synonyms.inc
deleted file mode 100644
index b7c44f7..0000000
--- a/plugins/behavior/synonyms.inc
+++ /dev/null
@@ -1,12 +0,0 @@
-<?php
-
-/**
- * @file
- * Plugin definition for most general synonyms behavior.
- */
-
-$plugin = array(
-  'title' => t('Include into term synonyms'),
-  'description' => t('Basic behavior that includes values of this field into the list of synonyms of its entity.'),
-  'interface' => 'SynonymsSynonymsBehavior',
-);
diff --git a/synonyms.info b/synonyms.info
index 709384a..04eb45c 100644
--- a/synonyms.info
+++ b/synonyms.info
@@ -4,6 +4,7 @@ package = Taxonomy
 core = 7.x
 dependencies[] = taxonomy
 dependencies[] = ctools
+dependencies[] = entity
 
 files[] = synonyms.test
 
diff --git a/synonyms.module b/synonyms.module
index fe53208..77e9378 100644
--- a/synonyms.module
+++ b/synonyms.module
@@ -11,15 +11,46 @@
 function synonyms_menu() {
   $items = array();
 
-  $items['synonyms/autocomplete/%/%/%'] = array(
+  $items['admin/structure/synonyms'] = array(
+    'title' => 'Synonyms',
+    'description' => 'Manage synonyms settings for all entity types.',
+    'page callback' => 'synonyms_settings_overview',
+    'access callback' => TRUE,
+    'file' => 'synonyms.pages.inc',
+    'type' => MENU_NORMAL_ITEM,
+  );
+
+  $items['admin/structure/synonyms/%synonyms_entity_type/%synonyms_bundle'] = array(
+    'title' => 'Synonyms settings',
+    'title callback' => 'synonyms_settings_title',
+    'title arguments' => array(3, 4),
+    'description' => 'Manage synonyms settings.',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('synonyms_settings_form', 3, 4),
+    // TODO: put some real access logic.
+    'access callback' => TRUE,
+    'load arguments' => array(3),
+    'file' => 'synonyms.pages.inc',
+  );
+
+  $items['synonyms/autocomplete-taxonomy-term/%/%/%'] = array(
     'title' => 'Autocomplete Synonyms',
-    'page callback' => 'synonyms_autocomplete',
+    'page callback' => 'synonyms_autocomplete_taxonomy_term',
     'page arguments' => array(2, 3, 4),
     'access arguments' => array('access content'),
     'file' => 'synonyms.pages.inc',
     'type' => MENU_CALLBACK,
   );
 
+  $items['synonyms/autocomplete-entity/%/%/%'] = array(
+    'title' => 'Autocomplete Synonyms',
+    'page callback' => 'synonyms_autocomplete_entity',
+    'page arguments' => array(2, 3, 4),
+    // TODO: check access logic.
+    'access arguments' => array('access content'),
+    'file' => 'synonyms.pages.inc',
+    'type' => MENU_CALLBACK,
+  );
   return $items;
 }
 
@@ -81,16 +112,22 @@ function synonyms_theme() {
  */
 function synonyms_entity_property_info() {
   $info = array();
-  $properties = &$info['taxonomy_term']['properties'];
-  $properties['synonyms'] = array(
-    'label' => t('Synonyms'),
-    'description' => t('Synonyms of entity.'),
-    'type' => 'list<text>',
-    'getter callback' => 'synonyms_get_sanitized',
-    'computed' => TRUE,
-    'sanitized' => TRUE,
-    'raw getter callback' => 'synonyms_get_raw',
-  );
+
+  foreach (entity_get_info() as $entity_type => $entity_info) {
+    $entity_info = synonyms_entity_type_load($entity_type);
+    if ($entity_info) {
+      $info[$entity_type]['properties']['synonyms'] = array(
+        'label' => t('Synonyms'),
+        'description' => t('Synonyms of entity.'),
+        'type' => 'list<text>',
+        'getter callback' => 'synonyms_get_sanitized',
+        'computed' => TRUE,
+        'sanitized' => TRUE,
+        'raw getter callback' => 'synonyms_get_raw',
+      );
+    }
+  }
+
   return $info;
 }
 
@@ -115,7 +152,6 @@ function synonyms_synonyms_behavior_implementation_info($behavior) {
   switch ($behavior) {
     case 'autocomplete':
     case 'select':
-    case 'synonyms':
       return array(
         'number_integer' => 'TextSynonymsBehavior',
         'number_decimal' => 'TextSynonymsBehavior',
@@ -133,6 +169,8 @@ function synonyms_synonyms_behavior_implementation_info($behavior) {
  * Implements hook_form_FORM_ID_alter().
  */
 function synonyms_form_taxonomy_form_vocabulary_alter(&$form, &$form_state) {
+  // TODO: remove this function after a few releases of Synonyms module, since
+  // now the module oversees synonyms of all entities, not only taxonomy terms.
   if (isset($form_state['confirm_delete']) && $form_state['confirm_delete']) {
     return;
   }
@@ -145,99 +183,14 @@ function synonyms_form_taxonomy_form_vocabulary_alter(&$form, &$form_state) {
     '#type' => 'fieldset',
     '#title' => t('Synonyms'),
     '#collapsible' => TRUE,
-    '#tree' => TRUE,
   );
 
-  $behaviors = synonyms_behaviors();
-  $bundle = field_extract_bundle('taxonomy_term', $form['#vocabulary']);
-
-  $form['synonyms']['behaviors'] = array(
-    '#theme' => 'synonyms_behaviors_settings',
-    '#id' => 'synonyms-behaviors-settings-wrapper',
+  $form['synonyms']['link'] = array(
+    '#markup' => t('You can configure synonyms of @vocabulary following <a href="@url">this link</a>.', array(
+      '@vocabulary' => $form['#vocabulary']->name,
+      '@url' => url('admin/structure/synonyms/taxonomy_term/' . $form['#vocabulary']->machine_name, array('query' => drupal_get_destination())),
+    )),
   );
-
-  foreach ($behaviors as $behavior => $behavior_info) {
-    $form['synonyms']['behaviors'][$behavior] = array(
-      '#title' => $behavior_info['title'],
-    );
-
-    $behavior_implementations = synonyms_behavior_get($behavior, 'taxonomy_term', $bundle);
-
-    foreach ($behavior_implementations as $implementation) {
-      $instance = field_info_instance($implementation['entity_type'], $implementation['field_name'], $implementation['bundle']);
-      $form['synonyms']['behaviors'][$behavior][$implementation['instance_id']]['#title'] = $instance['label'];
-
-      if (isset($form_state['values']['synonyms']['behaviors'][$behavior][$implementation['instance_id']])) {
-        $behavior_settings = (bool) $form_state['values']['synonyms']['behaviors'][$behavior][$implementation['instance_id']]['enabled'];
-      }
-      else {
-        $behavior_settings = !is_null($implementation['settings']);
-      }
-      if ($behavior_settings) {
-        if (isset($form_state['values']['synonyms']['behaviors'][$behavior][$implementation['instance_id']]['settings'])) {
-          $behavior_settings = $form_state['values']['synonyms']['behaviors'][$behavior][$implementation['instance_id']]['settings'];
-        }
-        elseif ($implementation['settings']) {
-          $behavior_settings = $implementation['settings'];
-        }
-        else {
-          $behavior_settings = array();
-        }
-      }
-
-      $form['synonyms']['behaviors'][$behavior][$implementation['instance_id']]['enabled'] = array(
-        '#type' => 'checkbox',
-        '#title' => t('Enable'),
-        '#default_value' => $behavior_settings !== FALSE,
-      );
-
-      $settings_form = ctools_plugin_get_function($behavior_info, 'settings form callback');
-      if ($settings_form) {
-        $form['synonyms']['behaviors'][$behavior][$implementation['instance_id']]['enabled']['#ajax'] = array(
-          'callback' => 'synonyms_behaviors_settings_form_ajax',
-          'wrapper' => $form['synonyms']['behaviors']['#id'],
-        );
-
-        if ($behavior_settings !== FALSE) {
-          $form['synonyms']['behaviors'][$behavior][$implementation['instance_id']]['settings'] = $settings_form($form, $form_state, $behavior_settings);
-        }
-      }
-    }
-  }
-  $form['#submit'][] = 'synonyms_taxonomy_form_vocabulary_submit';
-}
-
-/**
- * Submit handler for Taxonomy vocabulary edit form.
- *
- * Store synonyms behavior settings.
- */
-function synonyms_taxonomy_form_vocabulary_submit($form, &$form_state) {
-  $values = $form_state['values'];
-
-  if ($values['op'] == $form['actions']['submit']['#value']) {
-    foreach ($values['synonyms']['behaviors'] as $behavior => $settings) {
-      foreach ($settings as $instance_id => $behavior_settings) {
-        if ($behavior_settings['enabled']) {
-          synonyms_behavior_settings_save(array(
-            'instance_id' => $instance_id,
-            'behavior' => $behavior,
-            'settings' => isset($behavior_settings['settings']) ? $behavior_settings['settings'] : NULL,
-          ));
-        }
-        else {
-          synonyms_behavior_settings_delete($instance_id, $behavior);
-        }
-      }
-    }
-  }
-}
-
-/**
- * Ajax callback function for synonyms behavior settings form.
- */
-function synonyms_behaviors_settings_form_ajax($form, &$form_state) {
-  return $form['synonyms']['behaviors'];
 }
 
 /**
@@ -245,12 +198,12 @@ function synonyms_behaviors_settings_form_ajax($form, &$form_state) {
  */
 function synonyms_field_widget_info() {
   return array(
-    'synonyms_autocomplete' => array(
-      'label' => t('Synonyms friendly autocomplete term widget'),
+    'synonyms_autocomplete_taxonomy_term' => array(
+      'label' => t('Synonyms friendly autocomplete'),
       'field types' => array('taxonomy_term_reference'),
       'settings' => array(
         'size' => 60,
-        'synonyms_autocomplete_path' => 'synonyms/autocomplete',
+        'synonyms_autocomplete_path' => 'synonyms/autocomplete-taxonomy-term',
         'suggestion_size' => 10,
         'suggest_only_unique' => FALSE,
         'auto_creation' => 1,
@@ -259,7 +212,21 @@ function synonyms_field_widget_info() {
         'multiple values' => FIELD_BEHAVIOR_CUSTOM,
       ),
     ),
-    'synonyms_select' => array(
+    'synonyms_autocomplete_entity' => array(
+      'label' => t('Synonyms friendly autocomplete'),
+      'field types' => array('entityreference'),
+      'settings' => array(
+        'size' => 60,
+        'synonyms_autocomplete_path' => 'synonyms/autocomplete-entity',
+        'suggestion_size' => 10,
+        'suggest_only_unique' => FALSE,
+        'auto_creation' => 1,
+      ),
+      'behaviors' => array(
+        'multiple values' => FIELD_BEHAVIOR_CUSTOM,
+      ),
+    ),
+    'synonyms_select_taxonomy_term' => array(
       'label' => t('Synonyms friendly select list'),
       'field types' => array('taxonomy_term_reference'),
       'settings' => array(
@@ -269,6 +236,14 @@ function synonyms_field_widget_info() {
         'multiple values' => FIELD_BEHAVIOR_CUSTOM,
       ),
     ),
+    'synonyms_select_entity' => array(
+      'label' => t('Synonyms friendly select list'),
+      'field types' => array('entityreference'),
+      'settings' => array(),
+      'behaviors' => array(
+        'multiple values' => FIELD_BEHAVIOR_CUSTOM,
+      ),
+    ),
   );
 }
 
@@ -282,7 +257,8 @@ function synonyms_field_widget_settings_form($field, $instance) {
   $form = array();
 
   switch  ($widget['type']) {
-    case 'synonyms_autocomplete':
+    case 'synonyms_autocomplete_taxonomy_term':
+    case 'synonyms_autocomplete_entity':
       $form['auto_creation'] = array(
         '#type' => 'checkbox',
         '#title' => t('Allow auto-creation?'),
@@ -307,7 +283,7 @@ function synonyms_field_widget_settings_form($field, $instance) {
       );
       break;
 
-    case 'synonyms_select':
+    case 'synonyms_select_taxonomy_term':
       $form['sort'] = array(
         '#type' => 'radios',
         '#title' => t('Sort'),
@@ -329,21 +305,48 @@ function synonyms_field_widget_settings_form($field, $instance) {
  */
 function synonyms_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
   $default_value = array();
+  $column = array_keys($field['columns']);
+  $column = reset($column);
   foreach ($items as $item) {
-    $default_value[] = $item['tid'];
+    $default_value[] = $item[$column];
   }
 
   switch ($instance['widget']['type']) {
-    case 'synonyms_autocomplete':
-      $tags = taxonomy_term_load_multiple($default_value);
+    case 'synonyms_autocomplete_taxonomy_term':
+    case 'synonyms_autocomplete_entity':
+      switch ($instance['widget']['type']) {
+        case 'synonyms_autocomplete_taxonomy_term':
+          $default_value_string = taxonomy_implode_tags(taxonomy_term_load_multiple($default_value));
+          $element_validate = array('taxonomy_autocomplete_validate', 'synonyms_autocomplete_taxonomy_term_validate');
+          break;
+
+        case 'synonyms_autocomplete_entity':
+          $default_value_string = array();
+          $entity = isset($element['#entity']) ? $element['#entity'] : NULL;
+          $handler = entityreference_get_selection_handler($field, $instance, $instance['entity_type'], $entity);
+
+          $target_entities = entity_load($field['settings']['target_type'], $default_value);
+          foreach ($target_entities as $target_entity_id => $target_entity) {
+            $label = $handler->getLabel($target_entity);
+            // Labels containing commas or quotes must be wrapped in quotes.
+            if (strpos($label, ',') !== FALSE || strpos($label, '"') !== FALSE) {
+              $label = '"' . str_replace('"', '""', $label) . '"';
+            }
+            $default_value_string[] = $label;
+          }
+          $default_value_string = implode(', ', $default_value_string);
+
+          $element_validate = array('synonyms_autocomplete_entity_validate');
+          break;
+      }
 
       $element += array(
         '#type' => 'textfield',
-        '#default_value' => taxonomy_implode_tags($tags),
+        '#default_value' => $default_value_string,
         '#autocomplete_path' => $instance['widget']['settings']['synonyms_autocomplete_path'] . '/' . $field['field_name'] . '/' . $instance['entity_type'] . '/' . $instance['bundle'],
         '#size' => $instance['widget']['settings']['size'],
         '#maxlength' => 1024,
-        '#element_validate' => array('taxonomy_autocomplete_validate', 'synonyms_autocomplete_validate'),
+        '#element_validate' => $element_validate,
         '#auto_creation' => $instance['widget']['settings']['auto_creation'],
         '#attached' => array(
           'js' => array(
@@ -356,7 +359,7 @@ function synonyms_field_widget_form(&$form, &$form_state, $field, $instance, $la
       );
       break;
 
-    case 'synonyms_select':
+    case 'synonyms_select_taxonomy_term':
       $multiple = $field['cardinality'] > 1 || $field['cardinality'] == FIELD_CARDINALITY_UNLIMITED;
 
       $options = array();
@@ -367,10 +370,10 @@ function synonyms_field_widget_form(&$form, &$form_state, $field, $instance, $la
               if ($terms = taxonomy_get_tree($vocabulary->vid, $tree['parent'], NULL, TRUE)) {
                 $behavior_implementations = synonyms_behavior_get('select', 'taxonomy_term', field_extract_bundle('taxonomy_term', $vocabulary), TRUE);
                 foreach ($terms as $term) {
-                  $options[] = synonyms_select_option($term);
+                  $options[] = synonyms_select_option_taxonomy_term($term);
                   foreach ($behavior_implementations as $implementation) {
                     foreach (synonyms_extract_synonyms($term, $implementation) as $synonym) {
-                      $options[] = synonyms_select_option($term, $synonym, $implementation);
+                      $options[] = synonyms_select_option_taxonomy_term($term, $synonym, $implementation);
                     }
                   }
                 }
@@ -385,16 +388,56 @@ function synonyms_field_widget_form(&$form, &$form_state, $field, $instance, $la
         }
       }
 
-      if (!$multiple && !$element['#required']) {
-        $options = array('' => t('- None -')) + $options;
+      $element += array(
+        '#type' => 'select',
+        '#multiple' => $multiple,
+        '#options' => $options,
+        '#default_value' => $default_value,
+        '#element_validate' => array('synonyms_select_form_to_storage'),
+        '#empty_option' => t('- None -'),
+      );
+      break;
+
+    case 'synonyms_select_entity':
+      $multiple = $field['cardinality'] > 1 || $field['cardinality'] == FIELD_CARDINALITY_UNLIMITED;
+
+      $options = entityreference_get_selection_handler($field, $instance, $instance['entity_type'], $element['#entity'])->getReferencableEntities();
+      $synonyms_options = array();
+
+      $target_entity_info = entity_get_info($field['settings']['target_type']);
+      $entity_ids = array();
+      foreach ($options as $bundle_entity_ids) {
+        $entity_ids = array_merge($entity_ids, array_keys($bundle_entity_ids));
+      }
+      $entities = entity_load($field['settings']['target_type'], $entity_ids);
+      foreach ($options as $bundle => $bundle_entity_ids) {
+        $synonyms_options[$target_entity_info['bundles'][$bundle]['label']] = array();
+
+        $behavior_implementations = synonyms_behavior_get('select', $field['settings']['target_type'], $bundle, TRUE);
+
+        foreach ($bundle_entity_ids as $entity_id => $v) {
+          $entity = $entities[$entity_id];
+          $synonyms_options[$target_entity_info['bundles'][$bundle]['label']][] = synonyms_select_option_entity($entity, $field['settings']['target_type']);
+          foreach ($behavior_implementations as $behavior_implementation) {
+            foreach (synonyms_extract_synonyms($entity, $behavior_implementation) as $synonym) {
+              $synonyms_options[$target_entity_info['bundles'][$bundle]['label']][] = synonyms_select_option_entity($entity, $field['settings']['target_type'], $synonym, $behavior_implementation);
+            }
+          }
+        }
+        usort($synonyms_options[$target_entity_info['bundles'][$bundle]['label']], 'synonyms_select_sort_name');
+      }
+
+      if (count($synonyms_options) == 1) {
+        $synonyms_options = reset($synonyms_options);
       }
 
       $element += array(
         '#type' => 'select',
         '#multiple' => $multiple,
-        '#options' => $options,
+        '#options' => $synonyms_options,
         '#default_value' => $default_value,
         '#element_validate' => array('synonyms_select_form_to_storage'),
+        '#empty_option' => t('- None -'),
       );
       break;
   }
@@ -414,7 +457,7 @@ function synonyms_field_widget_error($element, $error, $form, &$form_state) {
  *
  * Handle validation for taxonomy term synonym-friendly autocomplete element.
  */
-function synonyms_autocomplete_validate($element, &$form_state) {
+function synonyms_autocomplete_taxonomy_term_validate($element, &$form_state) {
   // After taxonomy_autocomplete_validate() has finished its job any terms it
   // didn't find have been set for autocreation. We need to:
   // (a) Double-check that those terms are not synonyms.
@@ -428,7 +471,7 @@ function synonyms_autocomplete_validate($element, &$form_state) {
       foreach ($field['settings']['allowed_values'] as $tree) {
         $behavior_implementations = synonyms_behavior_get('autocomplete', 'taxonomy_term', $tree['vocabulary'], TRUE);
         foreach ($behavior_implementations as $behavior_implementation) {
-          $synonyms = synonyms_synonyms_find_behavior(db_and()->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, $term['name']), $behavior_implementation);
+          $synonyms = synonyms_synonyms_find_behavior(db_and()->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, $term['name']), $behavior_implementation);
           foreach ($synonyms as $synonym) {
             $synonym_tid = $synonym->entity_id;
             break(2);
@@ -449,6 +492,42 @@ function synonyms_autocomplete_validate($element, &$form_state) {
 }
 
 /**
+ * Form element validate handler.
+ *
+ * Validate entity reference synonyms friendly autocomplete element.
+ */
+function synonyms_autocomplete_entity_validate($element, &$form_state) {
+  $input = drupal_map_assoc(drupal_explode_tags(drupal_strtolower($element['#value'])));
+  $field = field_info_field($element['#field_name']);
+  $instance = field_info_instance($element['#entity_type'], $field['field_name'], $element['#bundle']);
+  $handler = entityreference_get_selection_handler($field, $instance);
+  $matches = $handler->getReferencableEntities($input, 'IN');
+  $value = array();
+
+  foreach ($matches as $bundle => $entity_ids) {
+    foreach ($entity_ids as $entity_id => $label) {
+      $value[] = array('target_id' => $entity_id);
+      unset($input[drupal_strtolower($label)]);
+    }
+  }
+
+  // TODO:you probably want to extra filter by bundles, if those are known.
+  $behavior_implementations = synonyms_behavior_get('autocomplete', $field['settings']['target_type'], NULL, TRUE);
+  foreach ($behavior_implementations as $implementation) {
+    $condition = db_and();
+    $condition->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, $input, 'IN');
+    foreach (synonyms_synonyms_find_behavior($condition, $implementation) as $synonym) {
+      unset($input[drupal_strtolower($synonym->synonym)]);
+      $value[] = array('target_id' => $synonym->entity_id);
+    }
+  }
+
+  // TODO: decide what to do with auto creation.
+
+  form_set_value($element, $value, $form_state);
+}
+
+/**
  * Try to find a term by its name or synonym.
  *
  * @param string $name
@@ -481,7 +560,7 @@ function synonyms_get_term_by_synonym($name, $vocabulary, $parent = 0) {
   // We have failed to find a term with the provided $name. So let's search now
   // among the term synonyms.
   $bundle = field_extract_bundle('taxonomy_term', $vocabulary);
-  $synonyms = synonyms_synonyms_find(db_and()->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, $name), 'taxonomy_term', $bundle);
+  $synonyms = synonyms_synonyms_find(db_and()->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, $name), 'taxonomy_term', $bundle);
   foreach ($synonyms as $synonym) {
     if (!$parent || synonyms_taxonomy_term_is_child_of($synonym->entity_id, $parent)) {
       // TODO: similarly here, as above, we could have more than 1 match, but
@@ -540,35 +619,35 @@ function synonyms_add_term_by_synonym($name, $vocabulary, $parent = 0) {
 }
 
 /**
- * Retrieve a list of sanitized synonyms of a taxonomy term.
+ * Retrieve list of sanitized synonyms of an entity.
  *
- * @param $item object
- *   Fully loaded taxonomy term
+ * @param $entity object
+ *   Fully loaded entity
  *
  * @return array
- *   List of sanitized synonyms of a taxonomy term
+ *   List of sanitized synonyms of an entity
  */
-function synonyms_get_sanitized($item) {
-  $synonyms = array();
-  foreach (synonyms_get_term_synonyms($item) as $synonym) {
-    $synonyms[] = $synonym['safe_value'];
-  }
-  return $synonyms;
+function synonyms_get_sanitized($entity, array $options, $name, $entity_type, &$context) {
+  return array_map('check_plain', synonyms_get_raw($entity, $options, $name, $entity_type, $context));
 }
 
 /**
- * Retrieve a list of raw synonyms of a taxonomy term.
+ * Retrieve list of raw synonyms of an entity.
  *
- * @param $item object
- *   Fully loaded taxonomy term
+ * @param $entity object
+ *   Fully loaded entity
  *
  * @return array
- *   List of raw synonyms of a taxonomy term
+ *   List of raw synonyms of an entity
  */
-function synonyms_get_raw($item) {
+function synonyms_get_raw($entity, array $options, $name, $entity_type, &$context) {
   $synonyms = array();
-  foreach (synonyms_get_term_synonyms($item) as $synonym) {
-    $synonyms[] = $synonym['value'];
+  $bundle = entity_extract_ids($entity_type, $entity);
+  $bundle = $bundle[2] ? $bundle[2] : $entity_type;
+
+  $behavior_implementations = synonyms_behavior_get_all_enabled($entity_type, $bundle);
+  foreach ($behavior_implementations as $implementation) {
+    $synonyms = array_merge($synonyms, synonyms_extract_synonyms($entity, $implementation));
   }
   return $synonyms;
 }
@@ -596,15 +675,15 @@ function synonyms_get_term_synonyms($term) {
   $vocabulary = taxonomy_vocabulary_load($term->vid);
   $bundle = field_extract_bundle('taxonomy_term', $vocabulary);
 
-  $behavior_implementations = synonyms_behavior_get('synonyms', 'taxonomy_term', $bundle, TRUE);
+  $behavior_implementations = synonyms_behavior_get_all_enabled('taxonomy_term', $bundle);
   foreach ($behavior_implementations as $implementation) {
     foreach  (synonyms_extract_synonyms($term, $implementation) as $synonym) {
-        $synonyms[] = array(
-          'value' => $synonym,
-          'safe_value' => check_plain($synonym),
-        );
-      }
+      $synonyms[] = array(
+        'value' => $synonym,
+        'safe_value' => check_plain($synonym),
+      );
     }
+  }
 
   return $synonyms;
 }
@@ -650,14 +729,13 @@ function synonyms_extract_synonyms($entity, $behavior_implementation) {
  * @param QueryConditionInterface $condition
  *   Object of QueryConditionInterface that specifies conditions by which you
  *   want to find synonyms. When building this condition object, use
- *   AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER as a placeholder for
- *   real column name that contains synonym as text. For example, if you were to
- *   find all entities with synonyms that begin with "synonym-come-here"
- *   substring, case insensitive and replacing all spaces in original synonym
- *   string by a dash sign, then you would have to create the following
- *   condition object:
+ *   AbstractSynonymsBehavior::COLUMN_PLACEHOLDER as a placeholder for real
+ *   column name that contains synonym as text. For example, if you were to find
+ *   all entities with synonyms that begin with "synonym-come-here" substring,
+ *   case insensitive and replacing all spaces in original synonym string by a
+ *   dash sign, then you would have to create the following condition object:
  *   db_and()
- *     ->where("LOWER(REPLACE(" . AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER . ", ' ', '-')) LIKE 'synonym-come-here%'")
+ *     ->where("LOWER(REPLACE(" . AbstractSynonymsBehavior::COLUMN_PLACEHOLDER . ", ' ', '-')) LIKE 'synonym-come-here%'")
  *   And then just supply this object as an input parameter to this function
  * @param string $entity_type
  *   Among synonyms of what entity type to search
@@ -674,7 +752,7 @@ function synonyms_extract_synonyms($entity, $behavior_implementation) {
 function synonyms_synonyms_find(QueryConditionInterface $condition, $entity_type, $bundle) {
   $rows = array();
 
-  $behavior_implementations = synonyms_behavior_get('synonyms', $entity_type, $bundle, TRUE);
+  $behavior_implementations = synonyms_behavior_get_all_enabled($entity_type, $bundle);
   foreach ($behavior_implementations as $behavior_implementation) {
     foreach (synonyms_synonyms_find_behavior($condition, $behavior_implementation) as $row) {
       $rows[] = $row;
@@ -702,14 +780,13 @@ function synonyms_synonyms_find(QueryConditionInterface $condition, $entity_type
  * @param QueryConditionInterface $condition
  *   Object of QueryConditionInterface that specifies conditions by which you
  *   want to find synonyms. When building this condition object, use
- *   AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER as a placeholder for
- *   real column name that contains synonym as text. For example, if you were to
- *   find all entities with synonyms that begin with "synonym-come-here"
- *   substring, case insensitive and replacing all spaces in original synonym
- *   string by a dash sign, then you would have to create the following
- *   condition object:
+ *   AbstractSynonymsBehavior::COLUMN_PLACEHOLDER as a placeholder for real
+ *   column name that contains synonym as text. For example, if you were to find
+ *   all entities with synonyms that begin with "synonym-come-here" substring,
+ *   case insensitive and replacing all spaces in original synonym string by a
+ *   dash sign, then you would have to create the following condition object:
  *   db_and()
- *     ->where("LOWER(REPLACE(" . AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER . ", ' ', '-')) LIKE 'synonym-come-here%'")
+ *     ->where("LOWER(REPLACE(" . AbstractSynonymsBehavior::COLUMN_PLACEHOLDER . ", ' ', '-')) LIKE 'synonym-come-here%'")
  *   And then just supply this object as an input parameter to this function
  * @param array $behavior_implementation
  *   Fully loaded behavior implementation. Supply here one of the values from
@@ -759,27 +836,23 @@ function synonyms_synonyms_find_behavior(QueryConditionInterface $condition, $be
  *   Whether synonym has been successfully added
  */
 function synonyms_add_entity_as_synonym($trunk_entity, $trunk_entity_type, $field, $synonym_entity, $synonym_entity_type) {
-  if ($trunk_entity_type != 'taxonomy_term') {
-    // Currently synonyms module only operates on taxonomy terms.
-    return FALSE;
-  }
-
   $bundle = entity_extract_ids($trunk_entity_type, $trunk_entity);
-  $bundle = $bundle[2];
-  $behavior_implementations = synonyms_behavior_get('synonyms', $trunk_entity_type, $bundle, TRUE);
+  $bundle = $bundle[2] ? $bundle[2] : $trunk_entity_type;
+  $behavior_implementations = synonyms_behavior_get_all_enabled($trunk_entity_type, $bundle, $field);
 
   $field = field_info_field($field);
   $instance = field_info_instance($trunk_entity_type, $field['field_name'], $bundle);
-  if (!isset($behavior_implementations[$instance['id']])) {
-    // $field either doesn't exist in the $trunk_entity or it does not have
-    // enabled the behavior of synonyms.
+  if (empty($behavior_implementations)) {
+    // $field either doesn't exist in the $trunk_entity or it does not have any
+    // enabled behavior.
     return FALSE;
   }
 
   $items = field_get_items($trunk_entity_type, $trunk_entity, $field['field_name']);
   $items = is_array($items) ? $items : array();
 
-  $object = synonyms_behavior_implementation_class('synonyms', $field);
+  $behavior_implementation = reset($behavior_implementations);
+  $object = synonyms_behavior_implementation_class($behavior_implementation['behavior'], $field);
   $object = new $object();
   $extra_items = $object->mergeEntityAsSynonym($items, $field, $instance, $synonym_entity, $synonym_entity_type);
 
@@ -805,9 +878,8 @@ function synonyms_add_entity_as_synonym($trunk_entity, $trunk_entity_type, $fiel
   $items = array_values($unique_items);
 
   $trunk_entity->{$field['field_name']}[LANGUAGE_NONE] = $items;
-  // In future if this module eventually becomes a gateway for synonyms for any
-  // entity types, we'll substitute it with entity_save().
-  taxonomy_term_save($trunk_entity);
+
+  entity_save($trunk_entity_type, $trunk_entity);
   return TRUE;
 }
 
@@ -831,7 +903,7 @@ function synonyms_add_entity_as_synonym($trunk_entity, $trunk_entity_type, $fiel
 function synonyms_synonyms_fields($vocabulary) {
   $fields = array();
   $bundle = field_extract_bundle('taxonomy_term', $vocabulary);
-  $behavior_implementations = synonyms_behavior_get('synonyms', 'taxonomy_term', $bundle, TRUE);
+  $behavior_implementations = synonyms_behavior_get_all_enabled('taxonomy_term', $bundle);
   foreach ($behavior_implementations as $v) {
     $fields[] = $v['field_name'];
   }
@@ -920,6 +992,56 @@ function synonyms_behavior_get($behavior, $entity_type = NULL, $bundle = NULL, $
 }
 
 /**
+ * Load all enabled behaviors on an entity_type and a bundle.
+ *
+ * This is useful when you want to do some operation on all enabled synonyms
+ * behaviors for a specific entity_type and a bundle.
+ *
+ * @param string $entity_type
+ *   Entity type whose enabled behaviors should be loaded
+ * @param string $bundle
+ *   Bundle whose enabled behaviors should be loaded
+ * @param string $field_name
+ *   Optional filter to only return enabled synonyms behaviors of a specific
+ *   field
+ *
+ * @return array
+ *   Array of enabled behaviors for a provided entity type and a bundle. Each
+ *   sub array will have the following structure:
+ *   - behavior: (string) Name of the synonyms behavior
+ *   - settings: (mixed) Behavior settings, its internal structure depends on
+ *     the type of behavior.
+ *   - entity_type: (string) Entity type to which this behavior implementation
+ *     applies
+ *   - bundle: (string) Bundle name to which this behavior implementation
+ *     applies
+ *   - field_name: (string) Name of the field on which this synonyms behavior is
+ *     enabled
+ *   - instance_id: (int) ID of the field instance to which this behavior
+ *     implementation applies
+ */
+function synonyms_behavior_get_all_enabled($entity_type, $bundle, $field_name = NULL) {
+  $query = db_select('synonyms_settings', 's');
+  $instance_alias = $query->innerJoin('field_config_instance', 'i', 'i.id = s.instance_id');
+  $query->fields($instance_alias, array('field_name', 'entity_type', 'bundle'));
+  $query->fields('s', array('behavior', 'settings_serialized'));
+  $query->addField($instance_alias, 'id', 'instance_id');
+
+  $query->condition($instance_alias . '.entity_type', $entity_type);
+  $query->condition($instance_alias . '.bundle', $bundle);
+  if ($field_name) {
+    $query->condition($instance_alias . '.field_name', $field_name);
+  }
+
+  $result = $query->execute();
+  $rows = array();
+  foreach ($result as $row) {
+    $rows[] = (array) $row;
+  }
+  return synonyms_behavior_settings_unpack($rows);
+}
+
+/**
  * Retrieve information about all ctools plugins of type 'synonyms behavior'.
  *
  * @return array
@@ -1088,23 +1210,24 @@ function synonyms_select_form_to_storage($element, &$form_state) {
   }
 
   foreach ($value as $k => $v) {
-    // For the cases when a synonym was selected and not a term option, we
+    // For the cases when a synonym was selected and not an entity option, we
     // process the selected values stripping everything that goes after
     // semicolon.
     if (!is_numeric($v)) {
-      $tid = explode(':', $v);
-      $value[$k] = $tid[0];
+      $id = explode(':', $v);
+      $value[$k] = $id[0];
     }
   }
 
-  // The user also might have selected multiple times the same term, given that
-  // a term can be represented by more than 1 option (a term and its synonym),
-  // then it's possible in theory, so we should be ready for this scenario.
+  // The user also might have selected multiple times the same entity, given
+  // that an entity can be represented by more than 1 option (an entity and its
+  // synonym), then it's possible in theory, so we should be ready for this
+  // scenario.
   $value = array_unique($value);
 
   $form_state_value = array();
-  foreach ($value as $tid) {
-    $form_state_value[] = array('tid' => $tid);
+  foreach ($value as $id) {
+    $form_state_value[] = array($element['#columns'][0] => $id);
   }
 
   form_set_value($element, $form_state_value, $form_state);
@@ -1141,7 +1264,7 @@ function synonyms_taxonomy_term_is_child_of($tid, $parent_tid) {
 }
 
 /**
- * Format an option for select form element.
+ * Format an option for taxonomy term select form element.
  *
  * @param object $term
  *   Fully loaded taxonomy term which is represented by this option
@@ -1152,18 +1275,13 @@ function synonyms_taxonomy_term_is_child_of($tid, $parent_tid) {
  *   Behavior implementation array from which the $synonym comes from
  *
  * @return object
- *   An option for select form element
+ *   An option for taxonomy term select form element
  */
-function synonyms_select_option($term, $synonym = NULL, $behavior_implementation = NULL) {
+function synonyms_select_option_taxonomy_term($term, $synonym = NULL, $behavior_implementation = NULL) {
   $key = $synonym ? $term->tid . ':' . drupal_html_class($synonym) : $term->tid;
   $wording = $term->name;
   if ($synonym) {
-    $instance = field_info_instance($behavior_implementation['entity_type'], $behavior_implementation['field_name'], $behavior_implementation['bundle']);
-    $wording = format_string($behavior_implementation['settings']['wording'], array(
-      '@synonym' => $synonym,
-      '@term' => $term->name,
-      '@field_name' => drupal_strtolower($instance['label']),
-    ));
+    $wording = synonyms_select_option_wording($term, $synonym, $behavior_implementation);
   }
   return (object) array(
     'option' => array($key => str_repeat('-', $term->depth) . $wording),
@@ -1171,6 +1289,44 @@ function synonyms_select_option($term, $synonym = NULL, $behavior_implementation
 }
 
 /**
+ * Format an option for entity reference select form element.
+ *
+ * @param object $entity
+ *   Fully loaded entity which is represented by this option
+ * @param string $entity_type
+ *   Entity type of the $entity object
+ * @param string $synonym
+ *   If the provided entity is represented in this option by a synonym, then
+ *   provide it here
+ * @param array $behavior_implementation
+ *   Behavior implementation array from which the $synonym comes from
+ *
+ * @return object
+ *   An option for entity reference select form element
+ */
+function synonyms_select_option_entity($entity, $entity_type, $synonym = NULL, $behavior_implementation = NULL) {
+  $entity_id = entity_extract_ids($entity_type, $entity);
+  $entity_id = $entity_id[0];
+  $key = $synonym ? $entity_id . ':' . drupal_html_class($synonym) : $entity_id;
+  $wording = entity_label($entity_type, $entity);
+  if ($synonym) {
+    $wording = synonyms_select_option_wording($entity, $synonym, $behavior_implementation);
+  }
+  return (object) array(
+    'option' => array($key => $wording),
+  );
+}
+
+function synonyms_select_option_wording($entity, $synonym, $behavior_implementation) {
+  $instance = field_info_instance($behavior_implementation['entity_type'], $behavior_implementation['field_name'], $behavior_implementation['bundle']);
+  return format_string($behavior_implementation['settings']['wording'], array(
+    '@synonym' => $synonym,
+    '@entity' => entity_label($behavior_implementation['entity_type'], $entity),
+    '@field_name' => drupal_strtolower($instance['label']),
+  ));
+}
+
+/**
  * Supportive function to build options array with sorting by name logic.
  *
  * The function starts from the 0-depth level and starts to recursively build
@@ -1209,10 +1365,10 @@ function synonyms_select_sort_name_options_recursive($vocabulary, $parent = 0, $
     $options = array();
     foreach ($terms as $term) {
       $term->depth = $depth;
-      $options[] = synonyms_select_option($term);
+      $options[] = synonyms_select_option_taxonomy_term($term);
       foreach ($behavior_implementations[$bundle] as $implementation) {
         foreach (synonyms_extract_synonyms($term, $implementation) as $synonym) {
-          $options[] = synonyms_select_option($term, $synonym, $implementation);
+          $options[] = synonyms_select_option_taxonomy_term($term, $synonym, $implementation);
         }
       }
     }
@@ -1244,3 +1400,70 @@ function synonyms_select_sort_name_options_recursive($vocabulary, $parent = 0, $
 function synonyms_select_sort_name($a, $b) {
   return strcasecmp(reset($a->option), reset($b->option));
 }
+
+/**
+ * Test if entity type is applicable for having synonyms.
+ *
+ * Only fieldable entity types can have synonyms for the very reason that
+ * synonyms are stored in fields.
+ *
+ * @param string $entity_type
+ *   Entity type to test
+ *
+ * @return bool|string
+ *   Whether the provided entity type is applicable for having synonyms. If it
+ *   is applicable, the $entity_type input argument will be returned. Otherwise
+ *   FALSE is returned
+ */
+function synonyms_entity_type_load($entity_type) {
+  $entity_info = entity_get_info($entity_type);
+  if ($entity_info && $entity_info['fieldable']) {
+    return $entity_type;
+  }
+  return FALSE;
+}
+
+/**
+ * Test if provided entity type and bundle exist.
+ *
+ * @param string $bundle
+ *   Bundle name to test for existence
+ * @param string $entity_type
+ *   Entity type to test for existence
+ *
+ * @return bool|string
+ *   Whether the provided entity type and bundle exist. If they exist, the
+ *   $bundle input argument is returned. Otherwise FALSE is returned
+ */
+function synonyms_bundle_load($bundle, $entity_type) {
+  $entity_info = entity_get_info($entity_type);
+  if ($entity_info && isset($entity_info['bundles'][$bundle])) {
+    return $bundle;
+  }
+  return FALSE;
+}
+
+/**
+ * Menu title callback function for synonyms settings page.
+ *
+ * @param string $entity_type
+ *   Entity type whose synonyms settings are managed
+ * @param string $bundle
+ *   Bundle whose synonyms settings are managed
+ *
+ * @return string
+ *   Title of the synonyms settings page
+ */
+function synonyms_settings_title($entity_type, $bundle) {
+  $entity_info = entity_get_info($entity_type);
+  $entity_label = isset($entity_info['plural label']) ? $entity_info['plural label'] : $entity_info['label'];
+  if ($entity_type == $bundle) {
+    return t('Synonyms settings of @entity_type', array(
+      '@entity_type' => $entity_label,
+    ));
+  }
+  return t('Synonyms settings of @bundle @entity_type', array(
+    '@bundle' => $entity_info['bundles'][$bundle]['label'],
+    '@entity_type' => $entity_label,
+  ));
+}
diff --git a/synonyms.pages.inc b/synonyms.pages.inc
index 04e6ec2..8355f9b 100644
--- a/synonyms.pages.inc
+++ b/synonyms.pages.inc
@@ -26,7 +26,7 @@
  *   autocomplete form element. Only the last term is used for autocompletion.
  *   Defaults to '' (an empty string).
  */
-function synonyms_autocomplete($field_name, $entity_type, $bundle, $tags_typed = '') {
+function synonyms_autocomplete_taxonomy_term($field_name, $entity_type, $bundle, $tags_typed = '') {
   // If the request has a '/' in the search text, then the menu system will have
   // split it into multiple arguments, recover the intended $tags_typed.
   $args = func_get_args();
@@ -56,7 +56,7 @@ function synonyms_autocomplete($field_name, $entity_type, $bundle, $tags_typed =
     exit;
   }
 
-  $widget = $instance['widget']['type'] == 'synonyms_autocomplete' ? $instance['widget']['settings'] : field_info_widget_settings('synonyms_autocomplete');
+  $widget = $instance['widget']['type'] == 'synonyms_autocomplete_taxonomy_term' ? $instance['widget']['settings'] : field_info_widget_settings('synonyms_autocomplete_taxonomy_term');
 
   // How many suggestions maximum we are able to output.
   $max_suggestions = $widget['suggestion_size'];
@@ -81,7 +81,12 @@ function synonyms_autocomplete($field_name, $entity_type, $bundle, $tags_typed =
     }
   }
 
-  $term_matches = array();
+  // Array of found suggestions. Each subarray of this array will represent a
+  // single suggestion entry. The sub array must contain the following keys:
+  // - tid: (int) tid of the suggested term
+  // - name: (string) name of the suggested term
+  // - wording: (string) human friendly XSS escaped text of the suggestion entry
+  $tags_return = array();
   if ($tag_last != '') {
     // Part of the criteria for the query come from the field's own settings.
     $vocabularies = array();
@@ -91,14 +96,6 @@ function synonyms_autocomplete($field_name, $entity_type, $bundle, $tags_typed =
     }
     $vocabularies = taxonomy_vocabulary_load_multiple(array_keys($vocabularies));
 
-    // Array of found suggestions. Each subarray of this array will represent
-    // a single suggestion entry. The sub array must contain the following keys:
-    // - tid: (int) tid of the suggested term
-    // - name: (string) name of the suggested term
-    // - wording: (string) human friendly XSS escaped text of the suggestion
-    //   entry
-    $tags_return = array();
-
     // Firstly getting a list of tids that match by $term->name.
     $query = db_select('taxonomy_term_data', 't');
     $query->addTag('translatable');
@@ -129,7 +126,7 @@ function synonyms_autocomplete($field_name, $entity_type, $bundle, $tags_typed =
       $behavior_implementations = synonyms_behavior_get('autocomplete', 'taxonomy_term', $bundle, TRUE);
       foreach ($behavior_implementations as $implementation) {
         $condition = db_and();
-        $condition->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, '%' . db_like($tag_last) . '%', 'LIKE');
+        $condition->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, '%' . db_like($tag_last) . '%', 'LIKE');
 
         if (!empty($tags_typed_tids)) {
           $condition->condition('entity_id', $tags_typed_tids, 'NOT IN');
@@ -178,26 +175,186 @@ function synonyms_autocomplete($field_name, $entity_type, $bundle, $tags_typed =
         }
       }
     }
-    $prefix = empty($tags_typed) ? '' : drupal_implode_tags($tags_typed) . ', ';
-
     if (count($tags_return) > $max_suggestions) {
       $tags_return = array_slice($tags_return, 0, $max_suggestions);
     }
+  }
+  $prefix = empty($tags_typed) ? '' : drupal_implode_tags($tags_typed) . ', ';
+  drupal_json_output(synonyms_autocomplete_format($tags_return, $prefix));
+}
+
+/**
+ * Page callback: Outputs JSON for entity autocomplete suggestions.
+ *
+ * This callback outputs entity name suggestions in response to Ajax requests
+ * made by the synonyms autocomplete widget for entity reference fields. The
+ * output is a JSON object of plain-text entity suggestions, keyed by the
+ * user-entered value with the completed entity name appended. Entity names
+ * containing commas are wrapped in quotes. The search is made with
+ * consideration of synonyms.
+ *
+ * @param string $field_name
+ *   The name of the entity reference field.
+ * @param string $entity_type
+ *   Entity type to which the supplied $field_name is attached to
+ * @param string $bundle
+ *   Bundle name to which the supplied $field_name is attached to
+ * @param string $tags_typed
+ *   (optional) A comma-separated list of entity names entered in the
+ *   autocomplete form element. Only the last term is used for autocompletion.
+ *   Defaults to '' (an empty string).
+ */
+function synonyms_autocomplete_entity($field_name, $entity_type, $bundle, $tags_typed = '') {
+  // If the request has a '/' in the search text, then the menu system will have
+  // split it into multiple arguments, recover the intended $tags_typed.
+  $args = func_get_args();
+  // Shift off the $field_name argument.
+  array_shift($args);
+  // Shift off the $entity_type argument.
+  array_shift($args);
+  // Shift off the $bundle argument.
+  array_shift($args);
+  $tags_typed = implode('/', $args);
+
+  if (!($field = field_info_field($field_name)) || $field['type'] != 'entityreference') {
+    print t('Entity reference field @field_name not found.', array('@field_name' => $field_name));
+    exit;
+  }
+
+  if (!($instance = field_info_instance($entity_type, $field['field_name'], $bundle))) {
+    // Error string. The JavaScript handler will realize this is not JSON and
+    // will display it as debugging information.
+    print t('There was not found an instance of @field_name in @entity_type.', array(
+      '@field_name' => $field_name,
+      '@entity_type' => $entity_type,
+    ));
+    exit;
+  }
+
+  $widget = $instance['widget']['type'] == 'synonyms_autocomplete_entity' ? $instance['widget']['settings'] : field_info_widget_settings('synonyms_autocomplete_entity');
+
+  // How many suggestions maximum we are able to output.
+  $max_suggestions = $widget['suggestion_size'];
+
+  // Whether we are allowed to suggest more than one entry per term, shall that
+  // entry be either term name itself or one of its synonyms.
+  $suggest_only_unique = $widget['suggest_only_unique'];
+
+  $tags_typed = drupal_explode_tags($tags_typed);
+  $tag_last = drupal_strtolower(array_pop($tags_typed));
+  $prefix = count($tags_typed) ? drupal_implode_tags($tags_typed) . ', ' : '';
+
+  $handler = entityreference_get_selection_handler($field, $instance, $entity_type, NULL);
+
+  $tags_typed_entity_ids = array();
+  if (!empty($tags_typed)) {
+    foreach ($handler->getReferencableEntities($tags_typed, 'IN') as $target_entity_ids) {
+      $tags_typed_entity_ids = array_merge($tags_typed_entity_ids, array_keys($target_entity_ids));
+    }
+  }
+
+  $matches = array();
+  if ($tag_last) {
+    foreach ($handler->getReferencableEntities($tag_last) as $target_entity_ids) {
+      foreach (array_diff_key($target_entity_ids, drupal_map_assoc($tags_typed_entity_ids)) as $target_id => $label) {
+        $matches[] = array(
+          'target_id' => $target_id,
+          'wording' => $label,
+          'name' => $label,
+        );
+        if (count($matches) >= $max_suggestions) {
+          break (2);
+        }
+      }
+    }
+
+    if (count($matches) < $max_suggestions) {
+      $behavior_implementations = synonyms_behavior_get('autocomplete', $field['settings']['target_type'], NULL, TRUE);
+      foreach ($behavior_implementations as $implementation) {
+        $condition = db_and();
+        $condition->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, '%' . db_like($tag_last) . '%', 'LIKE');
+
+        if (!empty($tags_typed_entity_ids)) {
+          $condition->condition('entity_id', $tags_typed_entity_ids, 'NOT IN');
+        }
+        if ($suggest_only_unique && !empty($matches)) {
+          $tmp = array();
+          foreach ($matches as $match) {
+            $tmp[] = $match['target_id'];
+          }
+          $condition->condition('entity_id', $tmp, 'NOT IN');
+        }
+
+        $new_target_ids = array();
+        foreach (synonyms_synonyms_find_behavior($condition, $implementation) as $synonym) {
+          if (!$suggest_only_unique || !in_array($synonym->entity_id, $new_target_ids)) {
+            $matches[] = array(
+              'target_id' => $synonym->entity_id,
+              'synonym' => $synonym->synonym,
+              'implementation' => $implementation,
+            );
+            $new_target_ids[] = $synonym->entity_id;
+            if (count($matches) >= $max_suggestions) {
+              break (2);
+            }
+          }
+        }
+      }
+    }
 
-    // Now formatting the results.
-    foreach ($tags_return as $info) {
-      $n = $info['name'];
-      // Term names containing commas or quotes must be wrapped in quotes.
-      if (strpos($info['name'], ',') !== FALSE || strpos($info['name'], '"') !== FALSE) {
-        $n = '"' . str_replace('"', '""', $info['name']) . '"';
+    $synonym_entities = array();
+    foreach ($matches as $match) {
+      if (!isset($match['wording']) && isset($match['synonym'])) {
+        $synonym_entities[] = $match['target_id'];
       }
-      while (isset($term_matches[$prefix . $n])) {
-        $n .= ' ';
+    }
+    if (!empty($synonym_entities)) {
+      $synonym_entities = entity_load($field['settings']['target_type'], $synonym_entities);
+      foreach ($matches as &$match) {
+        if (!isset($match['wording']) && isset($match['synonym'])) {
+          $instance = synonyms_instance_id_load($match['implementation']['instance_id']);
+          $label = entity_label($field['settings']['target_type'], $synonym_entities[$match['target_id']]);
+          $match['name'] = $label;
+          $match['wording'] = format_string(filter_xss($match['implementation']['settings']['wording']), array(
+            '@entity' => $label,
+            '@synonym' => $match['synonym'],
+            '@field_name' => drupal_strtolower($instance['label']),
+          ));
+        }
       }
-      $term_matches[$prefix . $n] = $info['wording'];
     }
   }
-  drupal_json_output($term_matches);
+
+  drupal_json_output(synonyms_autocomplete_format($matches, $prefix));
+}
+
+/**
+ * Supportive function to format autocomplete suggestions.
+ *
+ * @param array $matches
+ *   Array of matches entries. It should follow this structure:
+ *   - name: (string) String to be inserted into autocomplete textfield if user
+ *     chooses this autocomplete entry
+ *   - wording: (string) String to show in the autocomplete suggestion entry
+ * @param string $prefix
+ *   Any prefix to be appended to 'name' property of $matches array when
+ *   inserting into the autocomplete textfield. Normally it is the already
+ *   entered entries in the textfield
+ */
+function synonyms_autocomplete_format($matches, $prefix) {
+  $output = array();
+  foreach ($matches as $match) {
+    $n = $match['name'];
+    // Names containing commas or quotes must be wrapped in quotes.
+    if (strpos($match['name'], ',') !== FALSE || strpos($match['name'], '"') !== FALSE) {
+      $n = '"' . str_replace('"', '""', $match['name']) . '"';
+    }
+    while (isset($output[$prefix . $n])) {
+      $n .= ' ';
+    }
+    $output[$prefix . $n] = $match['wording'];
+  }
+  return $output;
 }
 
 /**
@@ -238,3 +395,137 @@ function theme_synonyms_behaviors_settings($variables) {
 
   return '<div id="' . $element['#id'] . '">' . theme('table', $table) . drupal_render_children($element) . '</div>';
 }
+
+function synonyms_settings_overview() {
+  $output = array();
+
+  $output['table'] = array(
+    '#theme' => 'table',
+    '#header' => array(t('Entity type'), t('Bundle'), t('Manage')),
+    '#rows' => array(),
+  );
+
+  foreach (entity_get_info() as $entity_type => $entity_info) {
+    if (synonyms_entity_type_load($entity_type)) {
+      foreach ($entity_info['bundles'] as $bundle => $bundle_info) {
+        $output['table']['#rows'][] = array(
+          $entity_info['label'],
+          $bundle == $entity_type ? '' : $bundle_info['label'],
+          l(t('Edit'), 'admin/structure/synonyms/' . $entity_type . '/' . $bundle),
+        );
+      }
+    }
+  }
+
+  return $output;
+}
+
+/**
+ * Synonyms settings form for a specific entity type and bundle name.
+ *
+ * @param string $entity_type
+ *   Entity type for which to generate synonyms settings form
+ * @param string $bundle
+ *   Bundle name for which to generate synonyms settings form
+ */
+function synonyms_settings_form($form, &$form_state, $entity_type, $bundle) {
+  $form['settings'] = array(
+    '#tree' => TRUE,
+    '#theme' => 'synonyms_behaviors_settings',
+    '#id' => 'synonyms-behaviors-settings-wrapper',
+  );
+
+  $behaviors = synonyms_behaviors();
+
+  foreach ($behaviors as $behavior => $behavior_info) {
+    $form['settings'][$behavior] = array(
+      '#title' => $behavior_info['title'],
+    );
+
+    $behavior_implementations = synonyms_behavior_get($behavior, $entity_type, $bundle);
+
+    foreach ($behavior_implementations as $implementation) {
+      $instance = field_info_instance($implementation['entity_type'], $implementation['field_name'], $implementation['bundle']);
+      $form['settings'][$behavior][$implementation['instance_id']]['#title'] = $instance['label'];
+
+      if (isset($form_state['values']['settings'][$behavior][$implementation['instance_id']])) {
+        $behavior_settings = (bool) $form_state['values']['settings'][$behavior][$implementation['instance_id']]['enabled'];
+      }
+      else {
+        $behavior_settings = !is_null($implementation['settings']);
+      }
+
+      if ($behavior_settings) {
+        if (isset($form_state['values']['settings'][$behavior][$implementation['instance_id']]['settings'])) {
+          $behavior_settings = $form_state['values']['settings'][$behavior][$implementation['instance_id']]['settings'];
+        }
+        elseif ($implementation['settings']) {
+          $behavior_settings = $implementation['settings'];
+        }
+        else {
+          $behavior_settings = array();
+        }
+      }
+
+      $form['settings'][$behavior][$implementation['instance_id']]['enabled'] = array(
+        '#type' => 'checkbox',
+        '#title' => t('Enable'),
+        '#default_value' => $behavior_settings !== FALSE,
+      );
+
+      $settings_form = ctools_plugin_get_function($behavior_info, 'settings form callback');
+      if ($settings_form) {
+        $form['settings'][$behavior][$implementation['instance_id']]['enabled']['#ajax'] = array(
+          'callback' => 'synonyms_settings_form_ajax',
+          'wrapper' => $form['settings']['#id'],
+        );
+
+        if ($behavior_settings !== FALSE) {
+          $form['settings'][$behavior][$implementation['instance_id']]['settings'] = $settings_form($form, $form_state, $behavior_settings);
+        }
+      }
+    }
+  }
+
+  $form['actions'] = array(
+    '#type' => '#actions',
+  );
+
+  $form['actions']['submit'] = array(
+    '#type' => 'submit',
+    '#value' => t('Save'),
+  );
+
+  return $form;
+}
+
+/**
+ * Submit handler for 'synonyms_settings_form' form.
+ *
+ * Store synonyms behavior settings.
+ */
+function synonyms_settings_form_submit($form, &$form_state) {
+  foreach ($form_state['values']['settings'] as $behavior => $settings) {
+    foreach ($settings as $instance_id => $behavior_settings) {
+      if ($behavior_settings['enabled']) {
+        synonyms_behavior_settings_save(array(
+          'instance_id' => $instance_id,
+          'behavior' => $behavior,
+          'settings' => isset($behavior_settings['settings']) ? $behavior_settings['settings'] : NULL,
+        ));
+      }
+      else {
+        synonyms_behavior_settings_delete($instance_id, $behavior);
+      }
+    }
+  }
+  drupal_set_message(t('Synonyms settings have been successfully saved.'));
+  $form_state['redirect'] = array('admin/structure/synonyms');
+}
+
+/**
+ * Ajax callback function for synonyms settings form.
+ */
+function synonyms_settings_form_ajax($form, &$form_state) {
+  return $form['settings'];
+}
diff --git a/synonyms.test b/synonyms.test
index 296929a..cae1a91 100644
--- a/synonyms.test
+++ b/synonyms.test
@@ -76,7 +76,7 @@ abstract class SynonymsWebTestCase extends DrupalWebTestCase {
    * SetUp method.
    */
   public function setUp($modules = array()) {
-    $modules[] = 'synonyms';
+    array_unshift($modules, 'synonyms');
     parent::setUp($modules);
 
     $this->admin = $this->drupalCreateUser(array(
@@ -140,7 +140,7 @@ abstract class SynonymsWebTestCase extends DrupalWebTestCase {
  */
 class SynonymsSynonymsWebTestCase extends SynonymsWebTestCase {
 
-  protected $behavior = 'synonyms';
+  protected $behavior = 'autocomplete';
 
   /**
    * GetInfo method.
@@ -235,11 +235,11 @@ class SynonymsSynonymsWebTestCase extends SynonymsWebTestCase {
     taxonomy_term_save($term);
 
     // Testing the 'synonyms' property of 'taxonomy_term' entity.
-    $synonyms = synonyms_get_sanitized($no_synonyms_term);
+    $synonyms = entity_metadata_wrapper('taxonomy_term', $no_synonyms_term)->synonyms->value();
     $this->assertTrue(empty($synonyms), 'Successfully retrieved synonyms_get_sanitized() for a term without synonyms.');
-    $synonyms = synonyms_get_sanitized($one_synonym_term);
+    $synonyms = entity_metadata_wrapper('taxonomy_term', $one_synonym_term)->synonyms->value();
     $this->assertTrue(count($synonyms) == 1 && $synonyms[0] == $synonym1, 'Successfully retrieved synonyms_get_sanitized() for a term with a single synonym.');
-    $synonyms = synonyms_get_sanitized($two_synonyms_term);
+    $synonyms = entity_metadata_wrapper('taxonomy_term', $two_synonyms_term)->synonyms->value();
     $this->assertTrue(count($synonyms) == 2 && $synonyms[0] == $synonym1 && $synonyms[1] == $synonym2, 'Successfully retrieved synonyms_get_sanitized() for a term with 2 synonyms.');
 
     // Testing the function synonyms_get_term_by_synonym().
@@ -357,7 +357,7 @@ class AutocompleteSynonymsWebTestCase extends SynonymsWebTestCase {
       'bundle' => $this->bundle,
       'label' => 'Synonym Terms Autcomplete',
       'widget' => array(
-        'type' => 'synonyms_autocomplete',
+        'type' => 'synonyms_autocomplete_taxonomy_term',
       ),
     );
     $instance = field_create_instance($instance);
@@ -683,7 +683,7 @@ class AutocompleteSynonymsWebTestCase extends SynonymsWebTestCase {
    *   Drupal assertion message to be displayed on the rest results page
    */
   protected function assertAutocompleteMenuPath($input, $standard, $message) {
-    $response = $this->drupalGet('synonyms/autocomplete/' . $this->term_reference_field['field_name']  . '/' . $this->entity_type . '/' . $this->bundle . '/' . $input);
+    $response = $this->drupalGet('synonyms/autocomplete-taxonomy-term/' . $this->term_reference_field['field_name']  . '/' . $this->entity_type . '/' . $this->bundle . '/' . $input);
     if (!$response) {
       $this->fail($message, 'Autocomplete Menu Path');
       return;
@@ -727,7 +727,7 @@ class SelectSynonymsWebTestCase extends SynonymsWebTestCase {
   protected $behavior = 'select';
 
   protected $behavior_settings = array(
-    'wording' => '@synonym @term @field_name',
+    'wording' => '@synonym @entity @field_name',
   );
 
   /**
@@ -797,7 +797,7 @@ class SelectSynonymsWebTestCase extends SynonymsWebTestCase {
       'bundle' => $this->bundle,
       'label' => 'Synonym Terms Select',
       'widget' => array(
-        'type' => 'synonyms_select',
+        'type' => 'synonyms_select_taxonomy_term',
       ),
     );
     $instance = field_create_instance($instance);
@@ -1191,7 +1191,7 @@ class SelectSynonymsWebTestCase extends SynonymsWebTestCase {
       '#value' => $multiple ? array() : 'nothing',
     );
 
-    if (!$multiple && !$required) {
+    if (!$multiple) {
       $element['#options'][''] = t('- None -');
     }
 
@@ -1201,7 +1201,7 @@ class SelectSynonymsWebTestCase extends SynonymsWebTestCase {
       if (isset($v['synonym'])) {
         $label = format_string($this->behavior_settings['wording'], array(
           '@synonym' => $v['synonym'],
-          '@term'=> $v['term']->name,
+          '@entity'=> $v['term']->name,
           '@field_name' => $this->fields['enabled']['instance']['label'],
         ));
       }
@@ -1247,7 +1247,7 @@ class SelectSynonymsWebTestCase extends SynonymsWebTestCase {
  */
 abstract class AbstractSynonymsBehaviorWebTestCase extends SynonymsWebTestCase {
 
-  protected $behavior = 'synonyms';
+  protected $behavior = 'autocomplete';
 
   /**
    * Test synonymsExtract() method.
@@ -1261,7 +1261,7 @@ abstract class AbstractSynonymsBehaviorWebTestCase extends SynonymsWebTestCase {
    *   SimpleTest assertion method
    */
   protected function assertSynonymsExtract($items, $standard, $message = '') {
-    $behavior_implementation = synonyms_behavior_implementation_class('synonyms', $this->fields['enabled']['field']);
+    $behavior_implementation = synonyms_behavior_implementation_class($this->behavior, $this->fields['enabled']['field']);
     $behavior_implementation = new $behavior_implementation();
 
     $term = (object) array(
@@ -1294,7 +1294,7 @@ abstract class AbstractSynonymsBehaviorWebTestCase extends SynonymsWebTestCase {
    *   SimpleTest assertion method
    */
   protected function assertMergeEntityAsSynonym($items, $synonym_entity, $synonym_entity_type, $standard, $message = '') {
-    $behavior_implementation = synonyms_behavior_implementation_class('synonyms', $this->fields['enabled']['field']);
+    $behavior_implementation = synonyms_behavior_implementation_class($this->behavior, $this->fields['enabled']['field']);
     $behavior_implementation = new $behavior_implementation();
 
     $message = get_class($behavior_implementation) . '::mergeEntityAsSynonym() passed: ' . $message;
@@ -1332,7 +1332,7 @@ abstract class AbstractSynonymsBehaviorWebTestCase extends SynonymsWebTestCase {
    *   SimpleTest assertion method
    */
   protected function assertSynonymsFind($meta_data, QueryConditionInterface $condition, $message = '') {
-    $behavior_implementation = synonyms_behavior_implementation_class('synonyms', $this->fields['enabled']['field']);
+    $behavior_implementation = synonyms_behavior_implementation_class($this->behavior, $this->fields['enabled']['field']);
     $behavior_implementation = new $behavior_implementation();
 
     $message = get_class($behavior_implementation) . '::synonymsFind() pass: ' . $message;
@@ -1424,14 +1424,14 @@ class TextSynonymsBehaviorWebTestCase extends AbstractSynonymsBehaviorWebTestCas
     $this->assertMergeEntityAsSynonym(array(), $node, 'node', array(array('value' => $node->title)), 'on a node entity.');
 
     // Testing synonymFind() method.
-    $this->assertSynonymsFind(array(), db_and()->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, $this->randomName()), 'on empty field.');
+    $this->assertSynonymsFind(array(), db_and()->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, $this->randomName()), 'on empty field.');
 
     $meta_data = array();
     $meta_data[] = array(
       'items' => array(),
       'found_synonyms' => array(),
     );
-    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, $this->randomName()), 'on a field without values.');
+    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, $this->randomName()), 'on a field without values.');
 
     $meta_data = array();
     $meta_data[] = array(
@@ -1442,7 +1442,7 @@ class TextSynonymsBehaviorWebTestCase extends AbstractSynonymsBehaviorWebTestCas
       ),
       'found_synonyms' => array(),
     );
-    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, $this->randomName()), 'on a field with a value, but when searching for another string.');
+    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, $this->randomName()), 'on a field with a value, but when searching for another string.');
 
     $meta_data = array();
     $synonym = $this->randomName();
@@ -1454,7 +1454,7 @@ class TextSynonymsBehaviorWebTestCase extends AbstractSynonymsBehaviorWebTestCas
       ),
       'found_synonyms' => array($synonym),
     );
-    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, $synonym), 'on a field with a single value searching for that string');
+    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, $synonym), 'on a field with a single value searching for that string');
 
     $meta_data = array();
     $synonym = $this->randomName();
@@ -1467,7 +1467,7 @@ class TextSynonymsBehaviorWebTestCase extends AbstractSynonymsBehaviorWebTestCas
       ),
       'found_synonyms' => array($synonym),
     );
-    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, $synonym), 'on a field with 2 values searching for one of those 2 values');
+    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, $synonym), 'on a field with 2 values searching for one of those 2 values');
 
     $meta_data = array();
     $synonym = $this->randomName();
@@ -1489,7 +1489,7 @@ class TextSynonymsBehaviorWebTestCase extends AbstractSynonymsBehaviorWebTestCas
       ),
       'found_synonyms' => array(),
     );
-    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, $synonym), 'on 2 fields with 2 values each searching for one of those values');
+    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, $synonym), 'on 2 fields with 2 values each searching for one of those values');
 
     $meta_data = array();
     $synonym = $this->randomName();
@@ -1501,7 +1501,7 @@ class TextSynonymsBehaviorWebTestCase extends AbstractSynonymsBehaviorWebTestCas
       ),
       'found_synonyms' => array($synonym),
     );
-    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, '%' . db_like(drupal_substr($synonym, 1, -1)) . '%', 'LIKE'), 'on a field with a value searching for a string LIKE the %value%');
+    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, '%' . db_like(drupal_substr($synonym, 1, -1)) . '%', 'LIKE'), 'on a field with a value searching for a string LIKE the %value%');
 
     $meta_data = array();
     $tag = $this->randomName();
@@ -1516,7 +1516,7 @@ class TextSynonymsBehaviorWebTestCase extends AbstractSynonymsBehaviorWebTestCas
       ),
       'found_synonyms' => array($synonym1, $synonym2),
     );
-    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, db_like($tag) . '%', 'LIKE'), 'on a field with 2 similar values searching a string like %both values%');
+    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, db_like($tag) . '%', 'LIKE'), 'on a field with 2 similar values searching a string like %both values%');
 
     $meta_data = array();
     $synonym1 = $this->randomName();
@@ -1530,7 +1530,7 @@ class TextSynonymsBehaviorWebTestCase extends AbstractSynonymsBehaviorWebTestCas
       ),
       'found_synonyms' => array($synonym1, $synonym2),
     );
-    $this->assertSynonymsFind($meta_data, db_or()->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, $synonym1)->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, $synonym2), 'on a field with 2 values searching for value1 or value2');
+    $this->assertSynonymsFind($meta_data, db_or()->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, $synonym1)->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, $synonym2), 'on a field with 2 values searching for value1 or value2');
 
     $meta_data = array();
     $synonym = $this->randomName();
@@ -1543,7 +1543,7 @@ class TextSynonymsBehaviorWebTestCase extends AbstractSynonymsBehaviorWebTestCas
       ),
       'found_synonyms' => array($synonym),
     );
-    $this->assertSynonymsFind($meta_data, db_and(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, $synonym)->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, db_like(drupal_substr($synonym, 0, -1)) . '%', 'LIKE'), 'on a field with 2 values searching for value1 and LIKE value1%');
+    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, $synonym)->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, db_like(drupal_substr($synonym, 0, -1)) . '%', 'LIKE'), 'on a field with 2 values searching for value1 and LIKE value1%');
 
     $meta_data = array();
     $synonym1 = $this->randomName();
@@ -1558,8 +1558,8 @@ class TextSynonymsBehaviorWebTestCase extends AbstractSynonymsBehaviorWebTestCas
       'found_synonyms' => array($synonym1, $synonym2),
     );
     $condition = db_or();
-    $condition->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, $synonym1);
-    $condition->condition(db_and()->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, $synonym2)->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, db_like(drupal_substr($synonym2, 0, -1)) . '%', 'LIKE'));
+    $condition->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, $synonym1);
+    $condition->condition(db_and()->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, $synonym2)->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, db_like(drupal_substr($synonym2, 0, -1)) . '%', 'LIKE'));
     $this->assertSynonymsFind($meta_data, $condition, 'on a field with 2 values searching for (value1 or (value2 AND value2%))');
 
     $meta_data = array();
@@ -1575,7 +1575,7 @@ class TextSynonymsBehaviorWebTestCase extends AbstractSynonymsBehaviorWebTestCas
       'found_synonyms' => array($synonym1, $synonym2),
     );
     $condition = db_and()
-      ->where("REPLACE(" . AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER . ", ' ', '-') = :synonym", array(
+      ->where("REPLACE(" . AbstractSynonymsBehavior::COLUMN_PLACEHOLDER . ", ' ', '-') = :synonym", array(
         ':synonym' => $synonym2,
       ));
     $this->assertSynonymsFind($meta_data, $condition, "on a field with 2 values, where 2nd value replaces spaces with dashes in the 1st value, searching for REPLACE(column, ' ', '-') = value2");
@@ -1654,14 +1654,14 @@ class TaxonomySynonymsBehaviorWebTestCase extends AbstractSynonymsBehaviorWebTes
     $this->assertMergeEntityAsSynonym(array(), $synonym_term, 'taxonomy_term', array(array('tid' => $synonym_term->tid)), 'on a term from referenced vocabulary.');
 
     // Testing synonymFind() method.
-    $this->assertSynonymsFind(array(), db_and()->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, $this->randomName()), 'on empty field');
+    $this->assertSynonymsFind(array(), db_and()->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, $this->randomName()), 'on empty field');
 
     $meta_data = array();
     $meta_data[] = array(
       'items' => array(),
       'found_synonyms' => array(),
     );
-    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, $this->randomName()), 'on a field without values');
+    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, $this->randomName()), 'on a field without values');
 
     $meta_data = array();
     $meta_data[] = array(
@@ -1672,7 +1672,7 @@ class TaxonomySynonymsBehaviorWebTestCase extends AbstractSynonymsBehaviorWebTes
       ),
       'found_synonyms' => array(),
     );
-    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, $this->randomName()), 'on a field with a value but searching for another string');
+    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, $this->randomName()), 'on a field with a value but searching for another string');
 
     $meta_data = array();
     $synonym_term = $this->createSynonymTerm();
@@ -1684,7 +1684,7 @@ class TaxonomySynonymsBehaviorWebTestCase extends AbstractSynonymsBehaviorWebTes
       ),
       'found_synonyms' => array($synonym_term->name),
     );
-    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, $synonym_term->name), 'on a field with a single value searching for that string');
+    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, $synonym_term->name), 'on a field with a single value searching for that string');
 
     $meta_data = array();
     $synonym_term = $this->createSynonymTerm();
@@ -1697,7 +1697,7 @@ class TaxonomySynonymsBehaviorWebTestCase extends AbstractSynonymsBehaviorWebTes
       ),
       'found_synonyms' => array($synonym_term->name),
     );
-    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, $synonym_term->name), 'on a field with 2 values searching for one of those 2 values');
+    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, $synonym_term->name), 'on a field with 2 values searching for one of those 2 values');
 
     $meta_data = array();
     $synonym_term = $this->createSynonymTerm();
@@ -1719,7 +1719,7 @@ class TaxonomySynonymsBehaviorWebTestCase extends AbstractSynonymsBehaviorWebTes
       ),
       'found_synonyms' => array(),
     );
-    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, $synonym_term->name), 'on 2 fields with 2 values each searching for one of those values');
+    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, $synonym_term->name), 'on 2 fields with 2 values each searching for one of those values');
 
     $meta_data = array();
     $synonym_term = $this->createSynonymTerm();
@@ -1731,7 +1731,7 @@ class TaxonomySynonymsBehaviorWebTestCase extends AbstractSynonymsBehaviorWebTes
       ),
       'found_synonyms' => array($synonym_term->name),
     );
-    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, '%' . db_like(drupal_substr($synonym_term->name, 1, -1)) . '%', 'LIKE'), 'on a field with a value searching for a string LIKE the %value%');
+    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, '%' . db_like(drupal_substr($synonym_term->name, 1, -1)) . '%', 'LIKE'), 'on a field with a value searching for a string LIKE the %value%');
 
     $meta_data = array();
     $tag = $this->randomName();
@@ -1746,7 +1746,7 @@ class TaxonomySynonymsBehaviorWebTestCase extends AbstractSynonymsBehaviorWebTes
       ),
       'found_synonyms' => array($synonym_term1->name, $synonym_term2->name),
     );
-    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, db_like($tag) . '%', 'LIKE'), 'on a field with 2 similar values searching a string like %both values%');
+    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, db_like($tag) . '%', 'LIKE'), 'on a field with 2 similar values searching a string like %both values%');
 
     $meta_data = array();
     $synonym_term1 = $this->createSynonymTerm();
@@ -1760,7 +1760,7 @@ class TaxonomySynonymsBehaviorWebTestCase extends AbstractSynonymsBehaviorWebTes
       ),
       'found_synonyms' => array($synonym_term1->name, $synonym_term2->name),
     );
-    $this->assertSynonymsFind($meta_data, db_or()->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, $synonym_term1->name)->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, $synonym_term2->name), 'on a field with 2 values searching for value1 or value2');
+    $this->assertSynonymsFind($meta_data, db_or()->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, $synonym_term1->name)->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, $synonym_term2->name), 'on a field with 2 values searching for value1 or value2');
 
     $meta_data = array();
     $synonym_term = $this->createSynonymTerm();
@@ -1773,7 +1773,7 @@ class TaxonomySynonymsBehaviorWebTestCase extends AbstractSynonymsBehaviorWebTes
       ),
       'found_synonyms' => array($synonym_term->name),
     );
-    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, $synonym_term->name)->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, '%' . db_like(drupal_substr($synonym_term->name, 1, -1)) . '%', 'LIKE'), 'on a field with 2 values searching for value1 and LIKE value1%');
+    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, $synonym_term->name)->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, '%' . db_like(drupal_substr($synonym_term->name, 1, -1)) . '%', 'LIKE'), 'on a field with 2 values searching for value1 and LIKE value1%');
 
     $meta_data = array();
     $synonym_term1 = $this->createSynonymTerm();
@@ -1788,10 +1788,10 @@ class TaxonomySynonymsBehaviorWebTestCase extends AbstractSynonymsBehaviorWebTes
       'found_synonyms' => array($synonym_term1->name, $synonym_term2->name),
     );
     $condition = db_or();
-    $condition->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, $synonym_term1->name);
+    $condition->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, $synonym_term1->name);
     $condition->condition(db_and()
-      ->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, $synonym_term2->name)
-      ->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, '%' . db_like(drupal_substr($synonym_term2->name, 1 -1)) . '%', 'LIKE'));
+      ->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, $synonym_term2->name)
+      ->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, '%' . db_like(drupal_substr($synonym_term2->name, 1 -1)) . '%', 'LIKE'));
     $this->assertSynonymsFind($meta_data, $condition, 'on a field with 2 values searching for (value1 or (value2 AND value2%))');
 
     $meta_data =  array();
@@ -1807,7 +1807,7 @@ class TaxonomySynonymsBehaviorWebTestCase extends AbstractSynonymsBehaviorWebTes
       'found_synonyms' => array($synonym_term1->name, $synonym_term2->name),
     );
     $condition = db_and()
-      ->where("REPLACE(" . AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER . ", ' ', '-') = :synonym", array(
+      ->where("REPLACE(" . AbstractSynonymsBehavior::COLUMN_PLACEHOLDER . ", ' ', '-') = :synonym", array(
         ':synonym' => $synonym_term2->name,
       ));
     $this->assertSynonymsFind($meta_data, $condition, "on a field with 2 values, where 2nd value replaces spaces with dashes in the 1st value, searching for REPLACE(column, ' ', '-') = value2");
@@ -1901,14 +1901,14 @@ class EntityReferenceSynonymsBehaviorWebTestCase extends AbstractSynonymsBehavio
     $this->assertMergeEntityAsSynonym(array(), $node, 'node', array(array('target_id' => $node->nid)), 'on a node.');
 
     // Testing synonymFind() method.
-    $this->assertSynonymsFind(array(), db_and()->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, $this->randomName()), 'on empty field');
+    $this->assertSynonymsFind(array(), db_and()->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, $this->randomName()), 'on empty field');
 
     $meta_data = array();
     $meta_data[] = array(
       'items' => array(),
       'found_synonyms' => array(),
     );
-    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, $this->randomName()), 'on a field without values');
+    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, $this->randomName()), 'on a field without values');
 
     $meta_data = array();
     $meta_data[] = array(
@@ -1919,7 +1919,7 @@ class EntityReferenceSynonymsBehaviorWebTestCase extends AbstractSynonymsBehavio
       ),
       'found_synonyms' => array(),
     );
-    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, $this->randomName()), 'on a field with a value but searching for another string');
+    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, $this->randomName()), 'on a field with a value but searching for another string');
 
     $meta_data = array();
     $synonym_entity = $this->createNode();
@@ -1931,7 +1931,7 @@ class EntityReferenceSynonymsBehaviorWebTestCase extends AbstractSynonymsBehavio
       ),
       'found_synonyms' => array(entity_label('node', $synonym_entity)),
     );
-    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, entity_label('node', $synonym_entity)), 'on a field with a single value searching for that string');
+    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, entity_label('node', $synonym_entity)), 'on a field with a single value searching for that string');
 
     $meta_data = array();
     $synonym_entity = $this->createNode();
@@ -1944,7 +1944,7 @@ class EntityReferenceSynonymsBehaviorWebTestCase extends AbstractSynonymsBehavio
       ),
       'found_synonyms' => array(entity_label('node', $synonym_entity)),
     );
-    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, entity_label('node', $synonym_entity)), 'on a field with 2 values searching for one of those 2 values');
+    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, entity_label('node', $synonym_entity)), 'on a field with 2 values searching for one of those 2 values');
 
     $meta_data = array();
     $synonym_entity = $this->createNode();
@@ -1966,7 +1966,7 @@ class EntityReferenceSynonymsBehaviorWebTestCase extends AbstractSynonymsBehavio
       ),
       'found_synonyms' => array(),
     );
-    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, entity_label('node', $synonym_entity)), 'on 2 fields with 2 values each searching for one of those values');
+    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, entity_label('node', $synonym_entity)), 'on 2 fields with 2 values each searching for one of those values');
 
     $meta_data = array();
     $synonym_entity = $this->createNode();
@@ -1978,7 +1978,7 @@ class EntityReferenceSynonymsBehaviorWebTestCase extends AbstractSynonymsBehavio
       ),
       'found_synonyms' => array(entity_label('node', $synonym_entity)),
     );
-    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, '%' . db_like(drupal_substr(entity_label('node', $synonym_entity), 1, -1)) . '%', 'LIKE'), 'on a field with a value searching for a string LIKE the %value%');
+    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, '%' . db_like(drupal_substr(entity_label('node', $synonym_entity), 1, -1)) . '%', 'LIKE'), 'on a field with a value searching for a string LIKE the %value%');
 
     $meta_data = array();
     $tag = $this->randomName();
@@ -1996,7 +1996,7 @@ class EntityReferenceSynonymsBehaviorWebTestCase extends AbstractSynonymsBehavio
         entity_label('node', $synonym_entity2),
       ),
     );
-    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, db_like($tag) . '%', 'LIKE'), 'on a field with 2 similar values searching a string like %both values%');
+    $this->assertSynonymsFind($meta_data, db_and()->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, db_like($tag) . '%', 'LIKE'), 'on a field with 2 similar values searching a string like %both values%');
 
     $meta_data = array();
     $synonym_entity1 = $this->createNode();
@@ -2014,8 +2014,8 @@ class EntityReferenceSynonymsBehaviorWebTestCase extends AbstractSynonymsBehavio
       ),
     );
     $condition = db_or()
-      ->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, entity_label('node', $synonym_entity1))
-      ->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, entity_label('node', $synonym_entity2));
+      ->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, entity_label('node', $synonym_entity1))
+      ->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, entity_label('node', $synonym_entity2));
     $this->assertSynonymsFind($meta_data, $condition, 'on a field with 2 values searching for value1 or value2');
 
     $meta_data = array();
@@ -2030,8 +2030,8 @@ class EntityReferenceSynonymsBehaviorWebTestCase extends AbstractSynonymsBehavio
       'found_synonyms' => array(entity_label('node', $synonym_entity)),
     );
     $condition = db_and()
-      ->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, entity_label('node', $synonym_entity))
-      ->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, '%' . db_like(drupal_substr(entity_label('node', $synonym_entity), 1, -1)) . '%', 'LIKE');
+      ->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, entity_label('node', $synonym_entity))
+      ->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, '%' . db_like(drupal_substr(entity_label('node', $synonym_entity), 1, -1)) . '%', 'LIKE');
     $this->assertSynonymsFind($meta_data, $condition, 'on a field with 2 values searching for value1 and LIKE value1%');
 
     $meta_data = array();
@@ -2050,8 +2050,8 @@ class EntityReferenceSynonymsBehaviorWebTestCase extends AbstractSynonymsBehavio
       ),
     );
     $condition = db_or()
-      ->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, entity_label('node', $synonym_entity1))
-      ->condition(db_and()->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, entity_label('node', $synonym_entity2))->condition(AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER, '%' . db_like(drupal_substr(entity_label('node', $synonym_entity2), 1, -1)) . '%', 'LIKE'));
+      ->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, entity_label('node', $synonym_entity1))
+      ->condition(db_and()->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, entity_label('node', $synonym_entity2))->condition(AbstractSynonymsBehavior::COLUMN_PLACEHOLDER, '%' . db_like(drupal_substr(entity_label('node', $synonym_entity2), 1, -1)) . '%', 'LIKE'));
     $this->assertSynonymsFind($meta_data, $condition, 'on a field with 2 values searching for (value1 or (value2 AND value2%))');
 
     $meta_data = array();
@@ -2070,7 +2070,7 @@ class EntityReferenceSynonymsBehaviorWebTestCase extends AbstractSynonymsBehavio
       ),
     );
     $condition = db_and()
-      ->where("REPLACE(" . AbstractSynonymsSynonymsBehavior::COLUMN_PLACEHOLDER . ", ' ', '-') = :synonym", array(
+      ->where("REPLACE(" . AbstractSynonymsBehavior::COLUMN_PLACEHOLDER . ", ' ', '-') = :synonym", array(
         ':synonym' => entity_label('node', $synonym_entity2),
       ));
     $this->assertSynonymsFind($meta_data, $condition, "on a field with 2 values, where 2nd value replaces spaces with dashes in the 1st value, searching for REPLACE(column, ' ', '-') = value2");
diff --git a/synonyms_search/includes/SearchSynonymsBehavior.interface.inc b/synonyms_search/includes/SearchSynonymsBehavior.interface.inc
index 63935dd..a30ff60 100644
--- a/synonyms_search/includes/SearchSynonymsBehavior.interface.inc
+++ b/synonyms_search/includes/SearchSynonymsBehavior.interface.inc
@@ -9,6 +9,6 @@
 /**
  * Interface of search integration synonyms behavior.
  */
-interface SearchSynonymsBehavior extends SynonymsSynonymsBehavior {
+interface SearchSynonymsBehavior extends SynonymsBehavior {
 }
 
diff --git a/synonyms_search/synonyms_search.module b/synonyms_search/synonyms_search.module
index 835f276..8423271 100644
--- a/synonyms_search/synonyms_search.module
+++ b/synonyms_search/synonyms_search.module
@@ -51,11 +51,11 @@ function synonyms_search_taxonomy_term_update($term) {
 function synonyms_search_node_update_index($node) {
   $output = array();
   foreach (field_info_instances('node', $node->type) as $instance) {
-    // We go a field by field looking for taxonomy term reference and if that
-    // vocabulary has enabled search synonyms, we add them to the search index.
+    // We go a field by field looking for taxonomy term reference or entity
+    // reference of taxonomy term type and if that vocabulary has enabled search
+    // synonyms, we add them to the search index.
     $field_info = field_info_field($instance['field_name']);
     if ($field_info['type'] == 'taxonomy_term_reference') {
-      // For each term referenced in this node we have to add synonyms.
       $terms = field_get_items('node', $node, $instance['field_name']);
       if (is_array($terms) && !empty($terms)) {
         foreach ($terms as $v) {
@@ -63,6 +63,14 @@ function synonyms_search_node_update_index($node) {
         }
       }
     }
+    if ($field_info['type'] == 'entityreference' && $field_info['settings']['target_type'] == 'taxonomy_term') {
+      $terms =field_get_items('node', $node, $instance['field_name']);
+      if (is_array($terms) && !empty($terms)) {
+        foreach ($terms as $v) {
+          $output[] = $v['target_id'];
+        }
+      }
+    }
   }
 
   if (!empty($output)) {
diff --git a/synonyms_search/synonyms_search.pages.inc b/synonyms_search/synonyms_search.pages.inc
index b6876f3..3747888 100644
--- a/synonyms_search/synonyms_search.pages.inc
+++ b/synonyms_search/synonyms_search.pages.inc
@@ -21,8 +21,6 @@ function synonyms_search_reindex_nodes_by_terms($tids) {
   $found_nids = array();
   foreach (field_info_field_map() as $field_name => $v) {
     if ($v['type'] == 'taxonomy_term_reference' && isset($v['bundles']['node'])) {
-      // This field is taxonomy term reference and it is attached to nodes, so
-      // we will run EntityFieldQuery on it.
       $query = new EntityFieldQuery();
       $result = $query->entityCondition('entity_type', 'node')
         ->fieldCondition($field_name, 'tid', $tids, 'IN')
@@ -31,6 +29,18 @@ function synonyms_search_reindex_nodes_by_terms($tids) {
         $found_nids = array_merge($found_nids, array_keys($result['node']));
       }
     }
+    if ($v['type'] == 'entityreference' && isset($v['bundles']['node'])) {
+      $field = field_info_field($field_name);
+      if ($field['settings']['target_type'] == 'taxonomy_term') {
+        $query = new EntityFieldQuery();
+        $result = $query->entityCondition('entity_type', 'node')
+          ->fieldCondition($field_name, 'target_id', $tids, 'IN')
+          ->execute();
+        if (isset($result['node'])) {
+          $found_nids = array_merge($found_nids, array_keys($result['node']));
+        }
+      }
+    }
   }
   if (!empty($found_nids)) {
     db_update('search_dataset')
diff --git a/synonyms_search/synonyms_search.test b/synonyms_search/synonyms_search.test
deleted file mode 100644
index 5477d9a..0000000
--- a/synonyms_search/synonyms_search.test
+++ /dev/null
@@ -1,367 +0,0 @@
-<?php
-
-/**
- * @file
- * Tests for the Synonyms Search module.
- */
-
-/**
- * Base class for tests of Synonyms Search module.
- */
-abstract class AbstractSearchSynonymsWebTestCase extends SynonymsWebTestCase {
-
-  protected $behavior = 'search';
-
-  /**
-   * What search type is being tested.
-   *
-   * @var string
-   */
-  protected $search_type = 'node';
-
-  /**
-   * Array of terms that will be used for testing.
-   *
-   * @var array
-   */
-  protected $terms = array();
-
-  /**
-   * SetUp method.
-   */
-  public function setUp($modules = array()) {
-    $modules[] = 'synonyms_search';
-    parent::setUp($modules);
-
-    // Create a few terms and synonyms.
-    $term = (object) array(
-      'vid' => $this->vocabulary->vid,
-      'name' => $this->randomName(),
-      $this->fields['disabled']['field']['field_name'] => array(
-        LANGUAGE_NONE => array(
-          array('value' => $this->randomName()),
-        ),
-      ),
-    );
-    taxonomy_term_save($term);
-    $this->terms['no_synonyms'] = $term;
-
-    $term = (object) array(
-      'vid' => $this->vocabulary->vid,
-      'name' => $this->randomName(),
-      $this->fields['enabled']['field']['field_name'] => array(
-        LANGUAGE_NONE => array(
-          array('value' => $this->randomName()),
-        ),
-      ),
-      $this->fields['disabled']['field']['field_name'] => array(
-        LANGUAGE_NONE => array(
-          array('value' => $this->randomName()),
-        ),
-      ),
-    );
-    taxonomy_term_save($term);
-    $this->terms['one_synonym'] = $term;
-
-    $term = (object) array(
-      'vid' => $this->vocabulary->vid,
-      'name' => $this->randomName(),
-      $this->fields['enabled']['field']['field_name'] => array(
-        LANGUAGE_NONE => array(
-          array('value' => $this->randomName()),
-          array('value' => $this->randomName()),
-        ),
-      ),
-      $this->fields['disabled']['field']['field_name'] => array(
-        LANGUAGE_NONE => array(
-          array('value' => $this->randomName()),
-        ),
-      ),
-    );
-    taxonomy_term_save($term);
-    $this->terms['two_synonyms'] = $term;
-  }
-
-  /**
-   * Retrieve search results.
-   *
-   * @param $keyword string
-   *   Keyword to supply to the search mechanism
-   *
-   * @return array
-   *   Array of HTML search results. Each element in this array is a single
-   *   search result represented in HTML code as Drupal search mechanism outputs
-   *   it
-   */
-  protected function getSearchResults($keyword) {
-    $response = $this->drupalGet('search/' . $this->search_type . '/' . $keyword);
-    $matches = array();
-    preg_match_all('#\<li[^>]+class="search-result"[^>]*\>(.*?)\</li\>#si', $response, $matches);
-    return $matches[1];
-  }
-}
-
-/**
- * Test Synonyms module integration with Drupal search functionality for nodes.
- */
-class NodeSearchSynonymsWebTestCase extends AbstractSearchSynonymsWebTestCase {
-
-  /**
-   * GetInfo method.
-   */
-  public static function getInfo() {
-    return array(
-      'name' => 'Synonyms node search integration',
-      'description' => 'Ensure that Synonyms module correctly integrates with the Drupal search functionality.',
-      'group' => 'Synonyms',
-    );
-  }
-
-  /**
-   * SetUp method.
-   */
-  public function setUp($modules = array()) {
-    parent::setUp($modules);
-
-    // Creating a test content type.
-    $this->drupalPost('admin/structure/types/add', array(
-      'name' => 'Synonyms Test Content',
-      'type' => 'synonyms_test_content',
-    ), 'Save content type');
-
-    // Attaching term reference field to the new content type.
-    $field = array(
-      'type' => 'taxonomy_term_reference',
-      'field_name' => 'synonyms_term_enabled',
-      'cardinality' => FIELD_CARDINALITY_UNLIMITED,
-      'settings' => array(
-        'allowed_values' => array(
-          array(
-            'vocabulary' => $this->vocabulary->machine_name,
-            'parent' => 0,
-          ),
-        ),
-      ),
-    );
-    $field = field_create_field($field);
-
-    $instance = array(
-      'field_name' => $field['field_name'],
-      'entity_type' => 'node',
-      'bundle' => 'synonyms_test_content',
-      'label' => 'Synonym Terms',
-      'widget' => array(
-        'type' => 'synonyms_autocomplete',
-      ),
-    );
-
-    field_create_instance($instance);
-  }
-
-  /**
-   * Test searching nodes by a term synonym.
-   *
-   * Since logically term and its synonyms represent the same entity, the idea
-   * is that searching by a term synonym should trigger all content referencing
-   * that term to be included in search results. Additionally we test that when
-   * a synonym is deleted/edited in a term, corresponding content is no longer
-   * encountered when searched by ex-synonym.
-   */
-  public function testSearchTermSynonym() {
-    // Creating a node, which references all the terms we have.
-    $node = (object) array(
-      'type' => 'synonyms_test_content',
-      'title' => $this->randomName(),
-      'synonyms_term_enabled' => array(LANGUAGE_NONE => array(
-        array('tid' => $this->terms['no_synonyms']->tid),
-        array('tid' => $this->terms['one_synonym']->tid),
-        array('tid' => $this->terms['two_synonyms']->tid),
-      )),
-    );
-    node_save($node);
-
-    // Rebuilding Search index.
-    $this->cronRun();
-
-    foreach ($this->terms as $k => $term) {
-      $this->assertSearchResults($term->name, array($node), 'Searching by name of the term ' . $k);
-      $items = field_get_items('taxonomy_term', $term, $this->fields['disabled']['field']['field_name']);
-      if (is_array($items)) {
-        foreach ($items as $delta => $item) {
-          $this->assertSearchResults($item['value'], array(), 'Searching by not enabled search integration field value #' . $delta . ' of term ' . $k);
-        }
-      }
-
-      $items = field_get_items('taxonomy_term', $term, $this->fields['enabled']['field']['field_name']);
-      if (is_array($items)) {
-        foreach ($items as $delta => $item) {
-          $this->assertSearchResults($item['value'], array($node), 'Searching by synonym #' . $delta . ' of the term ' . $k);
-        }
-      }
-    }
-
-    // Removing a synonym from the term. Then asserting node got re-indexed with
-    // new values of synonyms.
-    $deleted_synonym = array_pop($this->terms['one_synonym']->{$this->fields['enabled']['field']['field_name']}[LANGUAGE_NONE]);
-    taxonomy_term_save($this->terms['one_synonym']);
-    $this->cronRun();
-    $this->assertSearchResults($deleted_synonym['value'], array(), 'Searching by recently deleted synonym of a taxonomy term yields no results.');
-
-    // Editing a synonym in a term. Then asserting node got re-indexed with new
-    // values of synonyms.
-    $ex_synonym = $this->terms['two_synonyms']->{$this->fields['enabled']['field']['field_name']}[LANGUAGE_NONE][0]['value'];
-    $this->terms['two_synonyms']->{$this->fields['enabled']['field']['field_name']}[LANGUAGE_NONE][0]['value'] = $this->randomName();
-    taxonomy_term_save($this->terms['two_synonyms']);
-    $this->cronRun();
-    $this->assertSearchResults($ex_synonym, array(), 'Searching by recently changed synonym of a taxonomy term yields no results.');
-
-    // We disable entire field from search integration and make sure for all
-    // synonyms search results are empty.
-    synonyms_behavior_settings_delete($this->fields['enabled']['instance']['id'], $this->behavior);
-    $this->cronRun();
-    foreach ($this->terms as $k => $term) {
-      $items = field_get_items('taxonomy_term', $term, $this->fields['enabled']['field']['field_name']);
-      if (is_array($items)) {
-        foreach ($items as $synonym) {
-          $this->assertSearchResults($synonym['value'], array(), 'Searching by ' . $k . ' term synonym, which field was recently disabled from search behavior yields no results.');
-        }
-      }
-    }
-  }
-
-  /**
-   * Assert search results.
-   *
-   * @param $keyword string
-   *   Keyword to supply to the search mechanism
-   * @param $results array
-   *   Array of fully loaded nodes that are expected to be on search results
-   * @param $message string
-   *   Drupal assertion message to display on test results page
-   */
-  protected function assertSearchResults($keyword, $results, $message) {
-    $matches = $this->getSearchResults($keyword);
-    if (count($matches) != count($results)) {
-      $this->fail($message);
-      return;
-    }
-    $matches = implode('', $matches);
-    foreach ($results as $node) {
-      if (strpos($matches, 'node/' . $node->nid) === FALSE) {
-        $this->fail($message);
-        return;
-      }
-    }
-    $this->pass($message);
-  }
-}
-
-/**
- * Test Synonyms module integration with Drupal search for taxonomy terms.
- */
-class TermSearchSynonymsWebTestCase extends AbstractSearchSynonymsWebTestCase {
-
-  protected $search_type = 'term';
-
-  /**
-   * GetInfo method.
-   */
-  public static function getInfo() {
-    return array(
-      'name' => 'Synonyms term search integration',
-      'description' => 'Ensure that Synonyms module correctly integrates with the Term Search module.',
-      'group' => 'Synonyms',
-    );
-  }
-
-  /**
-   * SetUp method.
-   */
-  public function setUp($modules = array()) {
-    $modules[] = 'term_search';
-    parent::setUp($modules);
-    $active_searches = variable_get('search_active_modules', array('node', 'user'));
-    $active_searches[] = 'term_search';
-    variable_set('search_active_modules', $active_searches);
-  }
-
-  /**
-   * Test searching terms by their synonyms.
-   */
-  public function testSearchTermSynonym() {
-    // Rebuilding Search index.
-    $this->cronRun();
-
-    foreach ($this->terms as $k => $term) {
-      $this->assertSearchResults($term->name, array($term), 'Searching by name of the term ' . $k);
-      $items = field_get_items('taxonomy_term', $term, $this->fields['disabled']['field']['field_name']);
-      if (is_array($items)) {
-        foreach ($items as $delta => $item) {
-          $this->assertSearchResults($item['value'], array(), 'Searching by not enabled search integration field value #' . $delta . ' of term ' . $k);
-        }
-      }
-
-      $items = field_get_items('taxonomy_term', $term, $this->fields['enabled']['field']['field_name']);
-      if (is_array($items)) {
-        foreach ($items as $delta => $item) {
-          $this->assertSearchResults($item['value'], array($term), 'Searching by synonym #' . $delta . ' of the term ' . $k);
-        }
-      }
-    }
-
-    // Removing a synonym from the term. Then asserting it got re-indexed with
-    // new values of synonyms.
-    $deleted_synonym = array_pop($this->terms['one_synonym']->{$this->fields['enabled']['field']['field_name']}[LANGUAGE_NONE]);
-    taxonomy_term_save($this->terms['one_synonym']);
-    $this->cronRun();
-    $this->assertSearchResults($deleted_synonym['value'], array(), 'Searching by recently deleted synonym of a taxonomy term yields no results.');
-
-    // Editing a synonym in a term. Then asserting it got re-indexed with new
-    // values of synonyms.
-    $ex_synonym = $this->terms['two_synonyms']->{$this->fields['enabled']['field']['field_name']}[LANGUAGE_NONE][0]['value'];
-    $this->terms['two_synonyms']->{$this->fields['enabled']['field']['field_name']}[LANGUAGE_NONE][0]['value'] = $this->randomName();
-    taxonomy_term_save($this->terms['two_synonyms']);
-    $this->cronRun();
-    $this->assertSearchResults($ex_synonym, array(), 'Searching by recently changed synonym of a taxonomy term yields no results.');
-
-    // We disable entire field from search integration and make sure for all
-    // synonyms search results are empty.
-    synonyms_behavior_settings_delete($this->fields['enabled']['instance']['id'], $this->behavior);
-    $this->cronRun();
-    foreach ($this->terms as $k => $term) {
-      $items = field_get_items('taxonomy_term', $term, $this->fields['enabled']['field']['field_name']);
-      if (is_array($items)) {
-        foreach ($items as $synonym) {
-          $this->assertSearchResults($synonym['value'], array(), 'Searching by ' . $k . ' term synonym, which field was recently disabled from search behavior yields no results.');
-        }
-      }
-    }
-  }
-
-  /**
-   * Assert search results.
-   *
-   * @param $keyword string
-   *   Keyword to supply to the search mechanism
-   * @param $results array
-   *   Array of fully loaded terms that are expected to be on search results
-   * @param $message string
-   *   Drupal assertion message to display on test results page
-   */
-  protected function assertSearchResults($keyword, $results, $message) {
-    $matches = $this->getSearchResults($keyword);
-    if (count($matches) != count($results)) {
-      $this->fail($message);
-      return;
-    }
-    $matches = implode('', $matches);
-    foreach ($results as $term) {
-      if (strpos($matches, 'taxonomy/term/' . $term->tid) === FALSE) {
-        $this->fail($message);
-        return;
-      }
-    }
-    $this->pass($message);
-  }
-
-}
