Apply patch from Paul Evans