Fix various bugs in relation to the I-DATA chunk support
This is joint work with rrs.
MFC after: 3 days