Further improvements to EOF handling.