merged the code. There is a segfault when I run it, but all of the output files still seem to successfully output.