Fix PLC-based mode transition code.