Fix crash caused by #783

(I should really test these things before merging)