improved rebuildValueIndex in shell and cli modes.