Refactor

A few moves so that things are less indented and
there is less state to carry.