Reduce cache_keys_unstable manipulation

There's a trend in the code to directly manipulate attributes in various places. imo it's better to ship the logic for that into a private function and just allow the function to set the value when necessary. I'd like to make a function like element._set_cache_keys_stability() that handles this and more succinctly expresses the various conditions on that value

eg. a9cb4f41

Edited by Darius Makovsky