More work on types

Farm out more work to helper classes like InputSequence and NodeSet.