Fixing memory leaks reported by Valgrind in message logging layer.