anchor.diff:  and VolatileCollection() =
       
       let mutable handles : MultiPtr = Unchecked.defaultof<_>
  +    let mutable count : int = 0 // Note: could replace mode, but would require Array or HashSet to be dropped on Consume
       let mutable mode : byte = 0uy // using mode to avoid "expensive" type checks
   
  +    // NOTE: myIndexOf > Array.IndexOf<_>(arr, value, 0, count) > Array.IndexOf(arr, value, 0, count)
  +    let myIndexOf(arr : WeakReference<_>[], v : WeakReference<_>, count : int) : int =
  +        let mutable i = 0
  +        let mutable search = true
  +        while search && i < count do
  +            if Object.ReferenceEquals(arr.[i], v) then
  +                search <- false
  +            else
  +                i <- i + 1
  +        if search then
  +            -1
  +        else
  +            i
  +
       member x.IsEmpty = 
  -        if isNull handles.Single then true
  -        elif mode = 0uy then false
  -        else handles.Collection.Count = 0
  +        count = 0
           
       member x.Count = 
  -        if isNull handles.Single then 0
  -        elif mode = 0uy then 1
  -        else handles.Collection.Count
  +        count
               
  -    member x.Consume(arr : byref<array<IAdaptiveObject>>) : int =
  +    member x.Consume(res : byref<array<IAdaptiveObject>>) : int =
           let mutable length = 0
           if not (isNull handles.Single) then 
               let mutable v : IAdaptiveObject = Unchecked.defaultof<_>
               if mode = 0uy then
  -                if arr.Length < 1 then
  -                    arr <- Array.zeroCreate 8
  +                if res.Length < 1 then
  +                    res <- Array.zeroCreate 8
                   if handles.Single.TryGetTarget(&v) then
  -                    arr.[0] <- v
  +                    res.[0] <- v
                       length <- 1
                   handles.Single <- Unchecked.defaultof<_>
               elif mode = 1uy then
  -                let list = handles.List
  -                if arr.Length < list.Count then
  -                    arr <- Array.zeroCreate 8
  -                for i in 0..list.Count-1 do // NOTE: using indexer seems to be faster than foreach
  -                    if list.[i].TryGetTarget(&v) then
  -                        arr.[length] <- v 
  +                let arr = handles.Array
  +                if res.Length < count then
  +                    res <- Array.zeroCreate 8
  +                for i in 0..count-1 do
  +                    if arr.[i].TryGetTarget(&v) then
  +                        res.[length] <- v 
                           length <- length + 1
  -                list.Clear()
  +                    arr.[i] <- Unchecked.defaultof<_>
               else
                   let set = handles.Set
  -                if arr.Length < set.Count then
  -                    arr <- Array.zeroCreate (set.Count * 3 / 2)
  +                if res.Length < set.Count then
  +                    res <- Array.zeroCreate (set.Count * 3 / 2)
                   for ref in set do 
                       if ref.TryGetTarget(&v) then
  -                        arr.[length] <- v
  +                        res.[length] <- v
                           length <- length + 1
                   set.Clear()
  +        count <- 0
           length
   
       member x.Add(value : IAdaptiveObject) : bool =
  
positive.code:         if mode = 0uy then
              if isNull handles.Single then
                  handles.Single <- value
                  true
              elif Object.ReferenceEquals(handles.Single, value) then
                  false
              else
                  let list = List<WeakReference<IAdaptiveObject>>(4)
                  list.Add(handles.Single)
                  list.Add(value)
                  handles.List <- list
                  mode <- 1uy
                  true
          // NOTE: possible to use ICollection if mode >= 1, but directly using List or HashSet has best performance
          elif mode = 1uy then 
              let list = handles.List
              if list.Contains(value) then
                  false
              elif list.Count >= 8 then
                  let set = HashSet list
                  set.Add(value) |> ignore
                  handles.Set <- set
                  mode <- 2uy
                  true
              else
                  list.Add(value)
                  true
          else
              handles.Set.Add(value)
  
      member x.Remove(value : IAdaptiveObject) : bool =
          let value = value.Weak
          if Object.ReferenceEquals(handles.Single, value) then
              handles.Single <- null
              true
          elif mode > 0uy then
              handles.Collection.Remove(value)
          else
              false
  
      member x.Clear() =
          handles.Single <- null
          mode <- 0uy
       
  #endnowarn "9"
  
negative.code:         [<FieldOffset(0)>]
          val mutable public Single : WeakReference<IAdaptiveObject>
          [<FieldOffset(0)>]
          val mutable public Array : WeakReference<IAdaptiveObject>[]
          [<FieldOffset(0)>]
          val mutable public Set : HashSet<WeakReference<IAdaptiveObject>>
      end
  
  /// <summary>
  