Some code cleaning
Added OnBadRehash() event.