Do not allow lower bound values > upper bound in ranges

Fixes #329.