Fix regression in r53316, some more intelligent handling.