need to import $CFG into the local function scope

fixup comments regarding hashing of keys - it does not help at all with
stale data