[range A B C D] and [maxlib/scale A B C D] don't behave correctly when either A>B or C>D or both.
If they are not supposed to (which I don't see a good reason why), then they should at the very least print an error message, rather than output any unpredictable value.
When only C>D but A<B, the output seems to range from C to max(D,1) instead of from C to D.
When A>B, the result doesn't make any sense.
By the way wouldn' it be better to implement these objects as abstractions?