Fix based on the suggested patch in issue 543.