Various optimizations, specially for onResize