Index: /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Algorithms/ExtremePointAlgorithm.cs
===================================================================
--- /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Algorithms/ExtremePointAlgorithm.cs	(revision 15584)
+++ /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/Algorithms/ExtremePointAlgorithm.cs	(revision 15585)
@@ -205,5 +205,5 @@
                   SortingMethod[] sortings, 
                   FittingMethod[] fittings,
-                  ExtremePointCreationMethod[] ePGeneration,
+                  ExtremePointCreationMethod[] epCreationMethods,
                   CancellationToken token) {
       SortingMethod? bestSorting = null;
@@ -214,5 +214,5 @@
       foreach (var fit in fittings) {
         foreach (var sort in sortings) {
-          foreach (var epCreation in ePGeneration) {
+          foreach (var epCreation in epCreationMethods) {
             IDecoder<Permutation> decoder = new ExtremePointPermutationDecoder() {
               FittingMethod = fit,
Index: /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/ExtremePointCreation/ExtremePointCreator.cs
===================================================================
--- /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/ExtremePointCreation/ExtremePointCreator.cs	(revision 15584)
+++ /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/ExtremePointCreation/ExtremePointCreator.cs	(revision 15585)
@@ -20,5 +20,5 @@
 
     /// <summary>
-    /// Updates the residual space for a given bin packing
+    /// Updates the residual space for a given bin packing.
     /// </summary>
     /// <param name="binPacking"></param>
@@ -26,4 +26,11 @@
     /// <param name="position"></param>
     protected abstract void UpdateResidualSpace(BinPacking3D binPacking, PackingItem item, PackingPosition position);
+
+    /// <summary>
+    /// Adds an extreme point to the bin packing.
+    /// </summary>
+    /// <param name="binPacking"></param>
+    /// <param name="position"></param>
+    /// <returns></returns>
     protected abstract bool AddExtremePoint(BinPacking3D binPacking, PackingPosition position);
 
@@ -214,9 +221,9 @@
 
     /// <summary>
-    /// Returns true, if the given poisition and the related residual space is within the residual space of the given extreme point
-    /// </summary>
-    /// <param name="pos"></param>
+    /// Returns true, if the given poisition (pos) and the related residual space is within any residual space of the given extreme point (ep).
+    /// </summary>
+    /// <param name="pos">Given poisition</param>
     /// <param name="rsPos"></param>
-    /// <param name="ep"></param>
+    /// <param name="ep">Given extreme point</param>
     /// <param name="rsEp"></param>
     /// <returns></returns>
@@ -226,15 +233,22 @@
 
     /// <summary>
-    /// Returns true, if the given poisition and the related residual space is within the residual space of the given extreme point
-    /// </summary>
-    /// <param name="pos"></param>
+    /// Returns true, if the given poisition (pos) and the related residual space is within the residual space of the given extreme point (ep).
+    /// </summary>
+    /// <param name="pos">Given poisition</param>
     /// <param name="rsPos"></param>
-    /// <param name="ep"></param>
+    /// <param name="ep">Given extreme point</param>
     /// <param name="rsEp"></param>
     /// <returns></returns>
     protected virtual bool IsWithinResidualSpaceOfAnotherExtremePoint(Vector3D pos, ResidualSpace rsPos, PackingPosition ep, ResidualSpace rsEp) {
+      /*old implementation
       return rsEp.Width >= pos.X - ep.X + rsPos.Width
           && rsEp.Height >= pos.Y - ep.Y + rsPos.Height
-          && rsEp.Depth >= pos.Z - ep.Z + rsPos.Depth;
+          && rsEp.Depth >= pos.Z - ep.Z + rsPos.Depth;*/
+
+      var x = pos.X >= ep.X && pos.X + rsPos.Width <= ep.X + rsEp.Width;
+      var y = pos.Y >= ep.Y && pos.Y + rsPos.Height <= ep.Y + rsEp.Height;
+      var z = pos.Z >= ep.Z && pos.Z + rsPos.Depth <= ep.Z + rsEp.Depth;
+
+      return x && y && z;
     }
 
Index: /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/ExtremePointCreation/LineProjectionBasedEPCreator.cs
===================================================================
--- /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/ExtremePointCreation/LineProjectionBasedEPCreator.cs	(revision 15584)
+++ /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/ExtremePointCreation/LineProjectionBasedEPCreator.cs	(revision 15585)
@@ -23,49 +23,53 @@
         GenerateNewExtremePointsForItem(binPacking, it, p);
       }
-    }
-
-    /// <summary>
-    /// Adds a new extreme point an the related residual spaces to a given bin packing.
-    /// - The given position has to be valid.
-    /// - The extreme point does not exist in the bin packing.
-    /// - There must be at minimum one valid residual space. A residual space is invalid if the space is zero.
-    /// </summary>
-    /// <param name="binPacking"></param>
-    /// <param name="position"></param>
-    /// <returns>True = the given point and its related residual spaces were successfully added to the bin packing</returns>
-    protected override bool AddExtremePoint(BinPacking3D binPacking, PackingPosition position) {
-      if (position == null) {
-        return false;
-      }
-
-      if (PointIsInAnyItem(binPacking, new Vector3D(position))) {
-        return false;
-      }
-
-      if (binPacking.ExtremePoints.ContainsKey(position)) {
-        return false;
-      }
-
-      var rs = CalculateResidualSpace(binPacking, new Vector3D(position));
-
-      if (rs.Count() <= 0) {
-        return false;
-      }
-
-      // todo 
-      /*
-       ist der extrempunkt im residual space eines anderen muss ueberprueft werden:
-          - ist der andere ep in der luft, kann auch dieser hinzugefuegt werden.
-          - hat der andere ep ein item unterhalb, darf dieser nicht hinzugefuegt werden.
-       -> neu methode basierend auf IsWithinResidualSpaceOfAnotherExtremePoint, die den ep oder rs zurueck gibt, der einen anderen rs einschließt.
-          eventuell gehoert diese logik in den ResidualSpaceCreator.
-      if (LiesOnAnyItem(binPacking, position)) {
-        return false;
-      }*/
-
-      binPacking.ExtremePoints.Add(position, rs);
-      return true;
-    }
-
+     
+      // remove not needed extreme points.
+      foreach (var extremePoint in binPacking.ExtremePoints.ToList()) {
+        // check if a residual space can be removed
+        foreach (var rs in extremePoint.Value.ToList()) {
+          if (ResidualSpaceCanBeRemoved(binPacking, extremePoint.Key, rs)) {
+            ((IList<ResidualSpace>)extremePoint.Value).Remove(rs);
+          }
+        }
+        // if the current extreme point has no more residual spaces, it can be removed.
+        if (((IList<ResidualSpace>)extremePoint.Value).Count <= 0) {
+          binPacking.ExtremePoints.Remove(extremePoint);
+        }
+      }
+    }
+    
+    /// <summary>
+    /// Returns true if a given residual space can be removed.
+    /// The given residual space can be removed if it is within another residual space and
+    /// - neither the position of the other residual space and the current extreme point have an item below or
+    /// - the current extreme point has an item below.
+    /// </summary>
+    /// <param name="binPacking"></param>
+    /// <param name="position"></param>
+    /// <param name="rs"></param>
+    /// <returns></returns>
+    private bool ResidualSpaceCanBeRemoved(BinPacking3D binPacking, PackingPosition position, ResidualSpace rs) {
+      foreach (var extremePoint in binPacking.ExtremePoints) {
+        if (position.Equals(extremePoint.Key)) {
+          continue;
+        }
+        if (IsWithinResidualSpaceOfAnotherExtremePoint(new Vector3D(position), rs, extremePoint.Key, extremePoint.Value)) {
+          var itemBelowEp = LiesOnAnyItem(binPacking, extremePoint.Key);
+          var itemBelowPos = LiesOnAnyItem(binPacking, position);
+
+          if (itemBelowEp || !itemBelowEp && !itemBelowPos) {
+            return true;
+          }          
+        }
+      }
+      return false;
+    }
+    
+    /// <summary>
+    /// Returns true if the given position lies on an item or an the ground.
+    /// </summary>
+    /// <param name="binPacking"></param>
+    /// <param name="position"></param>
+    /// <returns></returns>
     private bool LiesOnAnyItem(BinPacking3D binPacking, PackingPosition position) {
       if (position.Y == 0) {
@@ -85,4 +89,37 @@
 
       return items.Count() > 0;
+    }
+
+
+    /// <summary>
+    /// Adds a new extreme point an the related residual spaces to a given bin packing.
+    /// - The given position has to be valid.
+    /// - The extreme point does not exist in the bin packing.
+    /// - There must be at minimum one valid residual space. A residual space is invalid if the space is zero.
+    /// </summary>
+    /// <param name="binPacking"></param>
+    /// <param name="position"></param>
+    /// <returns>True = the given point and its related residual spaces were successfully added to the bin packing</returns>
+    protected override bool AddExtremePoint(BinPacking3D binPacking, PackingPosition position) {
+      if (position == null) {
+        return false;
+      }
+
+      if (PointIsInAnyItem(binPacking, new Vector3D(position))) {
+        return false;
+      }
+
+      if (binPacking.ExtremePoints.ContainsKey(position)) {
+        return false;
+      }
+
+      var rs = CalculateResidualSpace(binPacking, new Vector3D(position));
+
+      if (rs.Count() <= 0) {
+        return false;
+      }
+
+      binPacking.ExtremePoints.Add(position, rs);
+      return true;
     }
 
Index: /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/ResidualSpaceCalculation/ResidualSpaceCalculator.cs
===================================================================
--- /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/ResidualSpaceCalculation/ResidualSpaceCalculator.cs	(revision 15584)
+++ /branches/2817-BinPackingSpeedup/HeuristicLab.Problems.BinPacking/3.3/3D/ResidualSpaceCalculation/ResidualSpaceCalculator.cs	(revision 15585)
@@ -19,6 +19,5 @@
       if (!rs1.IsZero()) {
         residualSpaces.Add(rs1);
-      }     
-
+      }
 
       if (!rs2.IsZero() && !residualSpaces.Any(rs => rs.Equals(rs2))) {
@@ -31,4 +30,13 @@
     }
 
+    /// <summary>
+    /// Calculates a resiual space by expanding to the limits of the axis in the following order:
+    /// 1. x
+    /// 2. z
+    /// 3. y
+    /// </summary>
+    /// <param name="binPacking"></param>
+    /// <param name="point"></param>
+    /// <returns></returns>
     private ResidualSpace CalculateXZY(BinPacking3D binPacking, Vector3D point) {
       ResidualSpace rs = new ResidualSpace(binPacking, point);
@@ -40,4 +48,13 @@
     }
 
+    /// <summary>
+    /// Calculates a resiual space by expanding to the limits of the axis in the following order:
+    /// 1. z
+    /// 2. y
+    /// 3. x
+    /// </summary>
+    /// <param name="binPacking"></param>
+    /// <param name="point"></param>
+    /// <returns></returns>
     private ResidualSpace CalculateZYX(BinPacking3D binPacking, Vector3D point) {
       ResidualSpace rs = new ResidualSpace(binPacking, point);
@@ -49,4 +66,13 @@
     }
 
+    /// <summary>
+    /// Calculates a resiual space by expanding to the limits of the axis in the following order:
+    /// 1. y
+    /// 2. x
+    /// 3. z
+    /// </summary>
+    /// <param name="binPacking"></param>
+    /// <param name="point"></param>
+    /// <returns></returns>
     private ResidualSpace CalculateYXZ(BinPacking3D binPacking, Vector3D point) {
       ResidualSpace rs = new ResidualSpace(binPacking, point);
@@ -114,5 +140,5 @@
 
     private bool OverlapsOnRight(Vector3D point, ResidualSpace residualSpace, PackingPosition position, PackingItem item) {
-      // if point.x >= position.x, the residual space would be located on the left side!
+      // if point.x >= position.x => the residual space is being located on the left side!
       if (point.X >= position.X) {
         return false;
@@ -133,4 +159,5 @@
     }
 
+
     private bool OverlapsAbove(Vector3D point, ResidualSpace residualSpace, PackingPosition position, PackingItem item ) {
       if (point.Y >= position.Y) {
@@ -142,5 +169,13 @@
       return x && z;
     }
-    
+
+    /// <summary>
+    /// Recalculates the width of a given residual space.
+    /// The new width is being limited by any item right of the residual space or the dimension of the bin shape.
+    /// If the new width is zero, the whole residual space is being set to zero.
+    /// </summary>
+    /// <param name="binPacking"></param>
+    /// <param name="point"></param>
+    /// <param name="residualSpace"></param>
     private void LimitResidualSpaceOnRight(BinPacking3D binPacking, Vector3D point, ResidualSpace residualSpace) {
       if (residualSpace.IsZero()) {
@@ -163,4 +198,12 @@
     }
 
+    /// <summary>
+    /// Recalculates the depth of a given residual space.
+    /// The new depth is being limited by any item in front of the residual space or the dimension of the bin shape.
+    /// If the new depth is zero, the whole residual space is being set to zero.
+    /// </summary>
+    /// <param name="binPacking"></param>
+    /// <param name="point"></param>
+    /// <param name="residualSpace"></param>
     private void LimitResidualSpaceInFront(BinPacking3D binPacking, Vector3D point, ResidualSpace residualSpace) {
       if (residualSpace.IsZero()) {
@@ -183,4 +226,12 @@
     }
 
+    /// <summary>
+    /// Recalculates the height of a given residual space.
+    /// The new height is being limited by any item above the residual space or the dimension of the bin shape.
+    /// If the new height is zero, the whole residual space is being set to zero.
+    /// </summary>
+    /// <param name="binPacking"></param>
+    /// <param name="point"></param>
+    /// <param name="residualSpace"></param>
     private void LimitResidualSpaceAbove(BinPacking3D binPacking, Vector3D point, ResidualSpace residualSpace) {
       if (residualSpace.IsZero()) {
Index: /branches/2817-BinPackingSpeedup/HeuristicLab.Tests/HeuristicLab.Problems.Bin-Packing-3.3/3D/Algorithms/ExtremePointAlgorithmTest.cs
===================================================================
--- /branches/2817-BinPackingSpeedup/HeuristicLab.Tests/HeuristicLab.Problems.Bin-Packing-3.3/3D/Algorithms/ExtremePointAlgorithmTest.cs	(revision 15584)
+++ /branches/2817-BinPackingSpeedup/HeuristicLab.Tests/HeuristicLab.Problems.Bin-Packing-3.3/3D/Algorithms/ExtremePointAlgorithmTest.cs	(revision 15585)
@@ -74,10 +74,15 @@
       };
 
-      object[] parameters = new object[] { _packingShape3, _items, new SortingMethod[] { SortingMethod.Given }, new FittingMethod[] { FittingMethod.FirstFit }, new CancellationToken() };
+      object[] parameters = new object[] { _packingShape3,
+                                           _items,
+                                           new SortingMethod[] { SortingMethod.Given },
+                                           new FittingMethod[] { FittingMethod.FirstFit },
+                                           new ExtremePointCreationMethod[] { ExtremePointCreationMethod.PointProjection},
+                                           new CancellationToken() };
       _extremPointAlgorithm.SortingMethodParameter.Value.Value = SortingMethod.Given;
       _extremPointAlgorithm.FittingMethodParameter.Value.Value = FittingMethod.FirstFit;
       _extremPointAlgorithm.ExtremePointCreationMethodParameter.Value.Value = ExtremePointCreationMethod.PointProjection;
       _extremPointAlgorithm.SortByMaterialParameter.Value.Value = false;
-      var result = TestUtils.InvokeMethod(typeof(ExtremePointAlgorithm), _extremPointAlgorithm, "GetBest", parameters) as Tuple<Solution, double, SortingMethod?, FittingMethod?>;
+      var result = TestUtils.InvokeMethod(typeof(ExtremePointAlgorithm), _extremPointAlgorithm, "GetBest", parameters) as Tuple<Solution, double, SortingMethod?, FittingMethod?, ExtremePointCreationMethod?>;
 
       int i = 0;
Index: /branches/2817-BinPackingSpeedup/HeuristicLab.Tests/HeuristicLab.Problems.Bin-Packing-3.3/3D/Instances/RandomInstanceProviderTest.cs
===================================================================
--- /branches/2817-BinPackingSpeedup/HeuristicLab.Tests/HeuristicLab.Problems.Bin-Packing-3.3/3D/Instances/RandomInstanceProviderTest.cs	(revision 15584)
+++ /branches/2817-BinPackingSpeedup/HeuristicLab.Tests/HeuristicLab.Problems.Bin-Packing-3.3/3D/Instances/RandomInstanceProviderTest.cs	(revision 15585)
@@ -170,10 +170,13 @@
         //foreach (FittingMethod fittingMethod in Enum.GetValues(typeof(FittingMethod))) {
         FittingMethod fittingMethod = FittingMethod.FirstFit;
-        TestExtremePointAlgorithmByParameters(randomInstanceProvider, @class, sortingMethod, fittingMethod);
+        foreach (ExtremePointCreationMethod epCreationMethod in Enum.GetValues(typeof(ExtremePointCreationMethod))) {
+          TestExtremePointAlgorithmByParameters(randomInstanceProvider, @class, sortingMethod, fittingMethod, epCreationMethod);
+        }
+        
         //}
       }
     }
 
-    private void TestExtremePointAlgorithmByParameters(RandomInstanceProvider randomInstanceProvider, int @class, SortingMethod sortingMethod, FittingMethod fittingMethod) {
+    private void TestExtremePointAlgorithmByParameters(RandomInstanceProvider randomInstanceProvider, int @class, SortingMethod sortingMethod, FittingMethod fittingMethod, ExtremePointCreationMethod epCreationMethod) {
       var dataDescriptors = randomInstanceProvider.GetDataDescriptors();
       var referenceValues = GetReferenceAlgorithmValues();
@@ -189,4 +192,5 @@
           algorithm.SortingMethodParameter.Value.Value = sortingMethod;
           algorithm.FittingMethodParameter.Value.Value = fittingMethod;
+          algorithm.ExtremePointCreationMethodParameter.Value.Value = epCreationMethod;
           algorithm.Problem.Load(packingData);
 
@@ -207,5 +211,5 @@
 
         if (referenceValues.TryGetValue(new Tuple<int, int, SortingMethod>(@class, numItems, sortingMethod), out referenceValue)) {
-          Console.WriteLine($"{numItems}-{@class}-{sortingMethod}: \tReference: {referenceValue} \tImplementation: {(double)sumNumberOfBins / (double)NUMBER_OF_TEST_INSTANCES} \t{(referenceValue - ((double)sumNumberOfBins / (double)NUMBER_OF_TEST_INSTANCES)):F2}");
+          Console.WriteLine($"{numItems}-{@class}-{sortingMethod}-{epCreationMethod}: \tReference: {referenceValue} \tImplementation: {(double)sumNumberOfBins / (double)NUMBER_OF_TEST_INSTANCES} \t{(referenceValue - ((double)sumNumberOfBins / (double)NUMBER_OF_TEST_INSTANCES)):F2}");
           Assert.AreEqual(referenceValue, (double)sumNumberOfBins / (double)NUMBER_OF_TEST_INSTANCES, 20.0);
         }
