diff --git a/src/RoomInfoListItem.h b/src/RoomInfoListItem.h
index baa8b98ba8cfd9155ce53b6c060d660d814e13af..c2826f6ff20c55c12e06519b040ef610197329b9 100644
--- a/src/RoomInfoListItem.h
+++ b/src/RoomInfoListItem.h
@@ -217,4 +217,6 @@ private:
 
         QColor bubbleBgColor_;
         QColor bubbleFgColor_;
+
+        friend struct room_sort;
 };
diff --git a/src/RoomList.cpp b/src/RoomList.cpp
index 67a7ac400396943687b7808a1ffe09f63d1e7b52..10042c9455e0db4c9351f80eef5667db1ac8e092 100644
--- a/src/RoomList.cpp
+++ b/src/RoomList.cpp
@@ -353,8 +353,8 @@ RoomList::updateRoomDescription(const QString &roomid, const DescInfo &info)
 
 struct room_sort
 {
-        bool operator()(const QSharedPointer<RoomInfoListItem> a,
-                        const QSharedPointer<RoomInfoListItem> b) const
+        bool operator()(const QSharedPointer<RoomInfoListItem> &a,
+                        const QSharedPointer<RoomInfoListItem> &b) const
         {
                 // Sort by "importance" (i.e. invites before mentions before
                 // notifs before new events before old events), then secondly
@@ -370,9 +370,9 @@ struct room_sort
                 // Now sort by recency
                 // Zero if empty, otherwise the time that the event occured
                 const uint64_t a_recency =
-                  a->lastMessageInfo().userid.isEmpty() ? 0 : a->lastMessageInfo().timestamp;
+                  a->lastMsgInfo_.userid.isEmpty() ? 0 : a->lastMsgInfo_.timestamp;
                 const uint64_t b_recency =
-                  b->lastMessageInfo().userid.isEmpty() ? 0 : b->lastMessageInfo().timestamp;
+                  b->lastMsgInfo_.userid.isEmpty() ? 0 : b->lastMsgInfo_.timestamp;
                 return a_recency > b_recency;
         }
 };