I've spun this off as #2965.  The current solution seems good enough for now.