Optimizations, and attempts to fix iOS crash