Apply patch from @adambiggs.