fix #267 valgrind errors

- fix out of memory access
- put `MessageHeader` constructor private to avoid side effects