Merged in trunk (with a small alteration to remove redundancy between the two cases), adding it to 6.1 so I don't forget to backport it.
Merged in trunk (with a small alteration to remove redundancy between the two cases), adding it to 6.1 so I don't forget to backport it.