Fix Sexp hash cache invalidation

Hash cache was being reset some places it didn't need to be, and not being reset some places it ought to have been. Not sure if there was any real impact on correctness.

Or maybe I just like saying "hash cache".

Edit: Ugh, actually this may cause performance to improve or get worse depending on the app. But only a little bit. I am so not on a roll today.