Added some locking, half finished in-mem