changes that fix segfaults