anchor.diff:      [<MaxLength(Int32.MaxValue)>]
       member val EventJson = "" with get, set
   
  -SQLite3.Config (SQLite3.ConfigOption.Serialized) |> ignore
  -
  -let db () =
  -    new SQLiteConnection(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "db"))
  +let db = new SQLiteConnection(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "db"))
  +let write computation =  
  +    lock db (fun _ -> computation db) 
   
   let init () =
  -    use db = db ()
       db.CreateTable<ChatHistory> () |> ignore
       db.CreateTable<ChatHistoryEvent> () |> ignore
       db.CreateTable<Error> () |> ignore
  
positive.code:     fun message -> processor.PostAndAsyncReply(fun replyChannel -> message, replyChannel)
  
  let fetchChatHistoryById (id) =
      use db = db ()
      db.Table<ChatHistory>().Where(fun x -> x.EntityId = id).FirstOrDefault()
  
  let updateChatHistoryReadById (id) =
      use db = db ()
      let history = fetchChatHistoryById id
      match history with
      | null -> ()
      | history ->
          history.Read <- true
          db.Update history |> ignore
  
  let fetchChatHistoryUnreadCount () =
      use db = db ()
      db.Table<ChatHistory>().Where(fun s -> s.Read = false).Count()
  
  let fetchChatHistory () = 
      use db = db ()
      db.Table<ChatHistory>().OrderByDescending(fun s -> s.LastStamp).Take(100).ToList() 
  
  let fetchChatEventHistoryByEntity entityId =
      use db = db ()
      db.Table<ChatHistoryEvent>().Where(fun e -> e.EntityId = entityId).OrderByDescending(fun s -> s.LastStamp).Take(100).ToList() 
  
  let removeChatHistoryById (id) =
      use db = db ()
      let history = fetchChatHistoryById id
      db.Delete(history) |> ignore
  
negative.code: init ()
  
  let deleteAll<'T when 'T : (new : unit -> 'T)>() = 
      let toDelete = db.Table<'T>().ToList()
      write (fun db -> for event in toDelete do db.Delete(event) |> ignore )
      
  let fetchErrors () =
      db.Table<Error>().ToList() 
  
  let createError (error:Error) =
      write (fun db -> db.Insert (error) |> ignore)
  
      #if DEBUG
      let errors = fetchErrors()
  