Refine some of the bounds checking.