fixed sorting of messages
Rebase with master