diff --git a/src/RoomList.cpp b/src/RoomList.cpp
index 764a8e42817c7d4ddfd9d9ed39d2b30c9afe8c91..67a7ac400396943687b7808a1ffe09f63d1e7b52 100644
--- a/src/RoomList.cpp
+++ b/src/RoomList.cpp
@@ -106,6 +106,10 @@ void
 RoomList::removeRoom(const QString &room_id, bool reset)
 {
         auto roomIt = rooms_.find(room_id);
+        if (roomIt == rooms_.end()) {
+                return;
+        }
+
         for (auto roomSortIt = rooms_sort_cache_.begin(); roomSortIt != rooms_sort_cache_.end();
              ++roomSortIt) {
                 if (roomIt->second == *roomSortIt) {
@@ -523,8 +527,11 @@ RoomList::firstRoom() const
                 auto item = qobject_cast<RoomInfoListItem *>(contentsLayout_->itemAt(i)->widget());
 
                 if (item) {
-                        return std::pair<QString, QSharedPointer<RoomInfoListItem>>(
-                          item->roomId(), rooms_.at(item->roomId()));
+                        auto topRoom = rooms_.find(item->roomId());
+                        if (topRoom != rooms_.end()) {
+                                return std::pair<QString, QSharedPointer<RoomInfoListItem>>(
+                                  item->roomId(), topRoom->second);
+                        }
                 }
         }
 
diff --git a/src/dialogs/InviteUsers.cpp b/src/dialogs/InviteUsers.cpp
index f85adb8ff7fa7437d8b05ea373433e3244b35f43..2de1d20ffa42d574c361865205d87d46883fbcf5 100644
--- a/src/dialogs/InviteUsers.cpp
+++ b/src/dialogs/InviteUsers.cpp
@@ -65,6 +65,10 @@ InviteUsers::InviteUsers(QWidget *parent)
 
         connect(inviteeInput_, &TextField::returnPressed, this, &InviteUsers::addUser);
         connect(confirmBtn_, &QPushButton::clicked, [this]() {
+                if (!inviteeInput_->text().isEmpty()) {
+                        addUser();
+                }
+
                 emit sendInvites(invitedUsers());
 
                 inviteeInput_->clear();