Fixed bugs in logic expressions for State switching.

Continued CCA code.