Use the right CheckResult object for commands.

Fixes #6260
Fix compiler warnings.

Fixes #5823