Fix scalemax to work as documented. (value * (newmax+1)) / (oldmax+1) is suitable for some purposes, but this isn't one of them.