More segfault fixes