Changed code for exit from synchronization state to a switch on the possible synchronization actions. This should have made it harder to avoid a case.