Split up message decoding and message handling.

This makes the code structure document what is happening rather than
having to comment on what is happening next to the handlers. It also makes
it easier to verify the code as packet decoding now happens in one place only.