Fixed some crashes found during submission