Fix a multi-threaded bug under iOS 5/6