anchor.diff:                      | Some r -> Some (Choice<obj, obj>.Choice2Of2 r :> obj)
                       | None -> None
   
  +type TimePattern private () =
  +    inherit Pattern(PersistentHashSet.empty)
  +    static let instance = TimePattern() :> Pattern
  +    static member Instance = instance
  +    
  +    override x.Run(s,v) =
  +        Some null
  +
  +type NeverPattern private () =
  +    inherit Pattern(PersistentHashSet.empty)
  +    static let instance = NeverPattern() :> Pattern
  +    static member Instance = instance
  +    
  +    override x.Run(s,v) =
  +        None
  +
  +
  +type MultiDict<'k, 'v when 'k : equality>() =
  +    let store = Dictionary<'k, List<'v>>()
  +
  +    member x.ContainsKey (key : 'k) =
  +        store.ContainsKey key
  +
  +    member x.Add(key : 'k, value : 'v) =
  +        let list = 
  +            match store.TryGetValue key with
  +                | (true, l) -> l
  +                | _ ->
  +                    let list = List()
  +                    store.[key] <- list
  +                    list
  +
  +        list.Add value
  +
  +    member x.Keys = store.Keys
  +
  +    interface System.Collections.IEnumerable with
  +        member x.GetEnumerator() = store.GetEnumerator() :> _
  +
  +    interface System.Collections.Generic.IEnumerable<KeyValuePair<'k, List<'v>>> with
  +        member x.GetEnumerator() = store.GetEnumerator() :> _
  +
  +
   type Runner<'s>(state : 's) =
  +    inherit Mod.AbstractMod<'s>()
  +
       let subscriptions = Dictionary<IEventSource, IDisposable>()
  -    let mutable pending = Dictionary<Pattern, obj -> SF<'s, unit>>()
  -    let queue = Queue<IEventSource * obj>()
  +
  +    let mutable pending : MultiDict<Pattern, obj -> SF<'s, unit>> = MultiDict()
  +    let queue = Queue<IEventSource * obj * float>()
       let mutable state = { time = 0.0; state = state }
  -    let modState = Mod.init state.state
       let sw = System.Diagnostics.Stopwatch()
  +    do sw.Start()
  +
  +    let mutable dependsOnTime = false
  +
  +
  +    let now () = sw.Elapsed.TotalSeconds
  +
  +    override x.Compute() =
  +        x.Evaluate()
  +            
  +        if dependsOnTime then
  +            AdaptiveObject.Time.Outputs.Add x |> ignore
  +            
  +        state.state
  +
  +    member private x.Push(source : IEventSource, value : obj) =
  +        queue.Enqueue(source, value, now())
  +        transact (fun () -> x.MarkOutdated())
   
       member x.Enqueue(sf : SF<'s, unit>) =
  -        match sf.run.Run(&state) with
  -            | Finished _ -> ()
  -            | Continue(p, cont) ->
  -                pending.[p] <- cont
  -                for r in p.Relevant do
  -                    if not (subscriptions.ContainsKey r) then
  -                        subscriptions.[r] <- r.Subscribe(fun o -> queue.Enqueue(r, o))
  +        lock x (fun () ->
  +            match sf.run.Run(&state) with
  +                | Finished _ -> ()
  +                | Continue(p, cont) ->
  +                    pending.Add(p, cont)
  +
  +                    if p = TimePattern.Instance then
  +                        dependsOnTime <- true
  +
  +                    for r in p.Relevant do
  +                        if not (subscriptions.ContainsKey r) then
  +                            subscriptions.[r] <- r.Subscribe(fun o -> x.Push(r, o))
  +        )
                               
  -    member x.Step() =
  +    member private x.Step() =
           lock x (fun () ->
  -            
  -            if not sw.IsRunning then sw.Start()
  -            else state <- { state with time = sw.Elapsed.TotalSeconds }
  -
  -            if queue.Count > 0 then
  -                printfn "step: %A" state.time
  -
               while queue.Count > 0 do
  -                let (s,e) = queue.Dequeue()
  -
  -                let newPending = Dictionary<Pattern, obj -> SF<'s, unit>>()
  -                for (KeyValue(p, cont)) in pending do
  +                let (s,e,t) = queue.Dequeue()
  +                state <- { state with time = t }
  +
  +                let mutable newPending = MultiDict()
  +                for KeyValue(p, conts) in pending do
                       match p.Run(s,e) with
                           | Some v -> 
  -                            let c = cont v
  -                            match c.run.Run(&state) with
  -                                | Continue(p,c) ->
  -                                    newPending.[p] <- c
  -                                | _ ->
  -                                    ()
  +                            for cont in conts do
  +                                let c = cont v
  +                                match c.run.Run(&state) with
  +                                    | Continue(p,c) ->
  +                                        newPending.Add(p, c)
  +                                    | _ ->
  +                                        ()
                           | None ->
  -                            newPending.[p] <- cont
  +                            for cont in conts do
  +                                newPending.Add(p,cont)
   
                   let oldEvents   = pending.Keys |> Seq.collect (fun p -> p.Relevant) |> HashSet
                   let newEvents   = newPending.Keys |> Seq.collect (fun p -> p.Relevant) |> HashSet
  
positive.code:                 let g = e.Graphics
                  g.Clear(Color.Black)
  
                  g.Line(Color.Red, s.current)
  
                  for p in s.finished do
                      g.Polygon(Color.Green, p)
  
      let run() =
          let runner = Runner { current = []; finished = [] }
          use form = new UI.PaintForm(runner.State)
  
  
          let thing = paintThingy form.MouseDown form.MouseUp form.MouseMove |> SF.ignore |> SF.repeat
          runner.Enqueue thing
  
  
          Application.Idle.Add (fun _ -> runner.Step())
          Application.Run(form)
  
negative.code: 
          repeatUntil cancelOrM
  
      let rec repeatWhile (guard : SF<'s, bool>) (body : SF<'s, unit>) =
          { run =
              state {
                  let! g = guard.run
                  match g with
                      | Finished true ->
                          let! r = body.run
                          match r with
                              | Finished () -> return! (repeatWhile guard body).run
  
                              | Continue(p, c) ->
                                  return Continue(p, fun o -> append (c o) (repeatWhile guard body))
                      | _ ->
                          return Finished ()
  
              }
          }
  
  
      let rec repeat (inner : SF<'s, unit>) =
          { run =
              state {
  