Fix bug about setting and updating appkeys.