fixed some crashes on ios5