Fix various errors in argument passing.

Factor out command formatting, too.