More efficient implementation of ScatterKeys()