Applied @cgohlke 's diff.