diff --git a/sites/all/modules/contrib/relation_select/js/relation-select.js b/sites/all/modules/contrib/relation_select/js/relation-select.js
index 70f1732..4313618 100644
--- a/sites/all/modules/contrib/relation_select/js/relation-select.js
+++ b/sites/all/modules/contrib/relation_select/js/relation-select.js
@@ -54,7 +54,7 @@
 
       // Event handler: close button clicked
       function addCloseEventHandlers(context){
-        
+
         $('.relation-select-close:not(.processed)', context).click(
             handleCloseClick).addClass('processed');
 
@@ -64,7 +64,7 @@
 
       }
 
-      function addRowEventHandlers(context){        
+      function addRowEventHandlers(context){
         // Check selected & add event handler: row clicked
         $('.views-view-relation-select tr', context).once(
             function(){
@@ -132,6 +132,7 @@
         id = $(this).parents('.relation-select-entities').attr("id");
         entitydata = $input.val();
         deselectItem($input, id, entitydata);
+        reindexArray(id);
         return false;
       }
 
@@ -162,7 +163,7 @@
                   'input', relationSelectItems[id]['element']), id, entitydata, $row.parents('.view-content').find('tr.selected'));
               // Select new row
               addInput($row, id, entitydata);
-              selectItem($row, id, entitydata);              
+              selectItem($row, id, entitydata);
             }
 
           } else {
@@ -210,12 +211,13 @@
        * Create an input
        */
       function addInput($row, id, entitydata){
+        $delta = countArity(id)-1;
         // Create a hidden input to mark the new item being selected
         $input = $('<div class="rs-wrapper" />');
         $input.append($('<input type="hidden" value="' + entitydata
             + '" name="'
             + relationSelectItems[id]['element'].attr("data-field-name")
-            + '[]" />'));
+            + '['+$delta+']" />'));
         $input.append(themeValue($row, entitydata));
         addInputRemoveLink($input);
         relationSelectItems[id]['element'].append($input);
@@ -224,13 +226,26 @@
       /**
        * Select a row
        */
-      function selectItem($row, id, entitydata){         
+      function selectItem($row, id, entitydata){
         // Trigger custom event
         relationSelectItems[id]['element'].trigger('selectItem', [id, entitydata]);
         $row.addClass('selected');
       }
 
       /**
+       * Reindexes the table of elements after an element has been removed.
+       */
+      function reindexArray(id) {
+        var $mainElement = $("#" + id);
+        var $elemChildren = $mainElement.children();
+        var index = 0;
+        $elemChildren.each( function( ) {
+          $(this).find("input").attr("name", $mainElement.attr("data-field-name") + '['+ index + ']');
+          index++;
+        });
+      }
+
+      /**
        * De-select a row
        */
       function deselectItem($input, id, entitydata, $row){
