Fix UI glitches with state updating.