Fix crash handling