 			}
 
 			// Create external definitions
-			for each (var extXML:XML in _source["external-defs"]["ext"])
-			{
-				definition = _lookup[extXML.@id];
+			for each (var extXML:XML in _source[extDefName][extName])
+			{
+				definition = _lookup[String(extXML.@id)];
 				if (definition == null)
 				{
-					definition = new Definition();
-					definition.id = extXML.@id;
-					definition.name = definition.id.slice(definition.id.lastIndexOf(":") + 1);
+					definition = newExternalDefinition(extXML.@id);
 					_lookup[definition.id] = definition;
 				}
 				definition.isExternal = true;
+			}
+
+			// Create externals for missing definitions
+			var missingDefinitions:Vector.<Definition> = new <Definition>[];
+			for each (definition in _lookup)
+			{
+				for each (defId in tempDependencies[definition.id])
+				{
+					if (!_lookup[defId])
+					{
+						missingDefinitions.push(newExternalDefinition(defId));
+					}
+				}
+				for each (defId in tempPrerequisites[definition.id])
+				{
+					if (!_lookup[defId])
+					{
+						missingDefinitions.push(newExternalDefinition(defId));
+					}
+				}
+			}
+			for each (definition in missingDefinitions)
+			{
+				_lookup[definition.id] = definition;
 			}
 
 			// Fill dependencies and prerequisites
 			for each (definition in _lookup)
 			{
-				var id:String;
-				for each (id in tempDependencies[definition.id])
-				{
-					var dependency:Definition = _lookup[id];
+				for each (defId in tempDependencies[definition.id])
+				{
+					var dependency:Definition = _lookup[defId];
 					if (dependency)
 					{
 						definition.dependencies.push(dependency);
 					}
 				}
-				for each (id in tempPrerequisites[definition.id])
-				{
-					var prerequisite:Definition = _lookup[id];
+				for each (defId in tempPrerequisites[definition.id])
+				{
+					var prerequisite:Definition = _lookup[defId];
 					if (prerequisite)
 					{
 						definition.prerequisites.push(prerequisite);

				_maxLevel = definition.level;
			}
		}
	}
}
			var tempPrerequisites:Object = {};

			// Fill definitions and temp dependencies
			var defId:String;
			var ns:Namespace = _source.namespace("");
			var scriptName:Object = ns ? new QName(ns, "script") : "script";
			var defName:Object = ns ? new QName(ns, "def") : "def";
			var depName:Object = ns ? new QName(ns, "dep") : "dep";
			var preName:Object = ns ? new QName(ns, "pre") : "pre";
			var extName:Object = ns ? new QName(ns, "ext") : "ext";
			var extDefName:Object = ns ? new QName(ns, "external-defs") : "external-defs";

			for each (var scriptXML:XML in _source.descendants(scriptName))
			{
				var defXML:XML = scriptXML[defName][0];
				if (defXML)
				{
					var definition:Definition = newCompiledDefinition(defXML, scriptXML);
					var v:Vector.<String>;

					v = tempDependencies[definition.id] = new <String>[];
					for each (var depXML:XML in scriptXML[depName])
					{
						var depId:String = depXML.@id;
						if (v.indexOf(depId) < 0)
						{
							v.push(depId);
						}
					}

					v = tempPrerequisites[definition.id] = new <String>[];
					for each (var preXML:XML in scriptXML[preName])
					{
						var preId:String = preXML.@id;
						if (v.indexOf(preId) < 0)
						{
							v.push(preId);
						}
					}

					_lookup[definition.id] = definition;
