Fixed some bugs in hash invalidation;