workaround for browsers like Firefox that don't fire popstate on pageload
Added more hooks to the code for use by extensions