-initialized    = false
+CACHE_SIZE     = 10
 currentState   = null
-referer        = document.location.href
+referer        = null
 loadedAssets   = null
 pageCache      = {}
 createDocument = null
 requestMethod  = document.cookie.match(/request_method=(\w+)/)?[1].toUpperCase() or ''
 xhr            = null
 
-visit = (url) ->
-  if browserSupportsPushState && browserIsntBuggy
-    cacheCurrentPage()
-    reflectNewUrl url
-    fetchReplacement url
-  else
-    document.location.href = url
-
 
 fetchReplacement = (url) ->
   triggerEvent 'page:fetch'


  xhr.send()

fetchHistory = (state) ->
  cacheCurrentPage()

  if page = pageCache[state.position]
    xhr?.abort()
    changePage page.title, page.body
    recallScrollPosition page
    triggerEvent 'page:restore'
  else
    fetchReplacement document.location.href


cacheCurrentPage = ->
  rememberInitialPage()

  pageCache[currentState.position] =
    url:       document.location.href,
    body:      document.body,

  xhr.onload = ->
    triggerEvent 'page:receive'

    if doc = processResponse()
      reflectNewUrl url
      changePage extractTitleAndBody(doc)...
      reflectRedirectedUrl()
      if document.location.hash
