Apply patch from @sasanrose