public static void writeNetworks(Config config, File archiveF) throws IOException, JSONException {
		ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(archiveF)));
		zos.putNextEntry(new ZipEntry("source.json"));
		zos.write(config.toJSON().toString(4).getBytes("UTF-8"));
		
		HashSet<String> taken = new HashSet<String>();
		taken.add("source");
		
		for (Config.Identifier identifier : config.identifiers) {
			String name = getName(identifier, taken);
			zos.putNextEntry(new ZipEntry(name + ".json"));
			zos.write(identifier.toJSON().toString(4).getBytes("UTF-8"));
			if (identifier instanceof Config.NNIdentifier) {
				Config.NNIdentifier id = (Config.NNIdentifier) identifier;
				for (int n = 0; n < id.numberOfNetworks; n++) {
					zos.putNextEntry(new ZipEntry(name + "_weights_" + n));
					new FastLoadingNetwork().initFromNetwork(id.networks.get(n)).saveWeights(zos);
					zos.putNextEntry(new ZipEntry(name + "_targets_" + n));
					writeTargets(id, n, zos);
				}
				zos.putNextEntry(new ZipEntry(name + "_sizes.json"));
				writeRelativeSizeInfo(id, zos);
				zos.putNextEntry(new ZipEntry(name + "_aspectRatios.json"));
				writeAspectRatioInfo(id, zos);
			}
			if (identifier instanceof Config.NumberOfPartsIdentifier) {
				zos.putNextEntry(new ZipEntry(name + "_numberOfParts.json"));
				writeNumberOfPartsInfo((Config.NumberOfPartsIdentifier) identifier, zos);
			}
			if (identifier instanceof Config.TreeIdentifier) {
				zos.putNextEntry(new ZipEntry(name + "_tree"));
				ObjectOutputStream oos = new ObjectOutputStream(zos);
				TreePredict.writeNode(((Config.TreeIdentifier) identifier).tree, oos);
				oos.flush();
			}
			if (identifier instanceof Config.NearestNeighbourIdentifier) {
				zos.putNextEntry(new ZipEntry(name + "_comparisons"));
				ObjectOutputStream oos = new ObjectOutputStream(zos);
				NearestNeighbour.write(((Config.NearestNeighbourIdentifier) identifier).comparisons, oos);
				oos.flush();
			}
		}
		
		zos.closeEntry();
		zos.flush(); // Bug in older versions of Java where close() would swallow flush() errors.
		zos.close();
	}