Add debug timings to resize function
Optimize scaling code