Second attempt to fix segfault