diff --git a/relation.info b/relation.info
index ae00f05..c315381 100644
--- a/relation.info
+++ b/relation.info
@@ -7,6 +7,7 @@ files[] = tests/relation.test
 files[] = tests/relation.rules.test
 files[] = tests/relation.views.test
 files[] = views/relation_handler_relationship.inc
+files[] = views/relation_handler_endpoint_entity_join.inc
 configure = admin/structure/relation
 dependencies[] = relation_endpoint
 dependencies[] = ctools (!=7.x-1.0-rc1)
diff --git a/views/relation.views.inc b/views/relation.views.inc
index 4f9aee2..33815b0 100644
--- a/views/relation.views.inc
+++ b/views/relation.views.inc
@@ -160,7 +160,13 @@ function relation_views_data() {
 
   // Define the base group of this table.
   $data['field_data_endpoints']['table']['group'] = t('Relation');
-  $data['field_data_endpoints']['table']['join'] = array();
+  // Define join from endpoints to relation.
+  $data['field_data_endpoints']['table']['join'] = array(
+    'relation' => array(
+      'left_field' => 'rid',
+      'field' => 'entity_id',
+    ),
+  );
 
   // Find out which entity type has which base table.
   $entity_infos = entity_get_info();
@@ -187,31 +193,71 @@ function relation_views_data() {
         '@left' => $entity_type_left,
         '@relation_type_label' => $relation_type->label,
       );
+
+      // Define relationship from endpoints to relation.
+      $data['field_data_endpoints']['endpoints_base_' . $type . '_right_relation'] = array(
+        'title' => t('@relation_type_label (endpoints -> relation)', $t_arguments),
+        'help' => t('Endpoints table to relation table using "@relation_type_label" relation', $t_arguments),
+        'relationship' => array(
+          // relation_handler_relationship::options_form() relies on this check_plain().
+          'label' => check_plain('Relation::' . $relation_type->label),
+          'base' => 'relation',
+          'base field' => 'rid',
+          'relationship field' => 'entity_id',
+        ),
+      );
+
+      // Define join from endpoints to "left" entity.
+      $data['field_data_endpoints']['table']['join'] += array(
+        // Directly links to the $entity_type_right table.
+        $entity_type_left => array(
+          'left_field' => $entity_infos[$entity_type_left]['entity keys']['id'],
+          'field' => 'endpoints_entity_id',
+          'handler' => 'relation_handler_endpoint_entity_join', // add "relation type" join condition
+          'relation_type' => $type, // USE THIS as bundle
+        ),
+      );
+      // Define relationship from endpoints to "left" entity.
+      $data['field_data_endpoints']['endpoints_base_' . $type . '_right_' . $entity_type_left] = array(
+        'title' => t('Endpoints: @relation_type_label (endpoints -> @left)', $t_arguments),
+        'help' => t('Endpoints table to @left using "@relation_type_label" relation', $t_arguments),
+        'relationship' => array(
+          // relation_handler_relationship::options_form() relies on this check_plain().
+          'label' => check_plain($entity_type_left . '::' . $relation_type->label),
+          'base' => $base_table_left,
+          'base field' => $entity_infos[$entity_type_left]['entity keys']['id'],
+          'relationship field' => 'endpoints_entity_id',
+        ),
+      );
+
       foreach ($relation_type->$target_index as $target_bundle) {
         $target_bundle = explode(':', $target_bundle, 2);
         $entity_type_right = $target_bundle[0];
         $base_table_right = $entity_tables[$entity_type_right];
         $t_arguments['@right'] = $entity_type_right;
-        // Define [join and] relationship from relation to endpoints.
+
+        // Define relationship from relation to endpoints.
         $data['relation']['relation_base_' . $type . '_right_endpoints'] = array(
-          'title' => t('@relation_type_label -> endpoints[@relation_type_label]', $t_arguments),
+          'title' => t('@relation_type_label (relation -> endpoints)', $t_arguments),
           'help' => t('Relation table to endpoints table using "@relation_type_label" relation', $t_arguments),
           'relationship' => array(
             // relation_handler_relationship::options_form() relies on this check_plain().
             'label' => check_plain('Endpoints::' . $relation_type->label),
             'base' => 'field_data_endpoints',
             'base field' => 'entity_id',
-            'real field' => 'rid',
+            'relationship field' => 'rid',
             'handler' => 'relation_handler_relationship', // To choose the r_index option.
             'relation_type' => $type, // USE THIS as bundle
+            'entity_type_left' => 'field_data_endpoints', // Not used.
             'entity_type_right' => $entity_type_right, // Use this as endpoint_entity_type.
-            'directional' => $relation_type->directional,
+            'directional' => $relation_type->directional, // Not used.
             'max_arity' => $relation_type->max_arity,
             'join_handler' => 'relation_handler_relation_endpoint_join', // To add the r_index condition to join.
           ),
         );
+
         if ($entity_type_right != 'relation') {
-          // Define join and relationship from endpoints to entity.
+          // Define join from endpoints to "right" entity.
           $data['field_data_endpoints']['table']['join'] += array(
             // Directly links to the $entity_type_right table.
             $entity_type_right => array(
@@ -220,33 +266,59 @@ function relation_views_data() {
             ),
           );
         }
+        // Define relationship from endpoints to "right" entity.
         $data['field_data_endpoints']['endpoints_base_' . $type . '_right_' . $entity_type_right] = array(
-          'title' => t('endpoints[@relation_type_label] -> @right)', $t_arguments),
+          'title' => t('@relation_type_label (endpoints -> @right)', $t_arguments),
           'help' => t('Endpoints table to @right using "@relation_type_label" relation', $t_arguments),
           'relationship' => array(
-            'label' => check_plain('Endpoints::' . $relation_type->label),
+            // relation_handler_relationship::options_form() relies on this check_plain().
+            'label' => check_plain($entity_type_right . '::' . $relation_type->label),
             'base' => $base_table_right,
             'base field' => $entity_infos[$entity_type_right]['entity keys']['id'],
             'relationship field' => 'endpoints_entity_id',
           ),
         );
 
-        // Define [join and] relationship from endpoints to endpoints.
-        $data['field_data_endpoints']['endpoints_base_' . $type . '_right_endpoints_' . $entity_type_right] = array(
-          'title' => t('@left -> endpoints[@relation_type_label])', $t_arguments),
-          'help' => t('@left to the sibling endpoints using the "@relation_type_label" relation', $t_arguments),
+        // Define relationship from endpoints to endpoints.
+        $data['field_data_endpoints']['endpoints_base_' . $type . '_right_endpoints'] = array(
+          'title' => t('@relation_type_label (endpoints -> endpoints)', $t_arguments),
+          'help' => t('Endpoints table (@left) to sibling endpoints (@right) using the "@relation_type_label" relation', $t_arguments),
           'relationship' => array(
             // relation_handler_relationship::options_form() relies on this check_plain().
             'label' => check_plain('Endpoints::' . $relation_type->label),
             'base' => 'field_data_endpoints',
             'base field' => 'entity_id',
+            'relationship field' => 'entity_id',
             'handler' => 'relation_handler_relationship',
             'relation_type' => $type, // USE THIS as bundle
+            'entity_type_left' => $entity_type_left,
             'entity_type_right' => $entity_type_right, // Use this as endpoint_entity_type.
-            'directional' => $relation_type->directional,
+            'directional' => $relation_type->directional, // Not used.
+            'max_arity' => $relation_type->max_arity, // Is this needed?
             'join_handler' => 'relation_handler_endpoint_endpoint_join',
           ),
         );
+
+        // Define relationship from entity to endpoints.
+        $data[$base_table_right][$entity_type_right . '_base_' . $type . '_right_endpoints'] = array(
+          'title' => t('Endpoints: @relation_type_label (@right -> endpoints)', $t_arguments),
+          'help' => t('Provides a relationship from @right to the endpoints table relative to the "@relation_type_label" relation', $t_arguments),
+          'relationship' => array(
+            // relation_handler_relationship::options_form() relies on this check_plain().
+            'label' => check_plain('Endpoints::' . $relation_type->label),
+            'base' => 'field_data_endpoints',
+            'base field' => 'endpoints_entity_id',
+            'relationship field' => $entity_infos[$entity_type_right]['entity keys']['id'],
+
+            'handler' => 'relation_handler_relationship', // To choose the r_index option.
+            'relation_type' => $type, // USE THIS as bundle
+            'entity_type_left' => 'field_data_endpoints', // Not used.
+            'entity_type_right' => $entity_type_right, // Use this as endpoint_entity_type.
+            'directional' => $relation_type->directional, // Not used.
+            'max_arity' => $relation_type->max_arity,
+            'join_handler' => 'relation_handler_entity_endpoint_join', // To add the r_index condition to join.
+          ),
+        );
       }
     }
   }
diff --git a/views/relation_handler_endpoint_entity_join.inc b/views/relation_handler_endpoint_entity_join.inc
index e69de29..69b9931 100644
--- a/views/relation_handler_endpoint_entity_join.inc
+++ b/views/relation_handler_endpoint_entity_join.inc
@@ -0,0 +1,131 @@
+<?php
+
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+/**
+ * Join handler: relationship from endpoints to "right" entity.
+ */
+class relation_handler_endpoint_entity_join extends views_join{
+
+  /**
+   * Get join  condition from parent. This is not a good idea. Any better idea ?
+   *
+   * @param type $select_query
+   * @param type $table
+   * @param type $view_query
+   * @return type
+   */
+  function parent_condition($select_query, $table, $view_query)
+  {
+    if (empty($this->definition['table formula'])) {
+      $right_table = $this->table;
+    }
+    else {
+      $right_table = $this->definition['table formula'];
+    }
+
+    if ($this->left_table) {
+      $left = $view_query->get_table_info($this->left_table);
+      $left_field = "$left[alias].$this->left_field";
+    }
+    else {
+      // This can be used if left_field is a formula or something. It should be used only *very* rarely.
+      $left_field = $this->left_field;
+    }
+
+    $condition = "$left_field = $table[alias].$this->field";
+    $arguments = array();
+
+    // Tack on the extra.
+    if (isset($this->extra)) {
+      if (is_array($this->extra)) {
+        $extras = array();
+        foreach ($this->extra as $info) {
+          $extra = '';
+          // Figure out the table name. Remember, only use aliases provided
+          // if at all possible.
+          $join_table = '';
+          if (!array_key_exists('table', $info)) {
+            $join_table = $table['alias'] . '.';
+          }
+          elseif (isset($info['table'])) {
+            $join_table = $info['table'] . '.';
+          }
+
+          // Convert a single-valued array of values to the single-value case,
+          // and transform from IN() notation to = notation
+          if (is_array($info['value']) && count($info['value']) == 1) {
+            if (empty($info['operator'])) {
+              $operator = '=';
+            }
+            else {
+              $operator = $info['operator'] == 'NOT IN' ? '!=' : '=';
+            }
+            $info['value'] = array_shift($info['value']);
+          }
+
+          if (is_array($info['value'])) {
+            // With an array of values, we need multiple placeholders and the
+            // 'IN' operator is implicit.
+            foreach ($info['value'] as $value) {
+              $placeholder_i = ':views_join_condition_' . $select_query->nextPlaceholder();
+              $arguments[$placeholder_i] = $value;
+            }
+
+            $operator = !empty($info['operator']) ? $info['operator'] : 'IN';
+            $placeholder = '( ' . implode(', ', array_keys($arguments)) . ' )';
+          }
+          else {
+            // With a single value, the '=' operator is implicit.
+            $operator = !empty($info['operator']) ? $info['operator'] : '=';
+            $placeholder = ':views_join_condition_' . $select_query->nextPlaceholder();
+            $arguments[$placeholder] = $info['value'];
+          }
+
+          $extras[] = "$join_table$info[field] $operator $placeholder";
+        }
+
+        if ($extras) {
+          if (count($extras) == 1) {
+            $condition .= ' AND ' . array_shift($extras);
+          }
+          else {
+            $condition .= ' AND (' . implode(' ' . $this->extra_type . ' ', $extras) . ')';
+          }
+        }
+      }
+      elseif ($this->extra && is_string($this->extra)) {
+        $condition .= " AND ($this->extra)";
+      }
+    }
+    return $condition;
+  }
+  /**
+   * Overwrite build join method. \
+   * Add condition "Relation type"
+   *
+   * @param type $select_query
+   * @param type $table
+   * @param type $view_query
+   */
+  function build_join($select_query, $table, $view_query)
+  {
+    $conditions=$this->parent_condition($select_query, $table, $view_query);
+    // additional condition
+    //dpm($this,'this');
+    $entity_type_field_name = _field_sql_storage_columnname('endpoints', 'entity_type');
+    $entity_bundle_field_name = _field_sql_storage_columnname('endpoints', 'bundle');
+    $r_index_field_name = _field_sql_storage_columnname('endpoints', 'r_index');
+
+    $relation_type = $this->definition['relation_type'];
+    // The aliased name of the existing endpoint table we are joining to.
+    $l = $this->left_table;
+    // The aliased name of the current endpoint table.
+    $r = $table['alias'];
+    // add relation type condition
+    $conditions .= " AND $r.bundle = '$relation_type' ";
+    $select_query->addJoin($this->type, $table['table'], $table['alias'], $conditions);
+  }
+}
diff --git a/views/relation_handler_relationship.inc b/views/relation_handler_relationship.inc
index 8344c1c..3da01dc 100644
--- a/views/relation_handler_relationship.inc
+++ b/views/relation_handler_relationship.inc
@@ -5,6 +5,9 @@
  * Views relationship support.
  */
 
+/**
+ * Base join handler defining options available to use with the join.
+ */
 class relation_handler_relationship extends views_handler_relationship {
   /**
    * Define r_index option.
@@ -46,6 +49,9 @@ class relation_handler_relationship extends views_handler_relationship {
   }
 }
 
+/**
+ * Handler used to join the field_data_endpoints table to the field_data_endpoints table.
+ */
 class relation_handler_endpoint_endpoint_join extends views_join {
   /**
    * Build the SQL for the join this object represents.
@@ -56,6 +62,7 @@ class relation_handler_endpoint_endpoint_join extends views_join {
     $entity_type_field_name = _field_sql_storage_columnname('endpoints', 'entity_type');
     $r_index_field_name = _field_sql_storage_columnname('endpoints', 'r_index');
 
+    $entity_type_left = $this->definition['entity_type_left'];
     $entity_type_right = $this->definition['entity_type_right'];
     $relation_type = $this->definition['relation_type'];
 
@@ -71,10 +78,16 @@ class relation_handler_endpoint_endpoint_join extends views_join {
     $conditions = "$r.entity_id = $l.entity_id AND $r.$r_index_field_name != $l.$r_index_field_name";
     if ($this->options['r_index'] > -1) {
       // Grab a specific index.
-      $conditions .= " AND $l.$r_index_field_name = " . $this->options['r_index'];
+      $conditions .= " AND $r.$r_index_field_name = " . $this->options['r_index'];
+      if ($this->options['r_index'] == 0) {
+        // Restrict the join to the proper entity type and bundle.
+        $conditions .= " AND $r.$entity_type_field_name = '$entity_type_left' AND $r.bundle = '$relation_type'";
+      }
+      elseif ($this->options['r_index'] == 1) {
+        // Restrict the join to the proper entity type and bundle.
+        $conditions .= " AND $r.$entity_type_field_name = '$entity_type_right' AND $r.bundle = '$relation_type'";
+      }
     }
-    // Restrict the join to the proper entity type and bundle.
-    $conditions .= " AND $r.$entity_type_field_name = '$entity_type_right' AND $r.bundle = '$relation_type'";
 
     // Add a self-join.
     $select_query->addJoin($this->type, $table['table'], $table['alias'], $conditions);
@@ -82,13 +95,11 @@ class relation_handler_endpoint_endpoint_join extends views_join {
 }
 
 /**
- * Join handler which is used to join from relation table to the field_data_endpoints table.
+ * Handler used to join the relation table to the field_data_endpoints table.
  */
 class relation_handler_relation_endpoint_join extends views_join {
   /**
    * Construct the views_join object.
-   *
-   * This does a relation to endpoint join.
    */
   function construct($table = NULL, $left_table = NULL, $left_field = NULL, $field = NULL, $extra = array(), $type = 'LEFT') {
     parent::construct($table, $left_table, $left_field, $field, $extra, $type);
@@ -98,3 +109,22 @@ class relation_handler_relation_endpoint_join extends views_join {
     }
   }
 }
+
+/**
+ * Handler used to join the entity table to the field_data_endpoints table.
+ */
+class relation_handler_entity_endpoint_join extends views_join {
+  /**
+   * Construct the views_join object.
+   */
+  function construct($table = NULL, $left_table = NULL, $left_field = NULL, $field = NULL, $extra = array(), $type = 'LEFT') {
+    parent::construct($table, $left_table, $left_field, $field, $extra, $type);
+    $r_index_field_name = _field_sql_storage_columnname('endpoints', 'r_index');
+    $entity_type_field_name = _field_sql_storage_columnname('endpoints', 'entity_type');
+    $this->extra[] = array('field' => 'bundle', 'value' => $this->definition['relation_type']);
+    $this->extra[] = array('field' => 'endpoints_entity_type', 'value' => $this->definition['entity_type_right']);
+    if ($this->options['r_index'] > -1) {
+      $this->extra[] = array('field' => $r_index_field_name, 'value' => $this->options['r_index']);
+    }
+  }
+}
