Added the hashchange handler and reordered the actions.