improve handling of invalid range values

Heya, I tripped over these two issues with a seemingly broken scanner that provides some NaN values...