fixed some crashing bugs