anchor.diff:                  | _ -> failwith <| sprintf "Unexpected command type: %A" (cmdObj.GetType())
               config
               |> (fun config -> { config with CommandHandlers = config.CommandHandlers |> Map.add cmdType (typeof<'TCmd>, outerHandler) })
  +        let addEvent<'TEvt, 'TState> (toId: 'TEvt -> string option) (stateBuilder : IStateBuilder) (handler : 'TEvt -> 'TState -> seq<obj>) (config : EventProcessingConfiguration) =
  +            let evtType = typeof<'TEvt>.Name
  +            let outerHandler (evtObj : obj) : option<(string * IStateBuilder * (obj -> seq<obj>))> =
  +                let realHandler (evt : 'TEvt) : option<(string * IStateBuilder * (obj -> seq<obj>))> =
  +                    let stream = toId evt
  +                    match stream with
  +                    | Some stream -> 
  +                        let realRealHandler = 
  +                            let blah = handler evt
  +                            fun (state : obj) ->
  +                                blah (state :?> 'TState)
  +                        Some (stream, stateBuilder, realRealHandler)
  +                    | None -> None
  +                match evtObj with
  +                | :? 'TEvt as evt -> realHandler evt
  +                | _ -> failwith <| sprintf "Unexpected event type: %A" (evtObj.GetType())
  +            { config with EventHandlers = config.EventHandlers |> Map.add evtType (typeof<'TEvt>, outerHandler) }
       type EventModel (connection : IEventStoreConnection, config : EventProcessingConfiguration) =
  -        let mutable handlers : Map<string, ResolvedEvent -> option<string * seq<obj>>> = Map.empty
  -
  -        member x.RegisterHandler<'TEvt> (handler : 'TEvt -> option<string * seq<obj>>) =
  -            let handler' (evtObj : ResolvedEvent) = 
  -                let esEvent = evtObj
  -                let evt = deserialize<'TEvt>(esEvent.Event.Data)
  -                handler evt
  -            handlers <- handlers |> Map.add typeof<'TEvt>.Name handler' 
   
           member x.Start () = 
  -            connection.SubscribeToAllAsync(false, (fun subscription event -> x.EventAppeared event event.Event.EventId)) |> Async.AwaitTask
  -
  -        member x.EventAppeared event eventId =
  +            connection.SubscribeToAllAsync(false, (fun subscription event -> x.EventAppeared event event.Event.EventId |> Async.RunSynchronously )) |> Async.AwaitTask
  +
  +        member x.EventAppeared (event : ResolvedEvent) eventId : Async<unit> =
               log <| sprintf "Received: %A: %A" eventId event.Event.EventType
  -            maybe {
  -                let! handler = handlers |> Map.tryFind (event.Event.EventType)
  -                let! (stream, events) = handler event
  -                let eventData = 
  -                    events
  -                    |> Seq.map (fun x -> new EventData(Guid.NewGuid(), x.GetType().Name, true, serialize(x), null))
  -                    |> Array.ofSeq
  -                let result = connection.AppendToStreamAsync(stream, EventStore.ClientAPI.ExpectedVersion.Any, eventData).ContinueWith((fun _ -> true)) |> Async.AwaitTask |> Async.RunSynchronously
  -                return result
  -            } |> ignore
  +
  +            match config.EventHandlers |> Map.tryFind event.Event.EventType with
  +            | Some (t,handler) -> 
  +                let evt = deserializeObj (event.Event.Data) t
  +                match handler evt with
  +                | Some (stream, stateBuilder, handler') -> 
  +                    let state = stateBuilder.Zero
  +                    let result = handler' state
  +                    let eventData = 
  +                        result
  +                        |> Seq.map (fun x -> new EventData(Guid.NewGuid(), x.GetType().Name, true, serialize(x), null))
  +                        |> Array.ofSeq
  +                    connection.AppendToStreamAsync(stream, EventStore.ClientAPI.ExpectedVersion.Any, eventData).ContinueWith((fun _ -> ())) |> Async.AwaitTask  
  +                | None -> async { return () } 
  +            | None -> async { return () }
   
           member x.RunCommand cmd streamId =
               let cmdKey = cmd.GetType().FullName
  
positive.code:                 ParentId = Some parentId
              }
  
              do! model.RunCommand addParentCmd (parentId.ToString()) |> Async.Ignore
              do! model.RunCommand addChildCmd (childId.ToString()) |> Async.Ignore
  
              do! Async.Sleep(1000)
  
              let! parentStream = connection.ReadStreamEventsBackwardAsync(parentId.ToString(), EventStore.ClientAPI.StreamPosition.End, 1, false) |> Async.AwaitTask
  
              parentStream.Events
              |> Seq.head
              |> (fun evt -> evt.Event.EventType) |> should equal "ChildAddedEvent"
          } |> Async.RunSynchronously
negative.code:     type EventProcessingConfiguration = {
          CommandHandlers : Map<string, (Type * cmdHandler)>
          StateBuilders: Set<IStateBuilder>
          EventHandlers : Map<string, (Type *  (obj -> option<(string *  IStateBuilder * (obj -> seq<obj>))>))>
      }
      with static member Empty = { CommandHandlers = Map.empty; StateBuilders = Set.empty; EventHandlers = Map.empty } 
  
  