   moveTabRight: (count) -> moveTab(null, count)
   nextFrame: (count) ->
     chrome.tabs.getSelected(null, (tab) ->
-      frames = framesForTab[tab.id] = framesForTab[tab.id].rotate(count)
-      chrome.tabs.sendMessage(tab.id, { name: "focusFrame", frameId: frames[0].id, highlight: true }))
+      frames = frameIdsForTab[tab.id] = frameIdsForTab[tab.id].rotate(count)
+      chrome.tabs.sendMessage(tab.id, { name: "focusFrame", frameId: frames[0], highlight: true }))
 
   closeTabsOnLeft: -> removeTabsRelative "before"
   closeTabsOnRight: -> removeTabsRelative "after"

  # scroll position)
  tabInfoMap.deletor = -> delete tabInfoMap[tabId]
  setTimeout tabInfoMap.deletor, 1000
  delete framesForTab[tabId]

chrome.tabs.onActiveChanged.addListener (tabId, selectInfo) -> updateActiveState(tabId)


validFirstKeys = {}
singleKeyCommands = []
focusedFrame = null
frameIdsForTab = {}

# Keys are either literal characters, or "named" - for example <a-b> (alt+b), <left> (left arrow) or <f12>
# This regular expression captures two groups: the first is a named key, the second is the remainder of
