Fix segfaults (incomplete)