Clean up state loop
Use swap! in diff handling to update state

- Ensures state updates always use the current state as a basis.