Fix bugs in committing/applying state machine commands.