Convert to C++
Use top-level names.

Add tests. Fix some other index problems.
Preserve order in combine_vars
Add news item.