Rework units

Move `toOutput` etc. into -core, using a generic approach.  All the units work.

This was done at the expense of delayed leaves, and hence of arrows. (However, the way we were handling delayed leaves before wasn't really working anyway.) So we could merge this back into `units` but we still need to figure out what we are doing with those.