Fix a bug that caused crashes on iPad