Pass raw message and parameters to write listener.
Tidy write() conditionals.
Tidy obsolete bitwise local variables.