This code is still a bit voodoo to me, but now we pass all the tests again. (Stepping was broken by 4299874a.)