Minor fixes about ungetc and polluting stream