 
         var totalWidthToDistribute:Number = unscaledWidth;
         if (totalCount > 1)
-            totalWidthToDistribute -= (totalCount - 1) * GAP;
+            totalWidthToDistribute -= (totalCount - 1) * gap;
 
         distributeWidth(layoutItemArray, totalWidthToDistribute, unscaledHeight); 
                             
         // TODO EGeorgie: verticalAlign
         var vAlign:Number = 0;
         
+        
+        // If columnCount wasn't set, then as the LayoutItems are positioned
+        // we'll count how many columns fall within the layoutTarget's scrollRect
+        var visibleColumns:uint = 0;
+        var minVisibleX:Number = layoutTarget.horizontalScrollPosition;
+        var maxVisibleX:Number = minVisibleX + unscaledWidth
+            
         // Finally, position the objects        
         var x:Number = 0;
         for each (var lo:ILayoutItem in layoutItemArray)
         {
             var y:Number = (unscaledHeight - lo.actualSize.y) * vAlign;
-
             lo.setActualPosition(x, y);
-            x += lo.actualSize.x;
-            x += GAP;
-        }
-    }
+            if (!variableColumnWidth)
+            	lo.setActualSize(columnWidth, lo.actualSize.y);
+            var dx:Number = lo.actualSize.x;
+            if((explicitColumnCount == -1) && (x < maxVisibleX) && ((x + dx) > minVisibleX))
+            	visibleColumns += 1;
+            x += dx + gap;
+        }
+        if (explicitColumnCount == -1) 
+        	setColumnCount(visibleColumns);        
+
+        var r:Rectangle = layoutTarget.scrollRect;
+        if (r != null) 
+        {
+            r.width = unscaledWidth;
+            r.height = unscaledHeight;
+            layoutTarget.scrollRect = r;
+        }
+        else 
+        {
+        	var rx:Number = layoutTarget.horizontalScrollPosition;
+        	var ry:Number = layoutTarget.verticalScrollPosition;
+        	layoutTarget.scrollRect = new Rectangle(rx, ry, unscaledWidth, unscaledHeight);
+        }
+    }
+
 
     /**
      *  This function sets the width of each child

        _target = value;
    }
    
    public function measure():void
    {
    	var layoutTarget:Group = target;
        if (!layoutTarget)
            return;
            
        var minWidth:Number = 0;
        var minHeight:Number = 0;
        var preferredWidth:Number = 0;
        var preferredHeight:Number = 0;
        
        var count:uint = layoutTarget.numLayoutItems;
        var totalCount:uint = count; // How many items will be laid out


    //--------------------------------------------------------------------------
    //
    //  Class methods
    //
    //--------------------------------------------------------------------------
