Fixed nullptr crashes