Fix for a couple of crashes