Made KVDatabase more general