      *  not equal to the item they represent, i.e. if 
      *  renderersInView[item] != item.   More about item recycling
      *  in the getLayoutElementAt() doc.
-     * 
-     *  Clear the virtualLayoutUnderway flag.
-     */
-    override public function endVirtualLayout(startIndex:int, endIndex:int):void
-    {
+     */
+    private function finishVirtualLayout():void
+    {
+        var lastValidChildIndex:int = virtualLayoutEndIndex - virtualLayoutStartIndex;
+        
         // At this point, insertion of new IRs has pushed all of the unneeded IRs
         // past endIndex-startIndex.  Remove or recycle them without invalidating 
         // this DataGroup's size or display list.
-        for(var i:int = super.numChildren - 1; i > (endIndex - startIndex); i--)
+        for(var i:int = super.numChildren - 1; i > lastValidChildIndex; i--)
         {
             var elt:IVisualElement = IVisualElement(super.getChildAt(i));
             

        setTypicalLayoutElement(obj);
        super.removeChild(obj);
    }    

    //----------------------------------
    //  layout

                super.removeChild(DisplayObject(elt));
            }
        }
    }
    
    /**
     *  @private
     *  During virtual layout getLayoutElementAt() eagerly validates lazily
     *  created (or recycled) IRs.   We don't want changes to those IRs to
     *  invalidate the size of this UIComponent.
     */
    override public function invalidateSize():void
    {
        if (!virtualLayoutUnderway)
            super.invalidateSize();
    }
    
    
    /**
     *  @private 
     *  Make sure there's a typicalLayoutElement for virtual layout.
     */
    override protected function measure():void
    {
        if (layout && layout.virtualLayout)
            ensureTypicalLayoutElement();
        super.measure();
    }

    /**
     *  @private
     *  Manages the state required by virtual layout. 
     */
    override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
    {
        if (layout && layout.virtualLayout)
        {
            virtualLayoutUnderway = true;
            virtualLayoutStartIndex = -1;
            ensureTypicalLayoutElement();
        }
        
        super.updateDisplayList(unscaledWidth, unscaledHeight);

        if (virtualLayoutUnderway)
        {
            finishVirtualLayout();
            virtualLayoutUnderway = false;
        }
    }    
    
    /**
     *  @private
