Better HistoryLocation popstate handling - Fixes #2234