                 
                 // If we are using virtual layout, only size and position 
                 // the visible elements
-                if (yPos > height && !foundLastVisibleElement)
+                if (yPos > yPosMax && !foundLastVisibleElement)
                 {
                     foundLastVisibleElement = true;
                     // Keep track of the number of elements visible in the viewing area

        if (forceNoWrapElements != oldForceNoWrapElements)
            dispatchEvent(new Event(FORCE_NO_WRAP_ELEMENTS_CHANGE));
        
        var scrollPosition:Number = wrapElements ? 
            normalizeScrollPosition(verticalScrollPosition) : 
            verticalScrollPosition;
		
        var itemIndex:int = Math.floor(scrollPosition / rowHeight);
        var yPos:Number = 0;
        
        var foundLastVisibleElement:Boolean = false;
        var numVisibleElements:int = 0;
        var numVisitedElements:int = 0;
                
        // Translate the vsp to the item index
        if (wrapElements)
        {
            // The top item might only be partially visible. 
            yPos = -(scrollPosition % rowHeight);
        }
        else
        {
            if (!useVirtualLayout)
                itemIndex = 0;
            
            // If itemIndex is either the first or last element
            // then position using -scrollPosition
            if (itemIndex >= numElements)
            {
                itemIndex = numElements - 1;
                yPos = -scrollPosition;
            }
            else if (itemIndex > 0)
            {
                yPos = -(scrollPosition % rowHeight);
            }
            else // itemIndex == 0
            {
                yPos = -scrollPosition;
            }
        }			
        
        // Start at the top index
        var iter:LayoutIterator = new LayoutIterator(target, itemIndex);

		return vsp;
	}
    
    // Helper function to normalize the item index
    private function normalizeItemIndex(index:int):int
    {
        if (target)
        {
            index %= target.numElements;
            
            if (index < 0)
                index += target.numElements;
        }
        
        return index;
    }
    
    // Helper function to return whether an element is enabled or not
    private function isElementEnabled(element:Object):Boolean
    {
