Bug fixes

Various fixes to trace back errors
`if state.sweeping():`