I'm not sure how to do the key_destroy part, key_destroy get's called by release_object, and release_object before calling the destroy operation free's up the name attribute of the object, so I can't call save_all_subkeys because it makes use of that. I think I have to save the key before key_destroy get's called or modify the order of the release_object function.