Fixed the segfaults