Fixed some crash issues