Bugfixes for iOS5 compatibility