Fix scaling bugs

Change-Id: I5ed17559c3768fc800052317f78320451a87f52a