Don't know why this fixed the segfault at the end, but it did. Should
watch for memory leaks when destroying objects