Added better touch scaling code from the dinomage branch.