Fixed some crashing bugs.