fix initial scaling under some circumstances

and improve performance