Optimization for ipads and solve some bugs