Fix minor segfaults