Yet another resubmission of pull request #1779

Yet another resubmission of pull request #1779. Hopefully it will submit against the "post-2.4" branch as intended.