replace ByteBuffer with byte[] because ByteBuffer has state and was creating confusion and bugs