Refactor to two heads

Makes it clearer what the invariants are.
Cosmetics