Fixed crash

Title says all, see commit for details