Fix some crashes (hopefully...)