fixed issues with memory management on iOS