Moved payload buffer to thread ctx
Some code style fixes (long lines)