Code cleanup and performance fixes.
Fix for iOS devices in private mode.