Forward port of Richard Sharpe's <realrichardsharpe@gmail.com> fix for bug #8970...