Fix for 3016181, thanks to Tom Goddard for patch