Very unoptimized, still runs in <1min.