fixed some segfaults