Tidied up file, added a fix to popstate emptying page contents.