Multiple improvements.

- msghandler protocol
- custom logger
- other protocol tweaks