Add KeyValueStore support

Update: Make apply transaction atomic