Can't figure out this segfault, and I'm tired