Fix crashes found by really bad tests