Fixing the sorting of messages