                     }
                     
                     // Renumber the columns which follow the removed columns.
-                    while (index < columns.length)
+                    while (columnIndex < columns.length)
                     {
-                        column = GridColumn(columns.getItemAt(index));
-                        column.setColumnIndex(index);
-                        index++;
+                        column = GridColumn(columns.getItemAt(columnIndex));
+                        column.setColumnIndex(columnIndex);
+                        columnIndex++;
                     }                  
                     
                     break;

                {
                    // All columns between the old and new locations need to 
                    // have their index updated.
                    index = Math.min(event.oldLocation, event.location);
                    var maxIndex:int = Math.max(event.oldLocation, event.location);
                    while (index <= maxIndex)
                    {
                        column = GridColumn(columns.getItemAt(index));
                        column.setColumnIndex(index);
                        index++;
                    }                
                    break;
                }
                    
                case CollectionEventKind.REPLACE:
                case CollectionEventKind.UPDATE:
                {
                    column = GridColumn(columns.getItemAt(index));
                    column.setGrid(this);
                    column.setColumnIndex(index);
                    break;
                }
                    
                case CollectionEventKind.REFRESH:
                {
                    for (index = 0; index < columns.length; index++)
                    {
                        column = GridColumn(columns.getItemAt(index));
                        column.setColumnIndex(index);
                    }                
                    break;
                }

        
        /**
         *  @private
         *  Update caretColumnIndex if necessary.  This method should only be 
         *  called when caretColumnIndex is valid, i.e. != -1.
         */
        private function updateCaretForColumnsChange(event:CollectionEvent):void
        {
            const oldCaretColumnIndex:int = caretColumnIndex;
            const location:int = event.location;
            var itemsLength:int;
            
            // this should stay in sync with updateCaretForDataProviderChange
            
            switch (event.kind)
            {
                case CollectionEventKind.ADD:
                    if (oldCaretColumnIndex >= location)
                        caretColumnIndex += event.items.length;
                    break;
                
                case CollectionEventKind.REMOVE:
                    if (oldCaretColumnIndex >= location)
                    {
                        itemsLength = event.items.length;
                        if (oldCaretColumnIndex < (location + itemsLength))
                            caretColumnIndex = -1;
                        else
                            caretColumnIndex -= itemsLength;    
                    }                   
                    break;
                
                case CollectionEventKind.MOVE:
                    const oldLocation:int = event.oldLocation;
                    itemsLength = event.items.length;
                    if ((oldCaretColumnIndex >= oldLocation) && (oldCaretColumnIndex < (oldLocation + itemsLength)))
                        caretColumnIndex += location - oldLocation;
                    break;                        
                
                case CollectionEventKind.REPLACE:
                case CollectionEventKind.UPDATE:
                    break;
                
                case CollectionEventKind.REFRESH:
                case CollectionEventKind.RESET:
                    caretRowIndex = -1;
                    caretColumnIndex = -1;
                    horizontalScrollPosition = 0;
                    verticalScrollPosition = 0;
                    break;
            }            
        }


        /**
         *  @private
         *  Update hoverRowIndex if necessary.  This method should only be called when 
         *  hoverRowIndex is valid, i.e. != -1.
         */
