Fixed memory leak involving messages not being freed.