 			var tempPrerequisites:Object = {};
 
 			// Fill definitions and temp dependencies
+			var defId:String;
 			var ns:Namespace = _source.namespace("");
-
-			// http://code.google.com/p/redtamarin/wiki/SWC
-
 			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 = new Definition();
-					definition.id = defXML.@id;
-					definition.script = scriptXML.@name;
-					definition.modified = scriptXML.@mod;
-					definition.size = scriptXML.@size;
-					definition.optimizedSize = scriptXML.@optimizedsize;
-					definition.name = definition.id.slice(definition.id.lastIndexOf(":") + 1);
-
+					var definition:Definition = newCompiledDefinition(defXML, scriptXML);
 					var v:Vector.<String>;
 
 					v = tempDependencies[definition.id] = new <String>[];
 					for each (var depXML:XML in scriptXML[depName])
 					{
-						v.push(depXML.@id);
+						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])
 					{
-						v.push(preXML.@id);
+						var preId:String = preXML.@id;
+						if (v.indexOf(preId) < 0)
+						{
+							v.push(preId);
+						}
 					}
 
 					_lookup[definition.id] = definition;

			}

			// Create external definitions
			for each (var extXML:XML in _source["external-defs"]["ext"])
			{
				definition = _lookup[extXML.@id];
				if (definition == null)
				{
					definition = new Definition();
					definition.id = extXML.@id;
					definition.name = definition.id.slice(definition.id.lastIndexOf(":") + 1);
					_lookup[definition.id] = definition;
				}
				definition.isExternal = true;
			}

			// Fill dependencies and prerequisites
			for each (definition in _lookup)
			{
				var id:String;
				for each (id in tempDependencies[definition.id])
				{
					var dependency:Definition = _lookup[id];
					if (dependency)
					{
						definition.dependencies.push(dependency);
					}
				}
				for each (id in tempPrerequisites[definition.id])
				{
					var prerequisite:Definition = _lookup[id];
					if (prerequisite)
					{
						definition.prerequisites.push(prerequisite);

				_maxLevel = definition.level;
			}
		}

		private function newCompiledDefinition(defXML:XML, scriptXML:XML):Definition
		{
			var d:Definition = new Definition();
			d.id = defXML.@id;
			d.script = scriptXML.@name;
			d.modified = scriptXML.@mod;
			d.size = scriptXML.@size;
			d.optimizedSize = scriptXML.@optimizedsize;
			d.name = d.id.slice(d.id.lastIndexOf(":") + 1);
			return d;
		}

		private function newExternalDefinition(id:String):Definition
		{
			var d:Definition = new Definition();
			d.id = id;
			d.name = d.id.slice(d.id.lastIndexOf(":") + 1);
			d.isExternal = true;
			return d;
		}
	}
}