Fixed several iOS crash bugs