Clean up scaleGrid code