Fixing a bug in the scaling and account for the device scale.