Heavy refactoring to integrate the bounds and the scaling.