 # key as the mapping.
 i18nSubs = (element, value, subMap) ->
   if subMap
-    for prop of subMap when subMap.hasOwnProperty(prop) and prop is element.id
-      for subProp of subMap[prop] when subMap[prop].hasOwnProperty subProp
-        if subProp is value
-          subs = subMap[prop][subProp]
-          break
+    for own prop, subMap2 of subMap when prop is element.id
+      for own prop2, target of subMap2 when prop2 is value
+        subs = target
+        break
       break
-  return subs
+  subs
 
 # Utilities setup
 # ---------------


  # Retrieve the first entity/all entities that pass the specified `filter`.
  query: (entities, singular, filter) ->
    if singular
      return entity for entity in entities when filter entity
    else
      results = []
      results.push entity for entity in entities when filter entity
      return results

  # Data functions
  # --------------

  # Determine whether or not the specified key exists in `localStorage`.
  exists: (key) ->
    return localStorage.hasOwnProperty key

  # Retrieve the value associated with the specified key from `localStorage`.  
  # If the value is found, parse it as JSON before being returning it;
  # otherwise return `undefined`.
  get: (key) ->
    value = localStorage[key]
    return if value? then JSON.parse value else value

  # Initialize the value of the specified key in `localStorage`.  
  # If the value is currently `undefined`, assign the specified default value;
  # otherwise reassign itself.
  init: (key, defaultValue) ->
    value = utils.get key
    return utils.set key, value ? defaultValue

  # Remove the specified key from `localStorage`.
  remove: (key) ->
    value = utils.get key
    delete localStorage[key]
    return value

  # Copy the value of the existing key to that of the new key then remove the
  # old key from `localStorage`.  
  # If the old key doesn't exist in `localStorage`, assign the specified
  # default value to it instead.
  rename: (oldKey, newKey, defaultValue) ->
    if utils.exists oldKey
      utils.init newKey, utils.get oldKey
      utils.remove oldKey
    else
      utils.init newKey, defaultValue

  # Set the value of the specified key in `localStorage`.  
  # If the specified value is `undefined`, assign that value directly to the
  # key; otherwise transform it to a JSON string beforehand.
  set: (key, value) ->
    oldValue = utils.get key
    localStorage[key] = if value? then JSON.stringify value else value
    return oldValue

  # Internationalization functions
  # ------------------------------


  # Output all failed `assertions`.
  assert: (assertions...) ->
    console.assert assertion for assertion in assertions if @logging()

  # Create/increment a counter and output its current count for all `names`.
  count: (names...) ->
    console.count name for name in names if @logging()

  # Output all debug `entries`.
  debug: (entries...) ->
    console.debug entry for entry in entries if @logging()

  # Display an interactive listing of the properties of all `entries`.
  dir: (entries...) ->
    console.dir entry for entry in entries if @logging()

  # Output all error `entries`.
  error: (entries...) ->
    console.error entry for entry in entries if @logging()

  # Output all informative `entries`.
  info: (entries...) ->
    console.info entry for entry in entries if @logging()

  # Output all general `entries`.
  log: (entries...) ->
    console.log entry for entry in entries if @logging()

  # Indicates whether or not logging is enabled.
  logging: ->
    @get 'log'

  # Start a timer for all `names`.
  time: (names...) ->
    console.time name for name in names if @logging()

  # Stop a timer and output its elapsed time in milliseconds for all `names`.
  timeEnd: (names...) ->
    console.timeEnd name for name in names if @logging()

  # Output a stack trace.
  trace: ->
    console.trace() if @logging()

  # Output all warning `entries`.
  warn: (entries...) ->
    console.warn entry for entry in entries if @logging()