Fix a few bounds checks