fixes to key gen