Back upstream

There's a great deal of work here and this might not automatically merge yet.