Index: /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/Plugin.cs
===================================================================
--- /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/Plugin.cs	(revision 9598)
+++ /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/Plugin.cs	(revision 9599)
@@ -26,5 +26,5 @@
   /// Plugin class for HeuristicLab.Problems.BinPacking.Views plugin.
   /// </summary>
-  [Plugin("HeuristicLab.Problems.BinPacking.Views", "3.3.7.9596")]
+  [Plugin("HeuristicLab.Problems.BinPacking.Views", "3.3.7.9598")]
   [PluginFile("HeuristicLab.Problems.BinPacking.Views-3.3.dll", PluginFileType.Assembly)]
   [PluginDependency("HeuristicLab.Common", "3.3")]
Index: /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/Properties/AssemblyInfo.cs
===================================================================
--- /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/Properties/AssemblyInfo.cs	(revision 9598)
+++ /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.Views/3.3/Properties/AssemblyInfo.cs	(revision 9599)
@@ -54,3 +54,3 @@
 // by using the '*' as shown below:
 [assembly: AssemblyVersion("3.3.0.0")]
-[assembly: AssemblyFileVersion("3.3.7.9596")]
+[assembly: AssemblyFileVersion("3.3.7.9598")]
Index: /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/MultiComponentVector/BinBasedMultiComponentVectorCrossover.cs
===================================================================
--- /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/MultiComponentVector/BinBasedMultiComponentVectorCrossover.cs	(revision 9598)
+++ /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/MultiComponentVector/BinBasedMultiComponentVectorCrossover.cs	(revision 9599)
@@ -46,4 +46,5 @@
 
       int nrOfItems = parent1.NrOfItems;
+
       bool[] itemAlreadyAssigned = new bool[nrOfItems];
       int nrOfBins = parent1.NrOfBins > parent2.NrOfBins ? parent2.NrOfBins : parent1.NrOfBins;
@@ -82,6 +83,5 @@
         if (!itemAlreadyAssigned[itemID])
           child.PackingInformations[0].Add(new PackingInformation(itemID, random.Next(2) == 0 ? true : false));
-      }
-
+      }                
 
       return child;
Index: /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/MultiComponentVector/SequenceBasedMultiComponentVectorCrossover.cs
===================================================================
--- /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/MultiComponentVector/SequenceBasedMultiComponentVectorCrossover.cs	(revision 9598)
+++ /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/MultiComponentVector/SequenceBasedMultiComponentVectorCrossover.cs	(revision 9599)
@@ -92,5 +92,4 @@
           child.PackingInformations[0].Add(new PackingInformation(itemID, random.Next(2) == 0 ? true : false));
       }
-
       
       return child;
Index: /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/MultiComponentVector/ThreeWayMultiComponentVectorManipulator.cs
===================================================================
--- /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/MultiComponentVector/ThreeWayMultiComponentVectorManipulator.cs	(revision 9598)
+++ /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/MultiComponentVector/ThreeWayMultiComponentVectorManipulator.cs	(revision 9599)
@@ -58,5 +58,5 @@
         if (individual.NrOfBins > 1)
           do { targetBin = random.Next(individual.NrOfBins); }
-          while (targetBin != affectedBin);
+          while (targetBin == affectedBin);
         individual.PackingInformations = SingleGroupingMove.GetVectorAfterMove(individual, affectedBin, affectedIndex, targetBin).PackingInformations;
       }
@@ -67,5 +67,5 @@
         if (nrOfItems > 1)
           do { targetIndex = random.Next(nrOfItems); }
-          while (targetIndex != affectedIndex);
+          while (targetIndex == affectedIndex);
         individual.PackingInformations = ChangePositionMove.GetVectorAfterMove(individual, affectedBin, affectedIndex, targetIndex).PackingInformations;
       }
Index: /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/BinPacking.cs
===================================================================
--- /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/BinPacking.cs	(revision 9598)
+++ /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/BinPacking.cs	(revision 9599)
@@ -54,8 +54,10 @@
 
     [Storable]
-    public HashSet<D> ExtremePoints { get; protected set; }
+    //public HashSet<D> ExtremePoints { get; protected set; }
+    public SortedSet<D> ExtremePoints { get; protected set; }
 
-    //[Storable]
-    //public OccupiedPoints<D, B, I> OccupiedPoints { get; protected set; }
+    [Storable]
+    protected Dictionary<int, List<int>> OccupationLayers { get; set; }
+
     #endregion Properties
 
@@ -64,7 +66,8 @@
       ItemMeasures = new ObservableDictionary<int, I>();
       BinMeasures = (B)binMeasures.Clone();
-      ExtremePoints = new HashSet<D>();
-      ExtremePoints.Add(binMeasures.Origin);
+      OccupationLayers = new Dictionary<int, List<int>>();
+      InitializeOccupationLayers();
     }
+
 
     [StorableConstructor]
@@ -75,4 +78,5 @@
       this.ItemMeasures = new ObservableDictionary<int, I>(original.ItemMeasures);
         this.BinMeasures = (B)original.BinMeasures.Clone(cloner);
+        this.OccupationLayers = new Dictionary<int, List<int>>(original.OccupationLayers);
     }
    
@@ -91,6 +95,12 @@
       ItemPositions[itemID] = position;
       ExtremePoints.Remove(position);
-      GenerateNewExtremePointsForNewItem(measures, position);
+      foreach (int id in ItemMeasures.Select(x => x.Key))
+        GenerateNewExtremePointsForNewItem(ItemMeasures[id], ItemPositions[id]);
+      
+       
+      //GenerateNewExtremePointsForNewItem(measures, position);
       //OccupiedPoints.OccupyPoints(measures, position, itemID);
+
+      AddNewItemToOccupationLayers(itemID, measures, position);
     }
 
@@ -107,24 +117,37 @@
 
     public int PointOccupation(D position) {
-      foreach (var ipEntry in ItemPositions) {
-        if (ItemMeasures[ipEntry.Key].EnclosesPoint(ipEntry.Value, position))
-          return ipEntry.Key;
+      //foreach (var ipEntry in ItemPositions) {
+      //  if (ItemMeasures[ipEntry.Key].EnclosesPoint(ipEntry.Value, position))
+      //    return ipEntry.Key;
+      //}
+      foreach (var id in GetLayerItemIDs(position)) {
+        if (ItemMeasures[id].EnclosesPoint(ItemPositions[id], position))
+          return id;
       }
       return -1;
     }
+
     public bool IsPointOccupied(D position) {
-      foreach (var ipEntry in ItemPositions) {
-        if (ItemMeasures[ipEntry.Key].EnclosesPoint(ipEntry.Value, position))
+      //foreach (var ipEntry in ItemPositions) {
+      //  if (ItemMeasures[ipEntry.Key].EnclosesPoint(ipEntry.Value, position))
+      //    return true;
+      //}      
+      foreach (var id in GetLayerItemIDs(position)) {
+        if (ItemMeasures[id].EnclosesPoint(ItemPositions[id], position))
           return true;
       }
       return false;
     }
-    public bool IsPositionFeasible(I currentItem, D position) {
+    public bool IsPositionFeasible(I measures, D position) {
       //In this case feasability is defined as following: 1. the item fits into the bin-borders; 2. the point is supported by something; 3. the item does not collide with another already packed item
-      if (!BinMeasures.Encloses(position, currentItem))
+      if (!BinMeasures.Encloses(position, measures))
         return false;
 
-      foreach (var ipEntry in ItemPositions) {
-        if (ItemMeasures[ipEntry.Key].Overlaps(ipEntry.Value, position, currentItem))
+      //foreach (var ipEntry in ItemPositions) {
+      //  if (ItemMeasures[ipEntry.Key].Overlaps(ipEntry.Value, position, measures))
+      //    return false;
+      //} 
+      foreach (var id in GetLayerItemIDs(measures, position)) {
+        if (ItemMeasures[id].Overlaps(ItemPositions[id], position, measures))
           return false;
       }
@@ -133,5 +156,11 @@
     }
     public abstract int ShortestPossibleSideFromPoint (D position);
-    public abstract bool IsStaticStable (I item, D position);
+    public abstract bool IsStaticStable (I measures, D position);
+
+
+    protected abstract void InitializeOccupationLayers();
+    protected abstract void AddNewItemToOccupationLayers(int itemID, I measures, D position);
+    protected abstract List<int> GetLayerItemIDs(D position);
+    protected abstract List<int> GetLayerItemIDs(I measures, D position);
   }   
 }
Index: /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/BinPacking2D.cs
===================================================================
--- /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/BinPacking2D.cs	(revision 9598)
+++ /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/BinPacking2D.cs	(revision 9599)
@@ -41,6 +41,9 @@
   public class BinPacking2D : BinPacking<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> {
 
-    public BinPacking2D(RectangularPackingBin binMeasures) : base(binMeasures) {
-      //OccupiedPoints = new OccupiedPoints2D(binMeasures);
+    public BinPacking2D(RectangularPackingBin binMeasures)
+      : base(binMeasures) {
+      //ExtremePoints = new HashSet<TwoDimensionalPacking>();
+      ExtremePoints = new SortedSet<TwoDimensionalPacking>(new EPComparer2D());
+      ExtremePoints.Add(binMeasures.Origin);
     }
     [StorableConstructor]
@@ -48,4 +51,5 @@
     protected BinPacking2D(BinPacking2D original, Cloner cloner)
       : base(original, cloner) {
+      this.ExtremePoints = new SortedSet<TwoDimensionalPacking>(original.ExtremePoints, new EPComparer2D());
     }
     public override IDeepCloneable Clone(Cloner cloner) {
@@ -62,5 +66,5 @@
       if (sourcePointX.X < BinMeasures.Width && sourcePointX.Y < BinMeasures.Height) {
         //Traversing down the y-axis        
-        while (sourcePointX.Y > 0 && (-1).Equals(IsPointOccupied(new TwoDimensionalPacking(0, sourcePointX.X, sourcePointX.Y - 1)))) {
+        while (sourcePointX.Y > 0 && !IsPointOccupied(new TwoDimensionalPacking(0, sourcePointX.X, sourcePointX.Y - 1))) {
           sourcePointX.Y--;
         }
@@ -75,5 +79,5 @@
       if (sourcePointY.X < BinMeasures.Width && sourcePointY.Y < BinMeasures.Height) {
         //Traversing down the x-axis  
-        while (sourcePointY.X > 0 && (-1).Equals(IsPointOccupied(new TwoDimensionalPacking (0,sourcePointY.X - 1, sourcePointY.Y)))) {
+        while (sourcePointY.X > 0 && !IsPointOccupied(new TwoDimensionalPacking (0,sourcePointY.X - 1, sourcePointY.Y))) {
           sourcePointY.X--;
         }
@@ -81,8 +85,10 @@
       }
 
-      ExtremePoints = new HashSet<TwoDimensionalPacking>(ExtremePoints.
-        OrderBy(ep => ep.X).
-        ThenBy(ep => ep.Y).
-        ThenBy(ep => ShortestPossibleSideFromPoint(ep)));
+      //ExtremePoints.RemoveWhere(ep => IsPointOccupied(ep));
+
+      //ExtremePoints = new HashSet<TwoDimensionalPacking>(ExtremePoints.
+      //  OrderBy(ep => ep.X).
+      //  ThenBy(ep => ep.Y).
+      //  ThenBy(ep => ShortestPossibleSideFromPoint(ep)));
     }
 
@@ -190,4 +196,40 @@
       throw new NotImplementedException();
     }
+
+
+    protected override void InitializeOccupationLayers() {
+      for (int i = 0; i*10 <= BinMeasures.Width; i += 1 ) {
+        OccupationLayers[i] = new List<int>();
+      }
+    }
+    protected override void AddNewItemToOccupationLayers(int itemID, RectangularPackingItem measures, TwoDimensionalPacking position) {
+      int x1 = position.X / 10;
+      int x2 = (position.X + (position.Rotated ? measures.Height : measures.Width)) / 10;
+
+      for (int i = x1; i <= x2; i++)
+        OccupationLayers[i].Add(itemID);
+    }
+    protected override List<int> GetLayerItemIDs(TwoDimensionalPacking position) {
+      return OccupationLayers[position.X / 10];
+    }
+    protected override List<int> GetLayerItemIDs(RectangularPackingItem measures, TwoDimensionalPacking position) { 
+      List<int> result = new List<int> ();
+      int x1 = position.X / 10;
+      int x2 = (position.X + (position.Rotated ? measures.Height : measures.Width)) / 10;
+
+      for (int i = x1; i <= x2; i++)
+        result.AddRange(OccupationLayers[i]);
+
+      return result;
+    }
+  }
+  public class EPComparer2D : IComparer<TwoDimensionalPacking> {
+    public int Compare(TwoDimensionalPacking a, TwoDimensionalPacking b) {
+      int result = a.X.CompareTo(b.X);
+      if (result == 0)
+        result = a.Y.CompareTo(b.Y);
+
+      return result;
+    }
   }
 }
Index: /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/BinPacking3D.cs
===================================================================
--- /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/BinPacking3D.cs	(revision 9598)
+++ /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/BinPacking3D.cs	(revision 9599)
@@ -41,6 +41,9 @@
   public class BinPacking3D : BinPacking<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> {
 
-    public BinPacking3D(CuboidPackingBin binMeasures) : base(binMeasures) {
-      //OccupiedPoints = new OccupiedPoints3D(binMeasures);
+    public BinPacking3D(CuboidPackingBin binMeasures)
+      : base(binMeasures) {
+      //ExtremePoints = new HashSet<ThreeDimensionalPacking>();
+      ExtremePoints = new SortedSet<ThreeDimensionalPacking>(new EPComparer3D());
+      ExtremePoints.Add(binMeasures.Origin);
     }
     [StorableConstructor]
@@ -48,5 +51,6 @@
     protected BinPacking3D(BinPacking3D original, Cloner cloner)
       : base(original, cloner) {
-        this.depthWasDoubled = original.depthWasDoubled;
+      this.depthWasDoubled = original.depthWasDoubled;
+      this.ExtremePoints = new SortedSet<ThreeDimensionalPacking>(original.ExtremePoints, new EPComparer3D());
     }
     public override IDeepCloneable Clone(Cloner cloner) {
@@ -63,9 +67,9 @@
         //Traversing down the y-axis            
         ThreeDimensionalPacking current = new ThreeDimensionalPacking(0, sourcePointX.X, sourcePointX.Y, sourcePointX.Z);
-        while (current.Y > 0 && IsPointOccupied(ThreeDimensionalPacking.MoveDown (current))) {
-          current = ThreeDimensionalPacking.MoveDown(current);
-        }
-        ExtremePoints.Add((ThreeDimensionalPacking)current.Clone());
-        while (current.X > 0 && IsPointOccupied(ThreeDimensionalPacking.MoveLeft(current))) {
+        while (current.Y > 0 && !IsPointOccupied(ThreeDimensionalPacking.MoveDown (current))) {
+          current = ThreeDimensionalPacking.MoveDown(current);
+        }
+        ExtremePoints.Add((ThreeDimensionalPacking)current.Clone());
+        while (current.X > 0 && !IsPointOccupied(ThreeDimensionalPacking.MoveLeft(current))) {
           current = ThreeDimensionalPacking.MoveLeft(current);
         }
@@ -74,9 +78,9 @@
         //Traversing down the z-axis                 
         current = new ThreeDimensionalPacking(0, sourcePointX.X, sourcePointX.Y, sourcePointX.Z);
-        while (current.Z > 0 && IsPointOccupied(ThreeDimensionalPacking.MoveBack (current))) {
+        while (current.Z > 0 && !IsPointOccupied(ThreeDimensionalPacking.MoveBack (current))) {
           current = ThreeDimensionalPacking.MoveBack(current);
         }
         ExtremePoints.Add((ThreeDimensionalPacking)current.Clone());
-        while (current.Y > 0 && IsPointOccupied(ThreeDimensionalPacking.MoveDown(current))) {
+        while (current.Y > 0 && !IsPointOccupied(ThreeDimensionalPacking.MoveDown(current))) {
           current = ThreeDimensionalPacking.MoveDown(current);
         }
@@ -92,9 +96,9 @@
         //Traversing down the x-axis          
         ThreeDimensionalPacking current = new ThreeDimensionalPacking(0, sourcePointY.X, sourcePointY.Y, sourcePointY.Z);
-        while (current.X > 0 && IsPointOccupied(ThreeDimensionalPacking.MoveLeft(current))) {
+        while (current.X > 0 && !IsPointOccupied(ThreeDimensionalPacking.MoveLeft(current))) {
           current = ThreeDimensionalPacking.MoveLeft(current);
         }
         ExtremePoints.Add((ThreeDimensionalPacking)current.Clone());
-        while (current.Y > 0 && IsPointOccupied(ThreeDimensionalPacking.MoveDown(current))) {
+        while (current.Y > 0 && !IsPointOccupied(ThreeDimensionalPacking.MoveDown(current))) {
           current = ThreeDimensionalPacking.MoveDown(current);
         }
@@ -103,9 +107,9 @@
         //Traversing down the z-axis                                                                   
         current = new ThreeDimensionalPacking(0, sourcePointY.X, sourcePointY.Y, sourcePointY.Z);
-        while (current.Z > 0 && IsPointOccupied(ThreeDimensionalPacking.MoveBack(current))) {
+        while (current.Z > 0 && !IsPointOccupied(ThreeDimensionalPacking.MoveBack(current))) {
           current = ThreeDimensionalPacking.MoveBack(current);
         }
         ExtremePoints.Add((ThreeDimensionalPacking)current.Clone());
-        while (current.Y > 0 && IsPointOccupied(ThreeDimensionalPacking.MoveDown(current))) {
+        while (current.Y > 0 && !IsPointOccupied(ThreeDimensionalPacking.MoveDown(current))) {
           current = ThreeDimensionalPacking.MoveDown(current);
         }
@@ -122,9 +126,9 @@
         //Traversing down the x-axis                                                                             
         ThreeDimensionalPacking current = new ThreeDimensionalPacking(0, sourcePointZ.X, sourcePointZ.Y, sourcePointZ.Z);
-        while (current.X > 0 && IsPointOccupied(ThreeDimensionalPacking.MoveLeft(current))) {
+        while (current.X > 0 && !IsPointOccupied(ThreeDimensionalPacking.MoveLeft(current))) {
           current = ThreeDimensionalPacking.MoveLeft(current);
         }
         ExtremePoints.Add((ThreeDimensionalPacking)current.Clone());
-        while (current.Y > 0 && IsPointOccupied(ThreeDimensionalPacking.MoveDown(current))) {
+        while (current.Y > 0 && !IsPointOccupied(ThreeDimensionalPacking.MoveDown(current))) {
           current = ThreeDimensionalPacking.MoveDown(current);
         }
@@ -133,9 +137,9 @@
         //Traversing down the y-axis                                                                     
         current = new ThreeDimensionalPacking(0, sourcePointZ.X, sourcePointZ.Y, sourcePointZ.Z);
-        while (current.Y > 0 && IsPointOccupied(ThreeDimensionalPacking.MoveDown(current))) {
-          current = ThreeDimensionalPacking.MoveDown(current);
-        }
-        ExtremePoints.Add((ThreeDimensionalPacking)current.Clone());
-        while (current.X > 0 && IsPointOccupied(ThreeDimensionalPacking.MoveLeft(current))) {
+        while (current.Y > 0 && !IsPointOccupied(ThreeDimensionalPacking.MoveDown(current))) {
+          current = ThreeDimensionalPacking.MoveDown(current);
+        }
+        ExtremePoints.Add((ThreeDimensionalPacking)current.Clone());
+        while (current.X > 0 && !IsPointOccupied(ThreeDimensionalPacking.MoveLeft(current))) {
           current = ThreeDimensionalPacking.MoveLeft(current);
         }
@@ -143,9 +147,11 @@
       }
 
-      ExtremePoints = new HashSet<ThreeDimensionalPacking>(ExtremePoints.
-        OrderBy(ep => ep.Z).
-        ThenBy(ep => ep.X).
-        ThenBy(ep => ep.Y)//.ThenBy(ep => ShortestPossibleSideFromPoint(ep)) 
-        );
+      //ExtremePoints.RemoveWhere(ep => IsPointOccupied (ep));
+
+      //ExtremePoints = new HashSet<ThreeDimensionalPacking>(ExtremePoints.
+      //  OrderBy(ep => ep.Z).
+      //  ThenBy(ep => ep.X).
+      //  ThenBy(ep => ep.Y)//.ThenBy(ep => ShortestPossibleSideFromPoint(ep)) 
+      //  );
     }
 
@@ -281,7 +287,7 @@
 
       if (IsPointOccupied (new ThreeDimensionalPacking (0, position.X, position.Y - 1, position.Z))
-        && IsPointOccupied (new ThreeDimensionalPacking (0, position.X + item.Width, position.Y - 1, position.Z))
-        && IsPointOccupied (new ThreeDimensionalPacking (0, position.X, position.Y - 1, position.Z + item.Depth))
-        && IsPointOccupied (new ThreeDimensionalPacking (0, position.X + item.Width, position.Y - 1, position.Z + item.Depth)))
+        && IsPointOccupied (new ThreeDimensionalPacking (0, position.X + item.Width-1, position.Y - 1, position.Z))
+        && IsPointOccupied (new ThreeDimensionalPacking (0, position.X, position.Y - 1, position.Z + item.Depth-1))
+        && IsPointOccupied (new ThreeDimensionalPacking (0, position.X + item.Width-1, position.Y - 1, position.Z + item.Depth-1)))
         return true;
 
@@ -307,5 +313,4 @@
     }
 
-
     [Storable]
     private bool depthWasDoubled = false;
@@ -336,10 +341,48 @@
 
       if (ItemMeasures[PointOccupation(new ThreeDimensionalPacking(0, ep.X, ep.Y - 1, ep.Z))].SupportsStacking(item)
-        && ItemMeasures[PointOccupation(new ThreeDimensionalPacking(0, ep.X + item.Width, ep.Y - 1, ep.Z))].SupportsStacking(item)
-        && ItemMeasures[PointOccupation(new ThreeDimensionalPacking(0, ep.X, ep.Y - 1, ep.Z + item.Depth))].SupportsStacking(item)
-        && ItemMeasures[PointOccupation(new ThreeDimensionalPacking(0, ep.X + item.Width, ep.Y - 1, ep.Z + item.Depth))].SupportsStacking(item))
+        && ItemMeasures[PointOccupation(new ThreeDimensionalPacking(0, ep.X + item.Width-1, ep.Y - 1, ep.Z))].SupportsStacking(item)
+        && ItemMeasures[PointOccupation(new ThreeDimensionalPacking(0, ep.X, ep.Y - 1, ep.Z + item.Depth-1))].SupportsStacking(item)
+        && ItemMeasures[PointOccupation(new ThreeDimensionalPacking(0, ep.X + item.Width-1, ep.Y - 1, ep.Z + item.Depth-1))].SupportsStacking(item))
         return true;
 
       return false;
+    }    
+    
+
+    protected override void InitializeOccupationLayers() {
+      for (int i = 0; i*10 <= BinMeasures.Depth; i += 1) {
+        OccupationLayers[i] = new List<int>();
+      }
+    }
+    protected override void AddNewItemToOccupationLayers(int itemID, CuboidPackingItem measures, ThreeDimensionalPacking position) {
+      int z1 = position.Z / 10;
+      int z2 = (position.Z + (position.Rotated ? measures.Width : measures.Depth)) / 10;
+
+      for (int i = z1; i <= z2; i++)
+        OccupationLayers[i].Add(itemID);
+    }
+    protected override List<int> GetLayerItemIDs(ThreeDimensionalPacking position) {
+      return OccupationLayers[position.Z / 10];
+    }
+    protected override List<int> GetLayerItemIDs(CuboidPackingItem measures, ThreeDimensionalPacking position) {
+      List<int> result = new List<int>();
+      int z1 = position.Z / 10;
+      int z2 = (position.Z + (position.Rotated ? measures.Width : measures.Depth)) / 10;
+
+      for (int i = z1; i <= z2; i++)
+        result.AddRange(OccupationLayers[i]);
+
+      return result;
+    }
+  }
+  public class EPComparer3D : IComparer<ThreeDimensionalPacking> {
+    public int Compare(ThreeDimensionalPacking a, ThreeDimensionalPacking b) { 
+        int result = a.Z.CompareTo (b.Z);
+      if (result == 0)
+        result = a.X.CompareTo (b.X);
+      if (result == 0)
+        result = a.Y.CompareTo(b.Y);
+
+      return result;
     }
   }
Index: /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/PackingPlan.cs
===================================================================
--- /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/PackingPlan.cs	(revision 9598)
+++ /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Encodings/PackingPlans/PackingPlan.cs	(revision 9599)
@@ -38,4 +38,5 @@
 using HeuristicLab.Encodings.PackingEncoding.GroupingVector;
 using HeuristicLab.Encodings.PackingEncoding.PackingSequence;
+using HeuristicLab.Encodings.IntegerVectorEncoding;
 
 namespace HeuristicLab.Encodings.PackingEncoding.PackingPlan {
@@ -128,4 +129,5 @@
             bp.PackItem(id, itemMeasures[id], position);
             remainingIDs.Remove(id);
+            break;
           }
         }
@@ -142,4 +144,13 @@
       }
       UpdateBinPackings();
+
+      var newSolution = new ObservableDictionary<int,ItemList<PackingInformation>> ();
+      foreach (var bp in BinPackings) {
+        int binIndex = newSolution.Count;
+        newSolution[binIndex] = new ItemList<PackingInformation>();
+        foreach (var entry in bp.ItemPositions)
+          newSolution[binIndex].Add(new PackingInformation (entry.Key, entry.Value.Rotated));
+      }
+      solution.PackingInformations = newSolution;
     }
     public void Pack(GroupingVectorEncoding solution, ItemList<I> itemMeasures) {
@@ -167,4 +178,5 @@
             bp.PackItem(id, itemMeasures[id], position);
             remainingIDs.Remove(id);
+            break;
           }
         }
@@ -181,4 +193,13 @@
       }
       UpdateBinPackings();
+
+      var newSolution = new int[solution.GroupingVector.Length];
+      int binIndex = 0;
+      foreach (var bp in BinPackings) {
+        foreach (var entry in bp.ItemPositions)
+          newSolution[entry.Key] = binIndex;
+        binIndex++;
+      }
+      solution.GroupingVector = new IntegerVector (newSolution);
     }
     public void Pack(PackingSequenceEncoding solution, ItemList<I> itemMeasures) {
Index: /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Interfaces/IPackingDimensions.cs
===================================================================
--- /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Interfaces/IPackingDimensions.cs	(revision 9598)
+++ /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Interfaces/IPackingDimensions.cs	(revision 9599)
@@ -29,4 +29,5 @@
   public interface IPackingDimensions : IItem {
     Int32 AssignedBin { get; }
+    bool Rotated { get; }
   }
 }
Index: /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Plugin.cs
===================================================================
--- /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Plugin.cs	(revision 9598)
+++ /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Plugin.cs	(revision 9599)
@@ -26,5 +26,5 @@
   /// Plugin class for HeuristicLab.Problems.BinPacking plugin.
   /// </summary>
-  [Plugin("HeuristicLab.Problems.BinPacking", "3.3.7.9596")]
+  [Plugin("HeuristicLab.Problems.BinPacking", "3.3.7.9598")]
   [PluginFile("HeuristicLab.Problems.BinPacking-3.3.dll", PluginFileType.Assembly)]
   [PluginDependency("HeuristicLab.Common", "3.3")]
Index: /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Shapes/CuboidPackingShape.cs
===================================================================
--- /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Shapes/CuboidPackingShape.cs	(revision 9598)
+++ /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Shapes/CuboidPackingShape.cs	(revision 9599)
@@ -57,11 +57,10 @@
 
     public override bool EnclosesPoint(ThreeDimensionalPacking myPosition, ThreeDimensionalPacking checkedPoint) {
-      var c = new CuboidDiagonal(myPosition, this);
-      return (c.x1 <= checkedPoint.X &&
-                c.x2 >= checkedPoint.X &&
-                c.y1 <= checkedPoint.Y &&
-                c.y2 >= checkedPoint.Y &&
-                c.z1 <= checkedPoint.Z &&
-                c.z2 >= checkedPoint.Z);
+      return (myPosition.X <= checkedPoint.X &&
+                (myPosition.X + (myPosition.Rotated ? Depth : Width) - 1) >= checkedPoint.X &&
+                myPosition.Y <= checkedPoint.Y &&
+                (myPosition.Y + Height - 1) >= checkedPoint.Y &&
+                myPosition.Z <= checkedPoint.Z &&
+                (myPosition.Z + (myPosition.Rotated ? Width : Depth) - 1) >= checkedPoint.Z);
     }
     public override bool Encloses(ThreeDimensionalPacking checkedPosition, PackingShape<ThreeDimensionalPacking> checkedShape) {
@@ -87,10 +86,10 @@
     }
     private bool Overlaps(CuboidDiagonal c1, CuboidDiagonal c2) {
-      return !(c1.x1 >= c2.x2 ||
-               c1.y1 >= c2.y2 ||  
-               c1.z1 >= c2.z2 ||
-               c1.x2 <= c2.x1 ||
-               c1.y2 <= c2.y1 ||
-               c1.z2 <= c2.z1);
+      return !(c1.x1 > c2.x2 ||
+               c1.y1 > c2.y2 ||  
+               c1.z1 > c2.z2 ||
+               c1.x2 < c2.x1 ||
+               c1.y2 < c2.y1 ||
+               c1.z2 < c2.z1);
     }
 
@@ -175,7 +174,7 @@
         y1 = myPosition.Y;
         z1 = myPosition.Z;
-        x2 = myPosition.X + (myPosition.Rotated ? myShape.Depth : myShape.Width);
-        y2 = myPosition.Y + myShape.Height;
-        z2 = myPosition.Z + (myPosition.Rotated ? myShape.Width : myShape.Depth);
+        x2 = myPosition.X + (myPosition.Rotated ? myShape.Depth : myShape.Width) - 1;
+        y2 = myPosition.Y + myShape.Height - 1;
+        z2 = myPosition.Z + (myPosition.Rotated ? myShape.Width : myShape.Depth) - 1;
       }
     }
Index: /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Shapes/RectangularPackingShape.cs
===================================================================
--- /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Shapes/RectangularPackingShape.cs	(revision 9598)
+++ /branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Shapes/RectangularPackingShape.cs	(revision 9599)
@@ -52,9 +52,8 @@
 
     public override bool EnclosesPoint(TwoDimensionalPacking myPosition, TwoDimensionalPacking checkedPoint) {
-      var r = new RectangleDiagonal(myPosition, this);
-      return (r.x1 <= checkedPoint.X &&
-                r.x2 >= checkedPoint.X &&
-                r.y1 <= checkedPoint.Y &&
-                r.y2 >= checkedPoint.Y);
+      return (myPosition.X <= checkedPoint.X &&
+                (myPosition.X + (myPosition.Rotated ? Height : Width) - 1) >= checkedPoint.X &&
+                myPosition.Y <= checkedPoint.Y &&
+                (myPosition.Y + (myPosition.Rotated ? Width : Height) - 1) >= checkedPoint.Y);
     }
     public override bool Encloses(TwoDimensionalPacking checkedPosition, PackingShape<TwoDimensionalPacking> checkedShape) {
@@ -78,8 +77,8 @@
     }
     private bool Overlaps(RectangleDiagonal r1, RectangleDiagonal r2) {
-      return !(r1.x1 >= r2.x2 ||
-               r1.y1 >= r2.y2 ||
-               r1.x2 <= r2.x1 ||
-               r1.y2 <= r2.y1);
+      return !(r1.x1 > r2.x2 ||
+               r1.y1 > r2.y2 ||
+               r1.x2 < r2.x1 ||
+               r1.y2 < r2.y1);
     }
 
@@ -150,6 +149,6 @@
         x1 = myPosition.X;
         y1 = myPosition.Y;
-        x2 = myPosition.X + (myPosition.Rotated ? myShape.Height : myShape.Width);
-        y2 = myPosition.Y + (myPosition.Rotated ? myShape.Width : myShape.Height);
+        x2 = myPosition.X + (myPosition.Rotated ? myShape.Height : myShape.Width) - 1;
+        y2 = myPosition.Y + (myPosition.Rotated ? myShape.Width : myShape.Height) - 1;
       }
     }
