Hopefully fixed some of those annoying segfaults