Fixed some crashes