Do not reset command count if there are no commands

Prevents another potential segfault.