fix some crashy bugs