segfault repaired, preparing to remove diagnostic print statements and implement csv output