iterator leak fix in keys cmd