Fix some segfaults.