Stack overlapping elements in a more compact manner.

Give this a look. It now arranges the stacking to utilize space better by using the minimum amount of divisions.

Added other performance and clean up improvements as well.