Don't reset ridx,eidx. And fix for #1949
Merge pull request #2188 from takeru/dont_reset_ridx_eidx

Don't reset ridx,eidx. And fix for #1949