Improve performance of the unread messages backlog fetcher by using a normal JOIN instead of a LEFT JOIN.
Correct for bug in which buffer.lastseenmsgid was set to a value higher than buffer.lastmsgid. This is a client bug, but this prevents it from screwing up the database.