Refactored scaling of datasets.

As discussed today.