         // target or source are used depending on the type of action and if it is refferring to a new index path or an old one
         for d in _updateContext.items.deleted {
             source[d._section].removed.insert(d._item)
+            source[d._section].deltas[d._item] = -1
         }
         for i in _updateContext.items.inserted {
             target[i._section]!.inserted.insert(i._item)
+            target[i._section]!.deltas[i._item] = +1
         }
         for m in _updateContext.items.moved {
             let s = source[m.0._section]

            print(self._updateContext)
            precondition(s.target != nil, "Invalid target index for section \(s)")
            precondition(s.estimatedCount == newData[s.target!], "Invalid update: invalid number of items in section \(s.target!). The number of items contained in an existing section after the update \(s.estimatedCount) must be equal to the number of items contained in that section before the update \(s.count), plus or minus the number of items inserted or deleted from that section (\(s.inserted.count) inserted, \(s.removed.count) deleted) and plus or minus the number of items moved into or out of that section (\(s.movedIn.count) moved in, \(s.movedOut.count) moved out). Data source reported \(newData[s.target!]) items.")
            return Section(count: newData[s.target!],
                           inserted: s.inserted.union(s.movedIn),
                           pinned: s.pinned,
                           removed: s.removed.union(s.movedOut))
        }
        

    }
    
    struct Section {
        var removed : IndexSet
        let deltas : [Int:Int]
        let count : Int
        
        private var storage = [Int?]()
        private var idx : Int = 0
        private var next : Int = 0
        private var adjust : Int = 0
        
        init(newCount: Int, deltas: [Int:Int], inserted: Int, removed: IndexSet) {
            self.count = newCount
            self.storage.reserveCapacity(count)
            self.deltas = deltas
            self.removed = removed
        }
        
        mutating func index(of previousIndex: Int) -> Int? {
