Keyvaluestore cache

Mainly add header cache to KeyValueStore, in order to make header passed with shared_ptr, there exists many methods arguments needed to change.
move the magic numbers (3 and later 5) to the top and make them static const, at least?