 window.mem0r1es = {} if not window.mem0r1es?
 
 class window.mem0r1es.Background
-  init : (sendResponse = null) ->
-    console.log "activating mem0r1es"
+  init : () ->
+    console.log "initializing mem0r1es"
     #open and initialize the database
-    if not @state?
-      @storageManager = new mem0r1es.StorageManager()
-      @storageManager.openDB()
+    @storageManager = new mem0r1es.StorageManager()
+    @storageManager.openDB()
     
     #Create the icon for the popup
     @icon = new mem0r1es.Icon()

    if @state is "on"
      @deactivate sendResponse
    else if @state is "off"
      @init sendResponse
  
  getState : (sendResponse) ->
    if @state is "on"

    chrome.extension.onMessage.addListener((request, sender, sendResponse) =>
      console.log "redirecting a message to #{request.module}"
      switch(request.module)
        when "storageManager"
          @storageManager.onMessage request.message, sender, sendResponse
        when "navigationListener"
          @navigationListener.onMessage request.message, sender, sendResponse
        when "documentPreprocessor"
          if @state is "on"
            @DocumentPreprocessorPool.onMessage request.message, sender, sendResponse 
        when "DSLProcessor"
          @dslProcessor.onMessage request.message, sender, sendResponse
        when "background"
          @onMessage request.message, sender, sendResponse
        when "userStudyToolbox"
          @userStudyToolbox.onMessage request.message, sender, sendResponse
        else console.log "Could not redirect the message from the popup user interface. #{request.module} is not a valid module"
      #the listener must return true if the response needs to be sent asynchronously
      return true)
    console.log "Message listener ready"
    return

background = new mem0r1es.Background
