Add iOS5 compatibility, close #2