anchor.diff:                      | :? ILockedResource as r ->
                           x.GetOrCreateLocal(key, fun () ->
                               v.AddRef()
  +                            let mutable oldData = None
                               { new Resource<'h>(v.Kind) with
                                   member x.GetInfo(h : 'h) =
                                       v.GetInfo h
   
                                   member x.Create(old : Option<'h>) =
  -                                    acquire old dataMod
  +                                    let newData = dataMod.GetValue x
  +                                    match oldData with
  +                                        | Some d -> releaseLock d
  +                                        | None -> ()
  +                                    oldData <- Some newData
  +                                    acquireLock newData
  +                                    acquireOutput old dataMod
  +
                                       let stats = v.Update(x)
                                       v.Handle.GetValue(), stats
   
                                   member x.Destroy(h : 'h) =
  -                                    release dataMod
  +                                    match oldData with
  +                                        | Some d -> releaseLock d; oldData <- None
  +                                        | None -> ()
  +                                    releaseOutput dataMod
                                       lock v (fun () -> 
                                           v.Outputs.Remove x |> ignore
                                           v.Handle.Outputs.Remove x |> ignore
  
positive.code:             | None ->
                  x.GetOrCreateLocal(key, fun _ -> 
                      let mutable ownsHandle = false
                  
                      let resource = 
                          { new Resource<'x>(desc.kind) with
                              member x.GetInfo (h : 'x) =
                                  desc.info h
  
                              member x.Create(old : Option<'x>) =
                                  acquire old dataMod
                                  let data = dataMod.GetValue x
                                  let stats = stats dataMod
  
                                  match old with
                                      | Some old ->
  
negative.code:                                                 handle, stats
  
                              member x.Destroy(h : 'x) =
                                  match oldData with
                                      | Some d -> releaseLock d
                                      | _ -> ()
  
                                  releaseOutput dataMod
                                  if ownsHandle then
                                      ownsHandle <- false
                                      desc.delete h
  