Fixed a few crashing bugs