I put in some additional checks. Could someone check if that fixes the crashes?