fix message positions
fix the data race

outbuf.buf and outbuf.pos are both used for reading and writing