Keyvaluestore cache

Not sure it's a proper time to merge this big branch. 

Mainly add header cache to KeyValueStore, in order to make header passed with shared_ptr, there exists many methods arguments needed to change.