first version of the cleaning state machine, with TODOs