Fixes to make it compile, but segfaults