anchor.diff:          else
               set.Remove value
   
  +[<StructLayout(LayoutKind.Explicit)>]
  +type MultiPtr =
  +    struct
  +        [<FieldOffset(0)>]
  +        val mutable public Single : WeakReference<IAdaptiveObject>
  +        [<FieldOffset(0)>]
  +        val mutable public List : List<WeakReference<IAdaptiveObject>>
  +        [<FieldOffset(0)>]
  +        val mutable public Set : HashSet<WeakReference<IAdaptiveObject>>
  +        [<FieldOffset(0)>]
  +        val mutable public Collection : ICollection<WeakReference<IAdaptiveObject>>
  +    end
  +
   /// <summary>
   /// Collection of WeakReferences using a switching internal representation: Single(0-1), List (2-8), HashSet(>8)
   /// This collection has improved performance to VolatileCollectionOld in cases where there are 0 or 1 references
   /// NOTE: using mode switch omits using types checks to determine used implementation
   ///       using matches instead of downcasts uses OpCode "isinst" instead of "unbox.any" and avoids code to be able to throw exception
   /// </summary>
  -type VolatileCollection<'a when 'a :> IWeakable<'a> and 'a : not struct>() =
  -    let mutable p : Object = Unchecked.defaultof<_>
  +type VolatileCollection() =
  +    let mutable handles : MultiPtr = Unchecked.defaultof<_>
       let mutable mode : byte = 0uy // using mode to avoid "expensive" type checks
   
       member x.IsEmpty = 
  -        if isNull p then true
  +        if isNull handles.Single then true
           elif mode = 0uy then false
  -        else 
  -            match p with 
  -            | :? ICollection<WeakReference<'a>> as col -> col.Count = 0
  -            | _ -> true
  +        else handles.Collection.Count = 0
           
       member x.Count = 
  -        if isNull p then 0
  +        if isNull handles.Single then 0
           elif mode = 0uy then 1
  -        else
  -            match p with 
  -            | :? ICollection<WeakReference<'a>> as col -> col.Count
  -            | _ -> 0
  +        else handles.Collection.Count
               
  -    member x.Consume(arr : byref<array<'a>>) : int =
  -        let mutable v : 'a = Unchecked.defaultof<_>
  +    member x.Consume(arr : byref<array<IAdaptiveObject>>) : int =
           let mutable length = 0
  -        // NOTE: using mode int allows to directly perform typecast of matching implementation
  -        //       using match instead of downcast is less expensive and code cannot throw exception
  -        if mode = 0uy then
  -            match p with
  -            | :? WeakReference<'a> as single -> 
  +        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
  -                p <- Unchecked.defaultof<_>
  -                if single.TryGetTarget(&v) then
  +                if handles.Single.TryGetTarget(&v) then
                       arr.[0] <- v
                       length <- 1
  -            | _ -> ()
  -        elif mode = 1uy then
  -            match p with
  -            | :? List<WeakReference<'a>> as list -> 
  +                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
  
positive.code: 
          new() =
              { Id = newId(); OutOfDateValue = true; 
                LevelValue = 0; Outputs = VolatileCollection<IAdaptiveObject>(); WeakThis = null;
                ReaderCountValue = 0; Reevaluate = false }
  
          static member inline private markTime() =
  
negative.code:                         arr.[length] <- v
                          length <- length + 1
                  set.Clear()
          length
  
      member x.Add(value : IAdaptiveObject) : bool =
          let value = value.Weak
          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
              
  
  