Gittrac #4312:  Hopefully final implementation of main bug fix;
removed temporary code.