Ref #6621: Fixes bugs introduced on earlier commits on this task