 
     if @pageHistory.length > 1 and window.location.hash is @pageHistory[@pageHistory.length - 2]
       @back = true
-      
+
     if @back and @pageHistory.length != 1
       transitionType = @currentPage.getAttribute("data-transition") or 'slide'
       @pageHistory.pop()
     else
       transitionType = @targetPage.getAttribute("data-transition") or 'slide'
-      @pageHistory.push(window.location.hash)
-    
+      @pageHistory.push window.location.hash
+
     targetPage = @targetPage
     currentPage = @currentPage
     @currentPage = @targetPage

    , 50

  handleEvents: (e) =>
    switch e.type
      when 'touchstart' then @onTouchStart(e)
      when 'mousedown' then @onTouchStart(e)
      when 'touchmove' then @onTouchMove(e)
      when 'touchend' then @onTouchEnd(e)

  onTouchStart: (e) =>
    @moved = false
    
    if window.Touch
      @theTarget = document.elementFromPoint(e.targetTouches[0].clientX, e.targetTouches[0].clientY)
    else
      @theTarget = document.elementFromPoint e.clientX, e.clientY

    if @theTarget.nodeName and @theTarget.nodeName.toLowerCase() isnt 'a' and (@theTarget.nodeType is 3 or @theTarget.nodeType is 1)
      @theTarget = @theTarget.parentNode
    
    @theTarget.className+= ' pressed'
    @theTarget.addEventListener('touchmove', @onTouchMove, false)
    @theTarget.addEventListener('mouseout', @onTouchEnd, false)
    @theTarget.addEventListener('touchend', @onTouchEnd, false)
    @theTarget.addEventListener('mouseup', @onTouchEnd, false)
    @theTarget.addEventListener('touchcancel', @onTouchcancel, false)

  onTouchMove: (e) =>
    @moved = true

  #
  # Returns nothing.
  goto: (targetPage) =>
    if @menuOpen is true
      @closeMenu()

    if typeof targetPage is "string"
