- fix possible leaks when changing message type