static bool Update(string bundle_id)
        {
            HashSet<string> new_paths = new HashSet<string>();
            HashSet<string> new_exts = new HashSet<string>();
            StringBuilder sb = new StringBuilder();
            string[] idstring_data;

            Console.WriteLine("Updating Paths and Extensions...");

            bundle = new BundleHeader();
            if (!bundle.Load(bundle_id))
            {
                Console.WriteLine("[Update error] Failed to parse bundle header. ({0})", bundle_id);
                return false;
            }

            string bundle_file = bundle_id + ".bundle";
            if (!File.Exists(bundle_file))
            {
                Console.WriteLine("[Update error] Bundle file does not exist. ({0})", bundle_file);
                return false;
            }
            using (FileStream fs = new FileStream(bundle_file, FileMode.Open, FileAccess.Read))
            {
                using (BinaryReader br = new BinaryReader(fs))
                {
                    byte[] data;
                    foreach (BundleEntry be in bundle.Entries)
                    {
                        string path = String.Format("unknown_{0:x}.bin", be.id);
                        NameEntry ne = name_index.Id2Name(be.id);
                        if (ne != null)
                        {
                            string name = known_index.GetPath(ne.path);
                            string extension = known_index.GetExtension(ne.extension);

                            if (name != null)
                            {
                                path = name;
                            }
                            else
                            {
                                path = String.Format("{0:x}", ne.path);
                            }
                        }

                        if (path.Contains("idstring_lookup"))
                        {
                            fs.Position = be.address;
                            if (be.length == -1)
                            {
                                data = br.ReadBytes((int)(fs.Length - fs.Position));
                            }
                            else
                            {
                                data = br.ReadBytes((int)be.length);
                            }

                            foreach (byte read in data)
                            {
                                sb.Append((char)read);
                            }

                            idstring_data = sb.ToString().Split('\0');
                            sb.Clear();

                            foreach (string idstring in idstring_data)
                            {
                                if (idstring.Contains("/"))
                                    new_paths.Add(idstring.ToLower());
                                else if (!idstring.Contains("/") && !idstring.Contains(".") && !idstring.Contains(":") && !idstring.Contains("\\"))
                                    new_exts.Add(idstring.ToLower());
                            }

                            new_paths.Add("idstring_lookup");
                            new_paths.Add("existing_banks");

                            known_index.Clear();
                            known_index.Load(ref new_paths, ref new_exts);

                            foreach (string file in Directory.EnumerateFiles(".", "*_h.bundle"))
                            {
                                string bundle_id_list = file.Replace("_h.bundle", "");
                                bundle_id_list = bundle_id_list.Remove(0, 2);
                                bundle = new BundleHeader();
                                if (!bundle.Load(bundle_id_list))
                                {
                                    Console.WriteLine("[Update error] Failed to parse bundle header. ({0})", bundle_id_list);
                                    return false;
                                }
                                ListBundle(bundle_id_list);
                            }

                            known_index.GenerateUsedPaths();
                            known_index.GenerateUsedExts();

                            new_paths.Clear();
                            new_exts.Clear();

                            return true;
                        }
                    }
                    br.Close();
                }
                fs.Close();
            }

            return false;
        }
        static void Main(string[] args)
        {
            foreach (string arg in args)
            {
                switch (arg)
                {
                    case "-list":
                        list_only = true;
                        break;
                    case "-extract_all":
                        extract_all = true;
                        break;
                    case "-update":
                        update = true;
                        break;
                    case "-update_only":
                        update = true;
                        update_only = true;
                        break;
                    default:
                        extract_one = true;
                        extract_id = arg;
                        break;
                }
            }
            if (!Load())
                return;

            if (update)
            {
                if (!Update("all_14"))
                {
                    Console.WriteLine("Error while updating");
                    return;
                }

                update = false;
                known_index.Clear();
                name_index.Clear();
                if (!Load())
                    return;
                Console.WriteLine("Paths and Extensions Updated Successfully");
            }
            if (update_only)
                return;

            if (extract_one && extract_id.Length > 0)
            {
                bundle = new BundleHeader();
                if (!bundle.Load(extract_id))
                {
                    Console.WriteLine("Failed to parse bundle header.");
                    return;
                }
                if (list_only)
                {
                    ListBundle(extract_id);
                }
                else
                {
                    ExtractBundle(extract_id);
                }
            }
            else
            {
                foreach (string file in Directory.EnumerateFiles(".", "*_h.bundle"))
                {
                    string bundle_id = file.Replace("_h.bundle", "");
                    bundle_id = bundle_id.Remove(0, 2);
                    bundle = new BundleHeader();
                    Console.WriteLine("Loading bundle header...");
                    if (!bundle.Load(bundle_id))
                    {
                        Console.WriteLine("Failed to parse bundle header.");
                        return;
                    }
                    Console.WriteLine("Extract bundle: {0}", bundle_id);

                    if (list_only)
                    {
                        ListBundle(bundle_id);
                    }
                    else
                    {
                        ExtractBundle(bundle_id);
                    }
                }
            }
        }