Refactored the hashchange mechanism