Re #10031. Some code restructuring.