Fixed crashing bugs