Fix a couple of bugs with conditional branch with counter