Add commander.

Note that this commit also includes some cleanup, which were difficult
to avoid in the same commit.