Fix segfault in main