main.c segfaults, take a look