State machine rework (WIP)