use lunr instead of fuse, remember if switched to modules
diff --git a/scripts/assignments.js b/scripts/assignments.js
index 9421f3f..8ede752 100644
--- a/scripts/assignments.js
+++ b/scripts/assignments.js
@@ -526,6 +526,9 @@
     $("#dtpsTabBar .btn").removeClass("active");
     $("#dtpsTabBar .btn.stream").addClass("active");
 
+    //Save coursework stream preference
+    window.localStorage.setItem("courseworkPref-" + classID, "stream");
+
     //Load class color, name, etc.
     dtps.presentClass(classNum);
 
@@ -830,6 +833,9 @@
     $("#dtpsTabBar .btn").removeClass("active");
     $("#dtpsTabBar .btn.stream").addClass("active");
 
+    //Save coursework stream preference
+    window.localStorage.setItem("courseworkPref-" + classID, "moduleStream");
+
     //Load class color, name, etc.
     dtps.presentClass(classNum);
 
diff --git a/scripts/core.js b/scripts/core.js
index 28f0d14..77f9ac0 100644
--- a/scripts/core.js
+++ b/scripts/core.js
@@ -239,19 +239,19 @@
         jQuery.getScript("https://cdn.jsdelivr.net/npm/[email protected]/locales-all.min.js");
     });
 
-    //Fuse.js is used for search
-    jQuery.getScript('https://cdn.jsdelivr.net/npm/[email protected]');
+    //Lunr is used for search
+    jQuery.getScript('https://unpkg.com/lunr/lunr.js');
 
     //jQuery UI for dashboard settings page
     jQuery.getScript('https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js');
 
-    //Tinycolor used for Fluid UI acrylic & color manipulation
-    jQuery.getScript("https://cdn.jottocraft.com/tinycolor.js", () => {
-        //dtao/nearest-color is used for finding the nearest class color
-        jQuery.getScript("https://cdn.jottocraft.com/nearest-color.dtao.js", () => {
-            //Fluid UI for core UI elements
-            jQuery.getScript('https://cdn.jottocraft.com/fluid/v5.min.js', cb);
-        })
+    //Tinycolor used for better dark mode support
+    jQuery.getScript("https://cdn.jottocraft.com/tinycolor.js");
+
+    //dtao/nearest-color is used for finding the nearest class color
+    jQuery.getScript("https://cdn.jottocraft.com/nearest-color.dtao.js", () => {
+        //Fluid UI for core UI elements
+        jQuery.getScript('https://cdn.jottocraft.com/fluid/v5.min.js', cb);
     });
 }
 
@@ -792,12 +792,8 @@
         //Class onclick listener
         $(".class:not(.overrideClass)").click(function (event) {
             //Load class content based on what's selected
-            if ((dtps.selectedContent == "stream") && dtps.classes[dtps.selectedClass]) {
-                fluid.screen("stream", dtps.classes[dtps.selectedClass].id);
-            }
-
-            if ((dtps.selectedContent == "moduleStream") && dtps.classes[dtps.selectedClass]) {
-                if (dtps.classes[dtps.selectedClass].modules) {
+            if (((dtps.selectedContent == "stream") || (dtps.selectedContent == "moduleStream")) && dtps.classes[dtps.selectedClass]) {
+                if (dtps.classes[dtps.selectedClass].modules && (window.localStorage.getItem("courseworkPref-" + dtps.classes[dtps.selectedClass].id) == "moduleStream")) {
                     fluid.screen("moduleStream", dtps.classes[dtps.selectedClass].id);
                 } else {
                     fluid.screen("stream", dtps.classes[dtps.selectedClass].id);
@@ -878,7 +874,7 @@
     $(".headerArea .dashboardStartDate").hide();
 
     //Clear search box if not on the search tab
-    if (classNum !== "search") {
+    if ((classNum !== "search") && !$("#dtpsMainSearchBox").is(":focus")) {
         $("#dtpsMainSearchBox").val("");
     }
 
@@ -1389,11 +1385,11 @@
                 <p>By defualt, Power+ will search based on the page you're on. You can use the keywords below for more advanced searches:</p>
                 <div class="grid samesize">
                     <div class="item">
+                        <p><i class="material-icons">library_books</i> type:coursework</p>
                         <p><i class="material-icons">view_module</i> type:module</p>
                         <p><i class="material-icons">assignment</i> type:assignment</p>
-                        <p><i class="material-icons">remove_circle_outline</i> type:missing</p>
-                        <p><i class="material-icons">assignment_turned_in</i> type:turnedin</p>
                         <p><i class="material-icons">assessment</i> type:grade</p>
+                        <p><i class="material-icons">announcement</i> type:announcement</p>
                     </div>
                     <div class="item">
                         <p><i class="material-icons">home</i> type:homepage</p>
@@ -1515,12 +1511,11 @@
     var error = false;
 
     //Get automatic type from selected content
-    if ((dtps.selectedContent == "stream") || (dtps.selectedContent == "moduleStream")) type = "coursework";
+    if ((dtps.selectedClass == "dash") || (dtps.selectedContent == "stream") || (dtps.selectedContent == "moduleStream")) type = "coursework";
     if (dtps.selectedContent == "people") type = "people";
     if (dtps.selectedContent == "discuss") type = "discussions";
     if (dtps.selectedContent == "pages") type = "pages";
     if (dtps.selectedContent == "grades") type = "grades";
-    if (dtps.selectedClass == "dash") type = "assignments";
 
     //If search is open, reuse existing context
     if (dtps.selectedClass == "search") {
@@ -1533,15 +1528,15 @@
     }
 
     //Check for type override from search box
-    if (value.split(" ").includes("type:assignment")) type = "assignments";
-    if (value.split(" ").includes("type:missing")) type = "missing assignments";
-    if (value.split(" ").includes("type:turnedin")) type = "turned in assignments";
-    if (value.split(" ").includes("type:module")) type = "modules";
+    if (value.split(" ").includes("type:coursework")) type = "coursework";
     if (value.split(" ").includes("type:homepage")) type = "homepages";
     if (value.split(" ").includes("type:page")) type = "pages";
     if (value.split(" ").includes("type:discussion")) type = "discussions";
     if (value.split(" ").includes("type:grade")) type = "grades";
     if (value.split(" ").includes("type:person")) type = "people";
+    if (value.split(" ").includes("type:assignment")) type = "assignments";
+    if (value.split(" ").includes("type:module")) type = "modules";
+    if (value.split(" ").includes("type:announcement")) type = "announcements";
     if (value.split(" ").includes("type:all")) type = "everything";
 
     //Get icon from final type
@@ -1551,10 +1546,9 @@
     if (type == "pages") icon = "insert_drive_file";
     if (type == "grades") icon = "assessment";
     if (type == "assignments") icon = "assignment";
-    if (type == "missing assignments") icon = "remove_circle_outline";
-    if (type == "turned in assignments") icon = "assignment_turned_in";
     if (type == "modules") icon = "view_module";
     if (type == "homepages") icon = "home";
+    if (type == "announcements") icon = "announcement";
     if (type == "everything") icon = "warning";
 
     //Check for course override from search box
diff --git a/scripts/search.js b/scripts/search.js
index c36a092..3c5abb5 100644
--- a/scripts/search.js
+++ b/scripts/search.js
@@ -50,19 +50,10 @@
     var datasetPromises = [];
 
     (courseNum == "all" ? dtps.classes : [dtps.classes[Number(courseNum)]]).forEach(course => {
-        if (type.includes("assignments") || (type == "coursework") || (type == "everything")) {
+        if ((type == "assignments") || (type == "coursework") || (type == "everything")) {
             datasetPromises.push(new Promise((resolve, reject) => {
                 if (!course.assignments) return resolve([]);
-                var res = [];
-                if (type == "missing assignments") {
-                    res = course.assignments.filter(assignment => assignment.missing);
-                } else if (type == "turned in assignments") {
-                    res = course.assignments.filter(assignment => assignment.turnedIn);
-                } else {
-                    res = course.assignments;
-                }
-
-                resolve(res.map(assignment => ({
+                resolve(course.assignments.map(assignment => ({
                     title: assignment.title,
                     class: course.num,
                     body: $('<div>' + assignment.body + '</div>').text(),
@@ -148,7 +139,9 @@
                         class: course.num,
                         locatedIn: course.subject,
                         icon: "home",
-                        body: $('<div>' + data + '</div>').text()
+                        body: $('<div>' + data + '</div>').text(),
+                        info: [],
+                        icons: []
                     }]);
                 }).catch(() => resolve([]));
             }));
@@ -250,42 +243,28 @@
             dataset = dataset.concat(result);
         });
 
-        var search = new Fuse(dataset, {
-            keys: [{
-                name: "title",
-                weight: 1
-            },
-            {
-                name: "body",
-                weight: 0.8
-            },
-            {
-                name: "locatedIn",
-                weight: 0.7
-            },
-            {
-                name: "info.info",
-                weight: 0.6
-            },
-            {
-                name: "icons.keywords",
-                weight: 0.4
-            }],
-            includeMatches: true,
-            ignoreLocation: true,
-            //threshold: 0
+        var idx = lunr(function () {
+            this.ref('id');
+            this.field('title');
+            this.field('body');
+            this.field('locatedIn');
+            this.field('info.info');
+            this.field('icons.keywords');
+            this.metadataWhitelist = ['position'];
+
+            dataset.forEach(function (doc, i) {
+                this.add({
+                    id: i,
+                    ...doc
+                });
+            }, this)
         });
 
-        if (term) {
-            var result = search.search(term);
-            if (result.length > 10) result.length = 10;
-        } else {
-            var result = dataset.map(item => ({ item: item, matches: [] }));
-        }
+        var result = idx.search(term);
 
         console.log(dataset, term, result);
 
-        $(".classContent").html(result.map(res => dtps.renderSearchResult(res.item, res.matches, courseNum == "all")));
+        $(".classContent").html(result.map(res => dtps.renderSearchResult(dataset[Number(res.ref)], res.matchData.metadata, courseNum == "all")));
     });
 }
 
@@ -293,22 +272,35 @@
  * Renders a Search data object into HTML for display in the search results list
  * 
  * @param {SearchData} result The search result to render
- * @param {Object[]} matches The list of matches from Fuse.js
+ * @param {Object[]} matchData The list of matches from Lunr
  * @param {boolean} [mixedClasses] True if there are results from multiple classes
  * @return {string} The HTML for this result in the results list
  */
-dtps.renderSearchResult = function (result, matches, mixedClasses) {
-    //A function that highlights a string between the specified indicies
-    function highlightString(string, indicies) {
+dtps.renderSearchResult = function (result, matchData, mixedClasses) {
+    var matches = {};
+    var matchTerms = Object.values(matchData);
+    matchTerms.forEach(term => {
+        Object.keys(term).forEach(k => {
+            if (matches[k]) {
+                matches[k] = matches[k].concat(term[k].position);
+            } else {
+                matches[k] = term[k].position;
+            }
+        });
+    });
+    matches = Object.keys(matches).map(k => ({ key: k, position: matches[k] }));
+
+    //A function that highlights a string
+    function highlightString(string, position) {
         var parts = string.split("");
-        indicies.forEach(ind => {
+        position.forEach(pos => {
             //highlight part
             parts.forEach((part, i) => {
-                if (i == ind[0]) {
+                if (i == pos[0]) {
                     parts[i] = '<span class="highlight">' + parts[i];
                 }
 
-                if (i == ind[1]) {
+                if (i == (pos[0] + pos[1] - 1)) {
                     parts[i] = parts[i] + '</span>';
                 }
             });
@@ -323,30 +315,32 @@
     var highlightedIcons = [];
     matches.forEach(match => {
         if (match.key == "title") {
-            result.title = highlightString(result.title, match.indices);
+            result.title = highlightString(result.title, match.position);
         } else if (match.key == "locatedIn") {
-            result.locatedIn = highlightString(result.locatedIn, match.indices);
+            result.locatedIn = highlightString(result.locatedIn, match.position);
         } else if (match.key == "body") {
             //Get longest 2 matches
-            var sections = match.indices.sort((a, b) => (b[1] - b[0]) - (a[1] - a[0]));
+            var sections = match.position.sort((a, b) => b[1] - a[1]);
             var matchesToDisplay = 2;
             if (sections.length < matchesToDisplay) matchesToDisplay = sections.length;
             bodyOverflow = sections.length - matchesToDisplay;
 
             for (var i = 0; i < matchesToDisplay; i++) {
-                var startIndex = sections[i][0] - 10;
-                var endIndex = sections[i][1] + 10;
+                var matchStartIndex = sections[i][0];
+                var matchEndIndex = sections[i][0] + sections[i][1] - 1;
+
+                var startIndex = matchStartIndex - 10;
+                var endIndex = matchEndIndex + 10;
 
                 if (startIndex < 0) startIndex = 0;
                 if (endIndex > (result.body.length - 1)) endIndex = result.body.length - 1;
 
-                var res = result.body.slice(startIndex, sections[i][0]) + '<span class="highlight">' + result.body.slice(sections[i][0], sections[i][1] + 1) + '</span>' + result.body.slice(sections[i][1] + 1, endIndex + 1);
+                var res = result.body.slice(startIndex, matchStartIndex) + '<span class="highlight">' + result.body.slice(matchStartIndex, matchEndIndex + 1) + '</span>' + result.body.slice(matchEndIndex + 1, endIndex + 1);
                 bodyParts.push(res);
             }
         } else if (match.key == "info.info") {
-            result.info[match.refIndex].info = highlightString(result.info[match.refIndex].info, match.indices);
-        } else if (match.key == "icons.keywords") {
-            highlightedIcons.push(match.refIndex);
+            return;
+            result.info[match.refIndex].info = highlightString(result.info[match.refIndex].info, match.position[0], match.position[1]);
         }
     });
 
@@ -375,11 +369,7 @@
             ${bodyOverflow ? `<p style="color: var(--secText);">+${bodyOverflow} more matches</p>` : ""}
 
             <h5>
-                ${result.icons.map((icon, i) => (
-                    highlightedIcons.includes(i) ? 
-                    `<span class="highlight"><i class="material-icons statusIcon">${icon.icon}</i></span>`
-                    : `<i class="material-icons statusIcon">${icon.icon}</i>`
-    )).join("")}
+                ${result.icons.map((icon, i) => (`<i class="material-icons statusIcon">${icon.icon}</i>`)).join("")}
             </h5>
         </div>
     `;