 
     try
       userConfig = CSON.readFileSync(@configFilePath)
-      @setAllRecursive(userConfig)
+      @setRecursive(null, userConfig)
       @configFileHasErrors = false
-      @emit 'updated'
-      @emitter.emit 'did-change'
     catch error
       @configFileHasErrors = true
       console.error "Failed to load user config '#{@configFilePath}'", error.message

    @watchSubscription?.close()
    @watchSubscription = null

  update: (event) ->
    return if @configFileHasErrors
    @save()
    @emit 'updated'
    @emitter.emit 'did-change', event

  save: ->
    CSON.writeFileSync(@configFilePath, @settings)

  setAllRecursive: (value) ->
    @setRecursive(key, childValue) for key, childValue of value
    return

  setRecursive: (keyPath, value) ->
    if value? and isPlainObject(value)
      keys = keyPath.split('.')
      for key, childValue of value
        continue unless value.hasOwnProperty(key)
        @setRecursive(keys.concat([key]).join('.'), childValue)
    else
      try
        value = @makeValueConformToSchema(keyPath, value)
        defaultValue = _.valueForKeyPath(@defaultSettings, keyPath)
        value = undefined if _.isEqual(defaultValue, value)
        _.setValueForKeyPath(@settings, keyPath, value)
      catch e
        console.warn("'#{keyPath}' could not be set. Attempted value: #{JSON.stringify(value)}; Schema: #{JSON.stringify(@getSchema(keyPath))}")

    return

  setDefaults: (keyPath, defaults) ->
    unless isPlainObject(defaults)
      return _.setValueForKeyPath(@defaultSettings, keyPath, defaults)

    hash = @defaultSettings
    if keyPath
      for key in keyPath.split('.')
        hash[key] ?= {}
        hash = hash[key]

    _.extend hash, defaults
    @emit 'updated'
    @emitter.emit 'did-change'

  setSchema: (keyPath, schema) ->
    unless isPlainObject(schema)

      catch e
        return false

    @setRawValue(keyPath, value)
    @save() unless @configFileHasErrors
    true

  # Extended: Restore the key path to its default value.
