Please review the attached patch. It was inspired by the patch attached to the bug report. Thanks.