anchor.diff:  
   and
     internal SortedMapCursor<'K,'V> =
  -    //struct
  -    val public source : SortedMap<'K,'V>
  -    val mutable index : int
  -    val mutable currentKey : 'K
  -    val mutable currentValue: 'V
  -    val mutable cursorVersion : int
  -    val mutable isBatch : bool
  -
  -    val mutable isSubscribed : bool
  -    val mutable tcs :  TaskCompletionSource<bool> //AsyncTaskMethodBuilder<bool>
  -    val mutable cancellationToken : CancellationToken 
  -    val mutable cancellationTokenRegistration : CancellationTokenRegistration
  -    [<DefaultValueAttribute(false)>]
  -    val mutable onNextHandler : OnNextHandler<'K,'V>
  -    [<DefaultValueAttribute(false)>]
  -    val mutable onCompletedHandler : OnCompletedHandler
  -    [<DefaultValueAttribute(false)>]
  -    val mutable onErrorHandler : OnErrorHandler
  -
  -    new(source:SortedMap<'K,'V>) = 
  -      { source = source; 
  -        index = -1;
  -        currentKey = Unchecked.defaultof<_>;
  -        currentValue = Unchecked.defaultof<_>;
  -        cursorVersion = source.orderVersion;
  -        isBatch = false;
  -        isSubscribed = false;
  -        tcs = Unchecked.defaultof<_>;
  -        cancellationToken = Unchecked.defaultof<_>;
  -        cancellationTokenRegistration  = Unchecked.defaultof<_> ;
  -
  -      }
  -    //end 
  -//    member this.ONH(kvp:KVP<'K,'V>) =
  -//      SortedMapCursor<'K,'V>.OnNext(&this, kvp)
  -
  -    static member private OnNext(cursor:SortedMapCursor<'K,'V>, kvp:KVP<'K,'V>) : unit =
  -      // we do not use kvp for now and ignore out of order data
  -      // MoveNext + versions handling should handle this
  -      let entered = enterLockIf cursor.source.SyncRoot true
  -      try
  -        if cursor.tcs <> Unchecked.defaultof<_> then
  -          let mutable localtcs = cursor.tcs
  -          cursor.tcs <- Unchecked.defaultof<_>
  -          try
  -            if cursor.MoveNext() then 
  -              localtcs.SetResult(true)
  -          with
  -          | _ as ex -> localtcs.SetException(ex)
  -        //else do nothing
  -      finally
  -        exitLockIf cursor.source.SyncRoot entered
  -
  -    // temp solution, this implementation them checks IsMutable property
  -    static member private OnCompleted(cursor:SortedMapCursor<'K,'V>) = 
  -      let entered = enterLockIf cursor.source.SyncRoot true
  -      try
  -        if cursor.tcs <> Unchecked.defaultof<_> then
  -          let mutable localtcs = cursor.tcs
  -          cursor.tcs <- Unchecked.defaultof<_>
  -          try
  -            if cursor.MoveNext() then localtcs.SetResult(true)
  -            else localtcs.SetResult(false)
  -          with
  -          | _ as ex -> localtcs.SetException(ex)
  -        //else do nothing
  -      finally
  -        exitLockIf cursor.source.SyncRoot entered
  -
  -    static member private OnError(this:SortedMapCursor<'K,'V>, e:exn) = 
  -      let entered = enterLockIf this.source.SyncRoot true
  -      try
  -        if this.tcs <> Unchecked.defaultof<_> then
  -          let mutable localtcs = this.tcs
  -          this.tcs <- Unchecked.defaultof<_>
  -          localtcs.SetException(e)
  -        //else do nothing
  -      finally
  -        exitLockIf this.source.SyncRoot entered
  -      
  +    struct
  +      val public source : SortedMap<'K,'V>
  +      val mutable index : int
  +      val mutable currentKey : 'K
  +      val mutable currentValue: 'V
  +      val mutable cursorVersion : int
  +      val mutable isBatch : bool
  +
  +      new(source:SortedMap<'K,'V>) = 
  +        { source = source; 
  +          index = -1;
  +          currentKey = Unchecked.defaultof<_>;
  +          currentValue = Unchecked.defaultof<_>;
  +          cursorVersion = source.orderVersion;
  +          isBatch = false;
  +        }
  +    end 
  +
       member this.Comparer: IComparer<'K> = this.source.Comparer
       member this.TryGetValue(key: 'K, value: byref<'V>): bool = this.source.TryGetValue(key, &value)
       member this.MoveNext() =
  
positive.code:       res <- Unchecked.defaultof<KeyValuePair<'K, 'V>>
        false
  
    override this.GetCursor() = //new SortedMapCursor<'K,'V>(this) :> ICursor<'K,'V>
      this.GetCursor(-1,  this.orderVersion, Unchecked.defaultof<'K>, Unchecked.defaultof<'V>) :> ICursor<'K,'V> //this.GetCursor(-1, this.version, Unchecked.defaultof<'K>, Unchecked.defaultof<'V>)
   
    // for foreach optimization
    // TODO(?) replace with a mutable struct, like in SCG.SortedList<T>, there are too many virtual calls and reference cells in the most critical paths like MoveNext
    // NB Object expression with ref cells are surprisingly fast compared to a custom class or even a struct
  
negative.code:       this.cursorVersion <-  this.source.orderVersion
        this.index <- -1
  
      member this.Dispose() = this.Reset()
  
      interface IDisposable with
        member this.Dispose() = this.Dispose()
  