Fix the layout state machine