Fix duplicate object IDs for command objects.

Fixes #5584