    public List<Path> generate() throws IOException {
        List<Path> paths = new ArrayList<>();
        Map<String, List<Tick>> demomap = new LinkedHashMap<>();
        Map<String, String> peeknext = new LinkedHashMap<>();
        String previous = null;
        for (Tick tick : ticklist) {
            List<Tick> ticks;
            if (!demomap.containsKey(tick.getDemoname())) {
                ticks = new ArrayList<>();
                demomap.put(tick.getDemoname(), ticks);
            } else {
                ticks = demomap.get(tick.getDemoname());
            }
            ticks.add(tick);
            if (previous != null) {
                if (!peeknext.containsKey(previous) && !previous.equals(tick.getDemoname())) {
                    peeknext.put(previous, tick.getDemoname());
                }
            }
            previous = tick.getDemoname();
        }
        for (Entry<String, List<Tick>> e : demomap.entrySet()) {
            String demo = e.getKey();
            log.finer("creating vdm for demo: " + demo);
            List<String> lines = new ArrayList<>();
            lines.add("demoactions\n{");
            int count = 1;
            int previousEndTick = 0;
            for (Tick tick : e.getValue()) {
                lines.add(segment(count++, "SkipAhead", "skip",
                        "starttick \"" + (previousEndTick + 1) + "\"",
                        "skiptotick \"" + (tick.getStart() - 1) + "\""));
                lines.add(segment(count++, "PlayCommands", "startrec",
                        "commands \"startrecording\""));
                lines.add(segment(count++, "PlayCommands", "stoprec",
                        "starttick \"" + tick.getEnd() + "\"",
                        "commands \"stoprecording\""));
                previousEndTick = tick.getEnd();
            }
            String nextdemo = peeknext.get(demo);
            if (nextdemo != null) {
                lines.add(segment(count++, "PlayCommands", "nextdem",
                        "starttick \"" + (previousEndTick + 1) + "\"",
                        "commands \"playdemo " + nextdemo + "\""));
            } else {
                lines.add(segment(count++, "PlayCommands", "stopdem",
                        "starttick \"" + (previousEndTick + 1) + "\"",
                        "commands \"stopdemo\""));
            }
            lines.add("}\n");
            Path added = Files.write(
                    tfpath.resolve(demo.substring(0, demo.indexOf(".dem")) + ".vdm"), lines,
                    Charset.defaultCharset());
            paths.add(added);
            log.fine("VDM file written to " + added);
        }
        return paths;
    }

    public List<Path> generate() throws IOException {
        List<Path> paths = new ArrayList<>();
        Map<String, List<Tick>> demomap = new LinkedHashMap<>();
        Map<String, String> peeknext = new LinkedHashMap<>();
        String previous = null;
        for (Tick tick : ticklist) {
            List<Tick> ticks;
            if (!demomap.containsKey(tick.getDemoname())) {
                ticks = new ArrayList<>();
                demomap.put(tick.getDemoname(), ticks);
            } else {
                ticks = demomap.get(tick.getDemoname());
            }
            ticks.add(tick);
            if (previous != null) {
                if (!peeknext.containsKey(previous) && !previous.equals(tick.getDemoname())) {
                    peeknext.put(previous, tick.getDemoname());
                }
            }
            previous = tick.getDemoname();
        }
        for (Entry<String, List<Tick>> e : demomap.entrySet()) {
            String demo = e.getKey();
            log.finer("creating vdm for demo: " + demo);
            List<String> lines = new ArrayList<>();
            lines.add("demoactions\n{");
            int count = 1;
            int previousEndTick = 0;
            for (Tick tick : e.getValue()) {
                lines.add(segment(count++, "SkipAhead", "skip",
                        "starttick \"" + (previousEndTick + 1) + "\"",
                        "skiptotick \"" + (tick.getStart() - 1) + "\""));
                lines.add(segment(count++, "PlayCommands", "startrec",
                        "starttick \"" + tick.getStart() + "\"",
                        "commands \"startrecording\""));
                lines.add(segment(count++, "PlayCommands", "stoprec",
                        "starttick \"" + tick.getEnd() + "\"",
                        "commands \"stoprecording\""));
                previousEndTick = tick.getEnd();
            }
            String nextdemo = peeknext.get(demo);
            if (nextdemo != null) {
                lines.add(segment(count++, "PlayCommands", "nextdem",
                        "starttick \"" + (previousEndTick + 1) + "\"",
                        "commands \"playdemo " + nextdemo + "\""));
            } else {
                lines.add(segment(count++, "PlayCommands", "stopdem",
                        "starttick \"" + (previousEndTick + 1) + "\"",
                        "commands \"stopdemo\""));
            }
            lines.add("}\n");
            Path added = Files.write(
                    tfpath.resolve(demo.substring(0, demo.indexOf(".dem")) + ".vdm"), lines,
                    Charset.defaultCharset());
            paths.add(added);
            log.fine("VDM file written to " + added);
        }
        return paths;
    }
