     if opts.shortcuts instanceof Shortcuts
       @shortcuts = opts.shortcuts
     else
-      raw = _.keys(defaults).reduce (acc, key) ->
-        acc[key] = defaults[key].data
-        return acc
-      , {}
-      @shortcuts = new Shortcuts raw
-
-
+      @shortcuts = new Shortcuts _.keys(defaults).reduce (acc, key) ->
+          acc[key] = defaults[key].data
+          return acc
+        , {}
+
+    @_buffer = @shortcuts.config.reduce (acc, collection) ->
+      acc[collection.name] = []
+      return acc
+    , {}
+
+
+  # Party starts here.
+  #
+  # This adds the necessary event listeners, and fetches changes.
+  # Make sure to call this after _appStorageController_ & _appManager_
+  # singletons are set.
+  #
   addEventListeners: ->
 
     { appManager, appStorageController } = kd.singletons

      version : STORAGE_VERSION
      fetch   : no

    # make sure we are not accessing storage until its ready.
    # this also updates kb bindings which are initially listening
    # for default combos.
    @_store.once 'ready', _.bind @_handleStoreReady, this

    # add valid kb event listeners and invalidate obsolete upon
    # front application is set and ready
    appManager.on 'FrontAppChange', _.bind @_handleFrontAppChange, this

    @_store.fetchStorage null, yes


  _save: _.throttle (collection, model) ->

    throw 'could not persist changes'  unless @_store.isReady
    # also means: do not call this method explicitly, use #update

    throw 'not implemented :trollface:'

  , THROTTLE_WAIT,
    leading  : no
    trailing : yes


  _handleStoreReady: ->

    osIndex = if globals.os is 'mac' then 1 else 0

    @shortcuts.config.each (collection) =>
      collectionName = collection.name

cloneArray     = require 'app/util/cloneArray'

STORAGE_NAME    = 'shortcuts'
STORAGE_VERSION = '4'
THROTTLE_WAIT   = 500

module.exports =

# Manages keyboard shortcuts.
#
# Wraps over a _shortcuts_ instance by default (if not passed explicitly
# within opts.shortcuts), and makes sure we are listening and dispatching
# correct keyboard events depending on an application's config.
#
# This also exposes convenience proxy methods to the underlying _keyconfig_
# instance, and persists the state of a keyconfig#Collection to the app storage.
#
class ShortcutsController extends events.EventEmitter

  klass = this

  constructor: (opts={}) ->

    super()

