Prevent out of bounds access to collapse_masks.