    public static void main(String[] args) {
	System.out.print("afck Copyright (C) 2013 Chandler Paul\n" +
			 "This program comes with ABSOLUTELY NO WARRANTY and is distributed under the terms"	+
			 "of the LGPL license. For more information, please see the file LICENSE at the root" 	+
			 "of the source code, or go to http://www.gnu.org/licenses.lgpl.html\n");
        if (args.length > 0) {
            File brokenAliceWorld = new File(args[0]);
            File tmpDir;
            String worldName;
            Random generator = new Random();
            if (!brokenAliceWorld.exists()) {
                System.err.printf("Path specified is not valid! Exiting...\n");
                System.exit(-1);
            }
            worldName = brokenAliceWorld.getPath();
            tmpDir = new File(System.getProperty("java.io.tmpdir") + "/afck-" +
                              Integer.toString(Math.abs(generator.nextInt())));
            tmpDir.mkdirs();
            try {
                ZipFile brokenAliceWorldZip = new ZipFile(brokenAliceWorld);
                Enumeration aliceZipEntries = brokenAliceWorldZip.entries();
                System.out.print("Extracting world...");
                while (aliceZipEntries.hasMoreElements()) {
                    ZipEntry entry = (ZipEntry) aliceZipEntries.nextElement();
                    String currentEntry = entry.getName();
                    File destFile = new File(tmpDir, currentEntry);
                    File destinationParent = destFile.getParentFile();
                    destinationParent.mkdirs();
                    if (!entry.isDirectory()) {
                        BufferedInputStream inputStream = new BufferedInputStream(brokenAliceWorldZip.getInputStream(entry));
                        int currentByte;
                        byte data[] = new byte[BUFFER_SIZE]; 
                        FileOutputStream outputStream = new FileOutputStream(destFile);
                        BufferedOutputStream dest = new BufferedOutputStream(outputStream, BUFFER_SIZE);
                        while ((currentByte = inputStream.read(data, 0, BUFFER_SIZE)) != -1)
                            dest.write(data, 0, currentByte);
                        dest.flush();
                        dest.close();
                        outputStream.close();
                        inputStream.close();
                    }
                }
            }
            catch (ZipException e) {
                System.err.printf("Fatal zip file exception! %s\n" +
                                  "Exiting...\n",
                                  e.getMessage());
                System.exit(-1);
            }
            catch (IOException e) {
                System.err.printf("Fatal I/O Exception: %s\n" +
                                  "Exiting...\n",
                                  e.getMessage());
                System.exit(-1);
            }
            System.out.print(" done!\n");
            try {
                DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
                DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
                for (File file : getAllElementData(tmpDir)) {
                    Document elementData = docBuilder.parse(file);
                    Element rootElement = elementData.getDocumentElement();
                    NodeList propertyList;
                    NodeList itemList;
                    int componentResponsesIndex = 0;
                    boolean indexVariableMarkedCorrectly = false;
                    if (!rootElement.getAttribute("class").equals(
                        "edu.cmu.cs.stage3.alice.core.response.LoopNInOrder"))
                        continue;
                    propertyList = rootElement.getElementsByTagName("property");
                    for (int i = 0; i < propertyList.getLength(); i++) {
                        if (((Element) propertyList.item(i)).getAttribute("name").equals(
                            "componentResponses")) {
                            componentResponsesIndex = i;
                            break;
                        }
                    }
                    itemList = ((Element) propertyList.item(componentResponsesIndex)).getElementsByTagName("item");
                    for (int i = 0; i < itemList.getLength(); i++) {
                         Node item = itemList.item(i);
                        if (((Element) item).getAttribute("criterionClass").equals(
                                "edu.cmu.cs.stage3.alice.core.criterion.InternalReferenceKeyedCriterion") &&
				((Element) item).getTextContext().equals(file.getAbsolutePath().replaceFirst(tmpDir.getAbsolutePath() + "(/|\\\\)(.*(/|\\\\))elementData\\.xml", "$2").replaceAll("/|\\\\", ".") + "index")) {
                            indexVariableMarkedCorrectly = true;
                            break;
                        }
                    }
                    if (indexVariableMarkedCorrectly)
                        continue;
                    System.out.println("Found one!");
                }
            }
            catch (ParserConfigurationException e) {
                System.err.println(e.getMessage());
                System.exit(-1);
            }
            catch (SAXException e) {
                System.err.println(e.getMessage());
                System.exit(-1);
            }
            catch (IOException e) {
                System.err.println(e.getMessage());
                System.exit(-1);
            }
            tmpDir.delete();
        }
    }

    public static void main(String[] args) {
    System.out.print("afck Copyright (C) 2013 Chandler Paul\n" +
             "This program comes with ABSOLUTELY NO WARRANTY and is distributed under the terms"    +
             "of the LGPL license. For more information, please see the file LICENSE at the root"   +
             "of the source code, or go to http://www.gnu.org/licenses.lgpl.html\n");
        if (args.length > 0) {
            File brokenAliceWorld = new File(args[0]);
            File tmpDir;
            String worldName;
            Random generator = new Random();
            if (!brokenAliceWorld.exists()) {
                System.err.printf("Path specified is not valid! Exiting...\n");
                System.exit(-1);
            }
            worldName = brokenAliceWorld.getPath();
            tmpDir = new File(System.getProperty("java.io.tmpdir") + "/afck-" +
                              Integer.toString(Math.abs(generator.nextInt())));
            tmpDir.mkdirs();
            try {
                ZipFile brokenAliceWorldZip = new ZipFile(brokenAliceWorld);
                Enumeration aliceZipEntries = brokenAliceWorldZip.entries();
                System.out.print("Extracting world...");
                while (aliceZipEntries.hasMoreElements()) {
                    ZipEntry entry = (ZipEntry) aliceZipEntries.nextElement();
                    String currentEntry = entry.getName();
                    File destFile = new File(tmpDir, currentEntry);
                    File destinationParent = destFile.getParentFile();
                    destinationParent.mkdirs();
                    if (!entry.isDirectory()) {
                        BufferedInputStream inputStream = new BufferedInputStream(brokenAliceWorldZip.getInputStream(entry));
                        int currentByte;
                        byte data[] = new byte[BUFFER_SIZE]; 
                        FileOutputStream outputStream = new FileOutputStream(destFile);
                        BufferedOutputStream dest = new BufferedOutputStream(outputStream, BUFFER_SIZE);
                        while ((currentByte = inputStream.read(data, 0, BUFFER_SIZE)) != -1)
                            dest.write(data, 0, currentByte);
                        dest.flush();
                        dest.close();
                        outputStream.close();
                        inputStream.close();
                    }
                }
            }
            catch (ZipException e) {
                System.err.printf("Fatal zip file exception! %s\n" +
                                  "Exiting...\n",
                                  e.getMessage());
                System.exit(-1);
            }
            catch (IOException e) {
                System.err.printf("Fatal I/O Exception: %s\n" +
                                  "Exiting...\n",
                                  e.getMessage());
                System.exit(-1);
            }
            System.out.print(" done!\n");
            try {
                DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
                DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
                for (File file : getAllElementData(tmpDir)) {
                    Document elementData = docBuilder.parse(file);
                    Element rootElement = elementData.getDocumentElement();
                    NodeList propertyList;
                    NodeList itemList;
                    int componentResponsesIndex = 0;
                    boolean indexVariableMarkedCorrectly = false;
                    if (!rootElement.getAttribute("class").equals(
                        "edu.cmu.cs.stage3.alice.core.response.LoopNInOrder"))
                        continue;
                    propertyList = rootElement.getElementsByTagName("property");
                    for (int i = 0; i < propertyList.getLength(); i++) {
                        if (((Element) propertyList.item(i)).getAttribute("name").equals(
                            "componentResponses")) {
                            componentResponsesIndex = i;
                            break;
                        }
                    }
                    itemList = ((Element) propertyList.item(componentResponsesIndex)).getElementsByTagName("item");
                    for (int i = 0; i < itemList.getLength(); i++) {
                        Node item = itemList.item(i);
                        String indexString = file.getAbsolutePath().replaceFirst(
                            tmpDir.getAbsolutePath() + "(/|\\\\)(.*(/|\\\\))elementData\\.xml", "$2").
                            replaceAll("/|\\\\", ".") + "index";
                        if (((Element) item).getAttribute("criterionClass").equals(
                                "edu.cmu.cs.stage3.alice.core.criterion.InternalReferenceKeyedCriterion") &&
                            item.getFirstChild().getNodeValue().equals(indexString)) {
                            indexVariableMarkedCorrectly = true;
                            break;
                        }
                    }
                    if (indexVariableMarkedCorrectly)
                        continue;
                    System.out.println("Found one!");
                }
            }
            catch (ParserConfigurationException e) {
                System.err.println(e.getMessage());
                System.exit(-1);
            }
            catch (SAXException e) {
                System.err.println(e.getMessage());
                System.exit(-1);
            }
            catch (IOException e) {
                System.err.println(e.getMessage());
                System.exit(-1);
            }
            tmpDir.delete();
        }
    }
