         var diff: [PiwigoAlbumData] = []
 
         // Look for categories which are not already displayed
-        for category in allCategories {
-
-            // Non-admin Community users can only upload in specific albums
-            if !Model.sharedInstance().hasAdminRights && !category.hasUploadRights {
-                continue
-            }
-
-            // Only add sub-categories of tapped category
-            if ((category.nearestUpperCategory != categoryTapped.albumId) ||
-                (category.albumId == currentCategory)) {
-                continue
-            }
-
+        /// - Non-admin Community users can only upload in specific albums
+        /// - Only add sub-categories of tapped category
+        /// - Do not add the current category
+        allCategories.filter({ Model.sharedInstance().hasAdminRights || $0.hasUploadRights })
+            .filter({ $0.nearestUpperCategory == categoryTapped.albumId })
+            .filter({ $0.albumId != currentCategory})
+            .forEach { category in
             // Is this category already in displayed list?
-            var doesNotExist = true
-            for existingCat in categories {
-
-                if category.albumId == existingCat.albumId {
-                    doesNotExist = false
-                    break
-                }
-            }
-            if doesNotExist {
+            if !categories.contains(where: { $0.albumId == category.albumId }) {
                 diff.append(category)
             }
         }
 
         // Build list of categories to be displayed
-        for category in diff {
-
+        diff.forEach { category in
             // Should we add sub-categories?
             if category.upperCategories.count > 0 {
                 var indexOfParent = 0
                 for existingCategory in categories {
-
                     if category.containsUpperCategory(existingCategory.albumId) {
                         categories.insert(category, at: indexOfParent + 1)
                         break

        var subcategories: [PiwigoAlbumData] = []

        // Look for known requested sub-categories
        for category in allCategories {

            // Only add sub-categories of tapped category
            if ((category.parentAlbumId != categoryTapped.albumId) ||
                (category.albumId == currentCategory)) {
                continue
            }
            subcategories.append(category)
        }

        // Look for sub-categories which are already displayed
        var nberDisplayedSubCategories = 0
        for category in subcategories {

            for existingCat in categories {

                if category.albumId == existingCat.albumId {
                    nberDisplayedSubCategories += 1
                    break
                }
            }
        }

        // This test depends on the caching option loadAllCategoryInfo:

        var diff: [PiwigoAlbumData] = []

        // Look for categories which are not already displayed
        /// - Smart albums should not be proposed
        /// - Non-admin Community users can only upload in specific albums
        allCategories.filter({ $0.albumId > kPiwigoSearchCategoryId })
            .filter({ Model.sharedInstance().hasAdminRights || $0.hasUploadRights })
            .forEach { category in
            // Is this category already in displayed list?
            if !categories.contains(where: { $0.albumId == category.albumId }) {
                diff.append(category)
            }
        }

        // Build list of categories to be displayed
        diff.forEach { category in
            if category.parentAlbumId == 0 {
                categories.append(category)
            }
        }

        // Add Community private categories
        for category in comCategories {
            // Is this category already in displayed list?
            if !categories.contains(where: { $0.albumId == category.albumId }) {
                categories.append(category)
            }
        }
