Wip cleanup memory store

I don't understand what this is doing at all.