Correcting segfaults