Compiles but the program still suffers from segfaults