Move the resets and testings of the BLOCKED flag to where they make more sense.
Improved use of EOF state to avoid worthless allocations.