Fixed some bugs/crashes