Factor hashing code into its own function.
clear local cache when clearing identities.