Some fixes of crashes