           allRegistered[id].resolved = true
           diModules[id] = { value: value }
           setImm -> onRegister(id, value)
+
+    # only register modules if they're named
+    if id?
+      allRegistered[id] = {
+        dependencies: modules
+        resolved: false
+        resolveMe: resolveMe
+      }
+
+    # trigger resolution if this is an anonymous module
+    if !id?
+      setImm ->
+        checkIfAllDepsDefined(modules) if !lazy
+        resolveMe()


  registerModule: (id, modules, callback) ->

    # if the module is anonymous, there's no need to register it
    if id?
      allRegistered[id] = { dependencies: modules, resolved: false }

    setImm ->
      checkAllRegistered()

      loadModules modules, (loadedModules) ->

        actualCallback = null

        if callback.length < 2
          actualCallback = (required, cb) ->
            cb(null, callback(required))
        else
          actualCallback = callback

        actualCallback loadedModules, (err, value) ->
          return if !id?
          return onError(new Error("Module '#{id}' defined twice")) if diModules[id]

        resolved[m] = diModules[m].value
      else
        missing[m] = true
        beginResolving(m)

    if Object.keys(missing).length == 0
      setImm -> callback(resolved)
