Merge branch 'V5-4-patches' into V5-5-patches

* V5-4-patches:
  David Jarvie's patch for bug 2507