Sprinkle a few more assertions to help along the way. (Actually, it was justified; I just hadn't made explicit the relation to the value of fdpos that all two callers specify.)
Preparation for converting it to use a fixed-size window.