Properly handle anchors when navigating through history - Fixes #324 #257 #256