Fixed some threading issues on iOS
Merge pull request #1335 from Nezz/ios_threading

Fixed some threading issues on iOS