Fix popstate handling on page load

* Use replaceState to set an initial state, allowing detection of the
"page load" popstate call.
* Removes need for allow_pop_state.
* fixes #4