     @_fetchQueue    = []
     @appStorage     = KD.getSingleton('appStorageController').storage 'Finder', '1.1'
 
-    @getPublishedApps()
-    @createExtensionToAppMap()
-    @fetchUserDefaultAppConfig()
+    @fetchApps =>
+      @getPublishedApps()
+      @createExtensionToAppMap()
+      @fetchUserDefaultAppConfig()
 
     @on "UpdateDefaultAppConfig", (extension, appName) =>
       @updateDefaultAppConfig extension, appName


  createExtensionToAppMap: ->
    @extensionToApp = map = {}
    @fetchApps (err, res) =>
      for key, app of res
        fileTypes = app.fileTypes
        if fileTypes
          for type in fileTypes
            map[type] = [] unless map[type]
            map[type].push app.name

      # Still there should be a more elagant way to add ace file types into map.
      for type in KD.getAppOptions("Ace").fileTypes
        map[type] = [] unless map[type]
        map[type].push "Ace"

  fetchUserDefaultAppConfig: ->
    @appConfigStorage = new AppStorage "DefaultAppConfig", "1.0"


  getPublishedApps: (callback) ->
    # return unless KD.isLoggedIn()
    appNames = []
    appNames.push appName for appName, manifest of @getManifests()

    query = "manifest.name": "$in": appNames
    KD.remote.api.JApp.someWithRelationship query, {}, (err, apps) =>
      @publishedApps = map = {}
      apps.forEach (app) =>
        map[app.manifest.name] = app
      @emit "UserAppModelsFetched", map
      callback? map

  isAppUpdateAvailable: (appName, appVersion) ->
    if @publishedApps[appName]
