Closes #3281. Refactor and export the key-value store interfaces and implementations. Changelog: refactor