         // Layout the row and column separators. 
         
         const lastRowIndex:int = paddedRowCount - 1;
-        const lastColumnIndex:int = gridDimensions.columnCount - 1;
 
         visibleRowSeparators = layoutLinearElements(grid.rowSeparator, grid.overlayLayer, 
             visibleRowSeparators, oldVisibleRowIndices, visibleRowIndices, layoutRowSeparator, lastRowIndex);
         
         visibleColumnSeparators = layoutLinearElements(grid.columnSeparator, grid.overlayLayer, 
-            visibleColumnSeparators, oldVisibleColumnIndices, visibleColumnIndices, layoutColumnSeparator, lastColumnIndex);
+            visibleColumnSeparators, oldVisibleColumnIndices, visibleColumnIndices, layoutColumnSeparator, lastVisibleColumnIndex);
         
         // HACK
         var dg:DataGrid = grid.gridOwner as DataGrid;

		const startCellX:Number = gridDimensions.getCellX(0 /* rowIndex */, firstVisibleColumnIndex);
		const columnGap:int = gridDimensions.columnGap;
        
		for (var columnIndex:int = firstVisibleColumnIndex; (width > 0) && (columnIndex < columnCount); columnIndex++)
		{
            var cellHeight:Number = gridDimensions.getTypicalCellHeight(columnIndex);
			var cellWidth:Number = gridDimensions.getTypicalCellWidth(columnIndex);

        // Invalid row or column.
        if (dataItem == null || column == null)
            return null;

        // column is GridColumn.visible==false
        if (!column.visible)
            return null;
                
        const factory:IFactory = itemToRenderer(column, dataItem);
        const renderer:IGridItemRenderer = factory.newInstance() as IGridItemRenderer;
