Refactored usage of KeyValue DB