Fix generation of keys.