fix byteBuffer is not cleared after write; clear code