Cleanups and clarifications in do_command()