Issue #40: was clamping with an off-by-one error that seems to have been the problem