Made compatible with the presence of multiple scans in planC.