Fix bad patterns

Step 1. Find this patterns
Step 2. Rewrite it with fsm