Fixed all possible crashes