Patch from James H which shouldn't change the functionality of