Fix Trac #4917: try a bit harder to unify on-the-fly