      *  The return value is any extra space that's left over
      *  after growing all children to their maxHeight.
      */
-    public function distributeHeight(layoutItemArray:Array,
-                                     width:Number,
-                                     height:Number):Number
+    public function distributeHeight(width:Number, 
+                                     height:Number, 
+                                     restrictedWidth:Number):Number
     {
         var spaceToDistribute:Number = height;
         var totalPercentHeight:Number = 0;
         var childInfoArray:Array = [];
         var childInfo:LayoutItemFlexChildInfo;
         var newWidth:Number;
+        var layoutItem:ILayoutItem;
+        
+        // rowHeight can be expensive to compute
+        var rh:Number = (variableRowHeight) ? 0 : rowHeight;
+        var count:uint = target.numLayoutItems;
+        var totalCount:uint = count; // number of items to use in gap calculation
         
         // If the child is flexible, store information about it in the
         // childInfoArray. For non-flexible children, just set the child's
         // width and height immediately.
-        for each (var layoutItem:ILayoutItem in layoutItemArray)
-        {
-            if (hasPercentHeight(layoutItem))
+        for (var index:int = 0; index < count; index++)
+        {
+            layoutItem = target.getLayoutItemAt(index);
+            if (!layoutItem || !layoutItem.includeInLayout)
+            {
+                totalCount--;
+                continue;
+            }
+            
+            if (hasPercentHeight(layoutItem) && variableRowHeight)
             {
                 totalPercentHeight += layoutItem.percentHeight;
 

            }
            else
            {
                newWidth = NaN;
                if (hasPercentWidth(layoutItem))
                   newWidth = calculatePercentWidth(layoutItem, width);
                
                layoutItem.setActualSize(newWidth, NaN);
                spaceToDistribute -= layoutItem.actualSize.y;
            } 
        }

        // Distribute the extra space among the flexible children
        if (totalPercentHeight)

            return;
        
        // TODO EGeorgie: use vector
        var layoutItem:ILayoutItem;
        var count:uint = layoutTarget.numLayoutItems;
        
        // if horizontalAlign is "contentJustify", we need to figure out restrictedWidth.
        // contentWidth gets sent in to distributeHeight(), but is only used if 
        // horizontalAlign is "justify" (contentWidth is unscaledWidth) or 
        // horizontalAlign is "contentJustify" (contentWidth is the maximum width
        // of all its children and a minimum of unscaledWidth)
        var contentWidth:Number = unscaledWidth;
        
        if (horizontalAlign != HorizontalAlign.LEFT)
        {
            for (var i:int = 0; i < count; i++)
            {
                layoutItem = layoutTarget.getLayoutItemAt(i);
                if (!layoutItem || !layoutItem.includeInLayout)
                    continue;

                var layoutItemWidth:Number;
                if (hasPercentWidth(layoutItem))
                    layoutItemWidth = calculatePercentWidth(layoutItem, unscaledWidth);
                else
                    layoutItemWidth = layoutItem.preferredSize.x;
                
                contentWidth = Math.max(contentWidth, layoutItemWidth);
            }
        }

        distributeHeight(unscaledWidth, unscaledHeight, contentWidth);        
        
        // default to left (0)
        var hAlign:Number = 0;
        if (horizontalAlign == HorizontalAlign.CENTER)
            hAlign = .5;
        else if (horizontalAlign == HorizontalAlign.RIGHT)
            hAlign = 1;
        
        // As the LayoutItems are positioned, we'll count how many rows 
        // fall within the layoutTarget's scrollRect
