both "state" are refs and the second one is modified, while the first one is just read for info .. the result is not very predictable.
Need to define stateLast and stateNext to decouple these and then stateLast=stateNext after the call (or smth like that).
This place is most likely the reason for the regressions that I observe.
Chris, would you like to try to fix this or should I take over this PR?