Fix eos detection