Fixed bugs, now it compiles but segfaults