fixed a couple of segfaults