Add scaleToRegion function.
Fixed type signatures for several functions.