Gittrac #4312:  Fixed the main problem documented in this ticket;
current commit has a bunch of temporary debug code, notes, etc.