The code was supposed to prevent constantly overshooting while turning to face a new direction, but it had quite a different effect. This is the kind of weirdness that happens on the very first attempt of adding new code.
It was fixed shortly after recording this. =)