Fix bound checks in Input and Buffers classes.