   while(window.historyCache.length > 0)
     cache = window.historyCache.pop()
     if cache.url == url
-      replaceHTML cache.html
+      replaceDocument cache.body, cache.title
       triggerPageChange
       return
 
   fetchReplacement url
 
 fullReplacement = (html, url) ->
-  replaceHTML html, "cache"
+  replaceHTML html
   triggerPageChange()
 
 reflectNewUrl = (url) ->

window.historyCache = []
visit = (url) ->
  if browserSupportsPushState?
    reflectNewUrl url

  else
    createDocumentUsingWrite

replaceHTML = (html) ->
  doc = createDocument html
  title = doc.querySelector "title"
  replaceDocument doc.body,title?.textContent, 'cache'


replaceDocument = (body,title,cache) ->
  originalBody = document.body
  document.documentElement.appendChild body.cloneNode(true), originalBody
  document.documentElement.removeChild originalBody
  document.title = title
  window.historyCache.push({url: document.location.href, title:title,body:body}) if cache


extractLink = (event) ->
