public void LoadLibraries(List<DirectoryInfo> libraries)
        {
            LibraryData lib = new LibraryData();

            StreamWriter writer = new StreamWriter(new FileInfo("outputList.txt").Open(FileMode.Create, FileAccess.Write));
            foreach (DirectoryInfo library in libraries)
            {
            retry:
                FileInfo precompFile = new FileInfo(library.FullName + "\\Precompiled.LibraryData");
                /*if (!precompFile.Exists)*/
                CompileLibrary(library, writer);
                IFormatter formatter = new BinaryFormatter();
                Stream stream = precompFile.OpenRead();
                try
                {
                    lib.Join((LibraryData) formatter.Deserialize(stream));
                    stream.Close();
                }
                catch (Exception err)
                {
                    stream.Close();
                    precompFile.Delete();
                    goto retry;
                }
            }
            libraryData = lib;

            {
                List<AMethodDecl> newMethods = new List<AMethodDecl>();
                List<AFieldDecl> newFields = new List<AFieldDecl>();
                XmlTextReader reader = new XmlTextReader(new FileInfo("Galaxy.xml").Open(FileMode.Open, FileAccess.Read));

                while (reader.Read())
                {
                    if (reader.NodeType != XmlNodeType.Element)
                        continue;

                    if (reader.Name == "KeyWord")
                    {
                        if (reader.GetAttribute("func") == null)
                        {
                            AFieldDecl fieldDecl = new AFieldDecl(new APublicVisibilityModifier(), null, null, null, new TIdentifier(reader.GetAttribute("name")), null);
                            newFields.Add(fieldDecl);
                            continue;
                        }
                        AMethodDecl methodDecl = new AMethodDecl();
                        methodDecl.SetName(new TIdentifier(reader.GetAttribute("name")));
                        while (reader.Read())
                        {
                            if (reader.NodeType == XmlNodeType.EndElement)
                            {
                                break;
                            }
                            if (reader.NodeType != XmlNodeType.Element)
                                continue;
                            if (reader.Name != "Param")
                                continue;
                            string type = reader.GetAttribute("name");
                            type = type.Substring(0, type.IndexOf(" "));
                            string name = reader.GetAttribute("name");
                            name = name.Substring(name.IndexOf(" ") + 1);

                            methodDecl.GetFormals().Add(new AALocalDecl(new APublicVisibilityModifier(), null, null, null, null,
                                                                        new ANamedType(new TIdentifier(type), null),
                                                                        new TIdentifier(name), null));

                        }
                        if (reader.EOF)
                            break;
                        newMethods.Add(methodDecl);
                    }
                }

                reader.Close();

                List<AMethodDecl> oldMethods = new List<AMethodDecl>();
                oldMethods.AddRange(libraryData.Methods);
                List<AFieldDecl> oldFields = new List<AFieldDecl>();
                oldFields.AddRange(libraryData.Fields);

                //Remove dublicates in old
                for (int i = 0; i < oldMethods.Count; i++)
                {
                    for (int j = i + 1; j < oldMethods.Count; j++)
                    {
                        if (oldMethods[i].GetName().Text == oldMethods[j].GetName().Text)
                        {
                            oldMethods.RemoveAt(j);
                            j--;
                        }
                    }
                }

                for (int i = 0; i < oldFields.Count; i++)
                {
                    for (int j = i + 1; j < oldFields.Count; j++)
                    {
                        if (oldFields[i].GetName().Text == oldFields[j].GetName().Text)
                        {
                            oldFields.RemoveAt(j);
                            j--;
                        }
                    }
                }

                //Remove dublicates in new
                for (int i = 0; i < newMethods.Count; i++)
                {
                    for (int j = i + 1; j < newMethods.Count; j++)
                    {
                        if (newMethods[i].GetName().Text == newMethods[j].GetName().Text)
                        {
                            newMethods.RemoveAt(j);
                            j--;
                        }
                    }
                }

                for (int i = 0; i < newFields.Count; i++)
                {
                    for (int j = i + 1; j < newFields.Count; j++)
                    {
                        if (newFields[i].GetName().Text == newFields[j].GetName().Text)
                        {
                            newFields.RemoveAt(j);
                            j--;
                        }
                    }
                }

                //Remove stuff they agree on
                for (int i = 0; i < newFields.Count; i++)
                {
                    for (int j = 0; j < oldFields.Count; j++)
                    {
                        if (newFields[i].GetName().Text == oldFields[j].GetName().Text)
                        {
                            newFields.RemoveAt(i);
                            oldFields.RemoveAt(j);
                            i--;
                            break;
                        }
                    }
                }
                for (int j = 0; j < oldFields.Count; j++)
                {
                    if (oldFields[j].GetStatic() != null)
                    {
                        oldFields.RemoveAt(j);
                        j--;
                    }
                }
                for (int i = 0; i < newMethods.Count; i++)
                {
                    for (int j = 0; j < oldMethods.Count; j++)
                    {
                        if (newMethods[i].GetName().Text == oldMethods[j].GetName().Text)
                        {
                            newMethods.RemoveAt(i);
                            oldMethods.RemoveAt(j);
                            i--;
                            break;
                        }
                    }
                }
                for (int j = 0; j < oldMethods.Count; j++)
                {
                    if (oldMethods[j].GetStatic() != null ||
                        (oldMethods[j].GetNative() == null && oldMethods[j].GetBlock() == null))
                    {
                        oldMethods.RemoveAt(j);
                        j--;
                    }
                }

            }

            {
                /*StreamWriter writer = new StreamWriter(new FileInfo("outputList.txt").Open(FileMode.Create, FileAccess.Write));
                foreach (AMethodDecl method in libraryData.Methods)
                {
                    string str = "native " + TypeToString(method.GetReturnType()) + " " + method.GetName().Text +
                                 "(";
                    bool first = true;
                    foreach (AALocalDecl formal in method.GetFormals())
                    {
                        if (!first)
                            str += ", ";
                        str += TypeToString(formal.GetType()) + " " + formal.GetName().Text;
                        first = false;
                    }
                    str += ");";

                    writer.WriteLine(str);
                }

                foreach (AFieldDecl field in libraryData.Fields)
                {
                    if (field.GetName().Text == "libNtve_gv__GameUIVisible")
                        writer = writer;
                    writer.WriteLine(TypeToString(field.GetType()) + " " + field.GetName().Text + ";");
                }*/
                writer.Flush();
                writer.Close();
            }
        }