         FlexGlobals.topLevelApplication.callLater(loadModule);
     }
 
-    private function moduleInfo_readyHandler(event:ModuleEvent):void
+    private function processModuleInfo(moduleInfo:IModuleInfo):void
     {
         if (Log.isInfo())
         {
             LOG.info('Module loaded: {0}', swf.url);
         }
 
-        var moduleInfo:IModuleInfo = event.currentTarget as IModuleInfo;
-        moduleInfo.removeEventListener(ModuleEvent.READY, moduleInfo_readyHandler);
-        moduleInfo.removeEventListener(ModuleEvent.ERROR, moduleInfo_errorHandler);
-
         if (config && config.exists)
         {
             if (Log.isInfo())

    {
        var moduleInfo:IModuleInfo = event.module;
        moduleInfo.removeEventListener(ModuleEvent.ERROR, moduleInfo_errorHandler);
        moduleInfo.removeEventListener(ModuleEvent.READY, moduleInfo_readyHandler);
        this.moduleInfo = null;
        dispatchError();
    }

            fileStream.readBytes(fileBytes);
            fileStream.close();

            //Use ModuleEvent.PROGRESS instead of ModuleEvent.READY to avoid the case where the latter is never dispatched.
            moduleInfo.addEventListener(ModuleEvent.PROGRESS, moduleInfo_progressHandler);
            moduleInfo.addEventListener(ModuleEvent.ERROR, moduleInfo_errorHandler);
            moduleInfo.load(null, null, fileBytes, FlexGlobals.topLevelApplication.moduleFactory);
        }
    }

    private function moduleInfo_progressHandler(event:ModuleEvent):void
    {
        if (event.bytesLoaded == event.bytesTotal)
        {
            var moduleInfo:IModuleInfo = event.currentTarget as IModuleInfo;
            moduleInfo.removeEventListener(ModuleEvent.PROGRESS, moduleInfo_progressHandler);
            moduleInfo.removeEventListener(ModuleEvent.ERROR, moduleInfo_errorHandler);
            FlexGlobals.topLevelApplication.callLater(processModuleInfo, [ moduleInfo ]);
        }
    }

