     return origin
 
   _putState: (state, extraState={}) ->
-    location = state?.location ? @_buildLocation()
-    Nav.state = _.extend state, moreState
+    if state?
+      Nav.state = state
+      state[key] = value for own key,value of extraState
+    else Nav.state = extraState
+
+    # for basepath and hashbang just build location from the browser's location
+    location = @_buildLocation()
     @history.replaceState Nav.state, document.title, location
     return
 

  start: (options) ->
    @_setup options
    @running = true
    @_setLocations @_buildLocation()
    return true

  # remove listeners which essentially stops this from doing anything
  stop: () ->
    @running = false
    # remove event listeners
    document.removeEventListener @_clickType(), @_handleClick, false
    window.removeEventListener 'popstate', @_handlePopstate, false
    return true # shows we successfully completed the stop() function

  # bind function so calling it has the `Nav` as the `this`
  _bindToNav: (listener) ->
    fn = listener.bind Nav
    fn.isBoundToNav = true
    return fn

  # uses the browser's location object to build the current location
  _buildLocation: -> # TODO: shouldn't we put a '#' before location.hash ?
    @_the.location.pathname + @_the.location.search + @_the.location.hash

  # sets click event based on existence of `ontouchstart`

      locationCount: 0 # TODO: use this ;)
      location: window?.history?.location ? window.location

    # store History object on Nav.
    # if there is a history pushState function then we're fine.
    if window?.history?.pushState?
      @history = window.history

    # there's no push state API, so, enable hashbangs now and provide an
    # alternate history implementation.
    # TODO: there's a history push state polyfill. add that with a conditional
    #       comment to support IE browsers. what about other old browsers? hmm.
    else
      @_setHashbangEnabled true
      # add NOOP implementations.
      # TODO:
      #  implement these for browsers which don't have a history API.
      #  we'd have to track our
      #  pushState should change the browser location with a hashbang location
      #  replaceState should only update the stored state for the location.
      #
      @history = {
        pushState:(->), replaceState:(->), back:(->), forward:(->)
      }

    @_decode = unless options?.decode then ((v)->v) else @_decodeThis

    unless options?.click is false # TODO: clicks element selector?
      @__handleClick ?= @_handleClick.bind Nav
      document.addEventListener @_clickType(), @__handleClick, false

    unless options?.popstate is false
      @__handlePopstate ?= @_handlePopstate.bind Nav
      window.addEventListener 'popstate', @__handlePopstate, false

    if options?.hashbang is true then @_setHashbangEnabled true

    if options?.basepath? then @_setBasepath options.basepath

    return true

  # get the which/button value
  _which: (event) -> # TODO:? shorten to: event?.which ? window?.event?.button
    event ?= window?.event
    return event?.which ? event.button
