Fixing a bug, that could lead to undefined behaviour through hash-tag-changes.

I added comments to the important lines of the commit.

To reproduce the bug, use your bookmarklet on googles search result page and try to navigate to a specific result.