Fixing out-of-bounds bugs