             
             // this should only get called if layer == 0, or we don't care
             // about layering (layeringMode == ITEM_ORDERED_LAYERING)
-            assignDisplayObjectTo(item,mergeData);
+            insertIndex = assignDisplayObjectTo(item, prevItem, insertIndex);
+            prevItem = item;
         }
         
         // we've done all layer == 0 items. 

        if (numGraphicElements > 0)
        {
	        var length:int = numElements;
	        var currentSharedSprite:InvalidatingSprite;
	        for (var i:int = 0; i < length; i++)
	        {
	            var element:IGraphicElement = getElementAt(i) as IGraphicElement;
	            if (element)
	            {
	            	var elementSprite:InvalidatingSprite = element.displayObject as InvalidatingSprite;
	            	var elementHasOwnDisplayObject:Boolean = element.needsDisplayObject;
	            	// Each element must either have a displayObject or sharedDisplayObject property
	            	// if the element has a layer set on it, then it's rendering into its own display object.  
	            	// in that case, calling the previous invalidating display object is incorrect, because the subsequent 
	            	// element might still be sharing the DO with the previous element. But then we know that this one has
	            	// its own display object. If that's the case, we can just update this one, and continue on with our grouping logic
	            	// as though we never saw this one. 
	            	// 
	            	if (!elementHasOwnDisplayObject && elementSprite)
	            	{
	            		if (currentSharedSprite)
	            		{
		            		// Reached a new display object, so mark the previous DisplayObject valid
		            		currentSharedSprite.invalid = false;
	            		}
	            		
	            		currentSharedSprite = elementSprite;
	            	}
	            	
	            	// currentSharedSprite is null if the Group is the sharedDisplayObject.            	
	            	if (elementSprite == null || elementSprite.invalid) 
	            	{
	            		element.validateDisplayList();
		            	if(elementHasOwnDisplayObject && elementSprite)
		            	{
		            		//we're about to forget about this invalidating displayobject, so mark it valid
		            		elementSprite.invalid = false;
		            	}
	            	} 
	
	            }
	        }
	        
	        // Mark the last shared displayObject valid
	        if (currentSharedSprite)
	        	currentSharedSprite.invalid = false;
        }
        
        if (scaleGridChanged)
        {

    mx_internal function removingGraphicElementChild(child:IGraphicElement):void
    {
        child.parentChanged(null);
        discardDisplayObject(child);        
    }

    /**
     *  Removes the element's <code>DisplayObject</code> from this <code>Group's</code>
     *  display list and sets the element's <code>displayObject</code> property to null.
     *
     *  The <code>Group</code> also ensures any elements that share the
     *  <code>DisplayObject</code> will be redrawn.
     * 
     *  <p>This method doesn't trigger new <code>DisplayObject</code> reassignment.
     *  To request new display object reassignment, call the
     *  <code>graphicElementLayerChanged</code> method.</p> 
     *
     *  @param element The graphic element whose display object will be discarded.
     *  @see #graphicElementLayerChanged
     */
    public function discardDisplayObject(element:IGraphicElement):void
    {
        var oldDisplayObject:DisplayObject = element.displayObject;
        element.displayObject = null;
        
        if (!oldDisplayObject)
            return;

        // If the element created the display object
        if (element.shareIndex <= 0)
        {
            super.removeChild(oldDisplayObject);

            // Redo the shared sequences. 
            invalidateDisplayObjectOrdering();
        }
        else if (oldDisplayObject is ISharedDisplayObject)
        {
            // Redraw the shared sequence
            ISharedDisplayObject(oldDisplayObject).redrawRequested = true;

            // Make sure we do a pass through the graphic elements and redraw
            // the invalid ones.  We should only redraw, no need to redo the layout.
            super.$invalidateDisplayList();
        }
    }
    
    /**
