Store the remote address as part of the payload since it doesn't seem to be available later.
Some code cleanup and lots of comments.