Tweak logic around restarting, to avoid some bugs