       @setKeyMapping items.normalModeKeyStateMapping
 
     chrome.storage.onChanged.addListener (changes, area) =>
-      if area == "local" and changes.normalModeKeyStateMapping?.newValue
+      if area == "local" and changes.normalModeKeyStateMapping and changes.normalModeKeyStateMapping.newValue
         @setKeyMapping changes.normalModeKeyStateMapping.newValue
+    return
 
   commandHandler: ({command: registryEntry, count}) ->
     count *= registryEntry.options.count ? 1
-    count = 1 if registryEntry.noRepeat
+    if registryEntry.noRepeat
+      count = 1
 
     if registryEntry.repeatLimit? and registryEntry.repeatLimit < count
-      return unless confirm """
+      result = confirm """
         You have asked Vimium to perform #{count} repetitions of the command: #{registryEntry.description}.\n
         Are you sure you want to continue?"""
+      return unless result
 
     if registryEntry.topFrame
       # We never return to a UI-component frame (e.g. the help dialog), it might have lost the focus.

    new FindMode()

  # Find.
  performFind: (count) -> FindMode.findNext false for [0...count] by 1
  performBackwardsFind: (count) -> FindMode.findNext true for [0...count] by 1

  # Misc.
  mainFrame: -> focusThisFrame highlight: true, forceFocusThisFrame: true
  showHelp: (sourceFrameId) -> HelpDialog.toggle {sourceFrameId, showAllCommandDetails: false}

  passNextKey: (count, options) ->
    if options.registryEntry.options.normal
      enterNormalMode count
    else

    # the currently-focused element highlighted specially. Tabbing will shift focus to the next input element.
    # Pressing any other key will remove the overlays and the special tab behavior.
    resultSet = DomUtils.evaluateXPath textInputXPath, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE
    visibleInputs = []

    for i in [0...resultSet.snapshotLength] by 1
      element = resultSet.snapshotItem i
      unless DomUtils.getVisibleClientRect element, true
        continue
      visibleInputs.push({ element, index: i, rect: Rect.copy element.getBoundingClientRect() })

    visibleInputs.sort ({element: element1, index: i1}, {element: element2, index: i2}) ->
      # Put elements with a lower positive tabIndex first, keeping elements in DOM order.
