fixes to makekey/writekey