Improved saving of keys