Slight refactoring of command execution.