       console.log("FILTER BOX CLICKED", $scope.selectedFilter)
       if $scope.selectedType.join(" ").includes($scope.volumeDisplayStr)
         if $scope.selectSessionStr in $scope.selectedFilter
-          $scope.filterBySession()
+          filterBySession()
         if $scope.selectHighlightStr in $scope.selectedFilter
-          $scope.filterByHighlight()
+          filterByHighlight()
       if $scope.selectedType.join(" ").includes($scope.partyDisplayStr)
         # $scope.partyFilterBoxClick()
-        $scope.filterParties($scope.selectedFilter)
+        filterParties($scope.selectedFilter)
         console.log("FILTERING BY PARTY")
       $scope.offset = 0 # Reset the offset
-      $scope.search()
-
-    $scope.addArgToQuery = (query, arg, val) ->
+      search()
+
+    addArgToQuery = (query, arg, val) ->
       return query + "|arg=" + arg + ":\"" + val + "\""
 
 
     $scope.partyFilterBoxClick = ->
-      $scope.filterByAffiliation()
-
-    $scope.filterByAffiliation = ->
+      filterByAffiliation()
+
+    filterByAffiliation = ->
       $scope.query = $scope.originalQuery + "|arg=party_affiliation_s:\"" + $scope.selectedFilter + "\""
 
-      # funcs = {"session" : filterBySession, "highlight" : $scope.filterByHighlight}
+      # funcs = {"session" : filterBySession, "highlight" : filterByHighlight}
 
     # Now we want to rerun the search but only return vols w/ highlights
-    $scope.filterByHighlight = ->
+    filterByHighlight = ->
       $scope.requireHighlight = true
       $scope.query = $scope.originalQuery + "|arg=volume_has_excerpt_b:true"
 
-    $scope.filterBySession = ->
+    filterBySession = ->
       $scope.requireSession = true
       $scope.query = $scope.originalQuery + "|arg=volume_has_sessions_b:true"
 
-    $scope.filterParties = (filterName) ->
+    filterParties = (filterName) ->
       console.log("Filtering parties by", filterName)
       if filterName.join(" ").includes("All")
         # Select all parties
         $scope.query = $scope.originalQuery # TODO should this do something else?
       else if filterName.join(" ").includes("Institution")
         # Select institutions
-        $scope.query = $scope.addArgToQuery($scope.originalQuery, "party_is_institution_b", "true")
+        $scope.query = addArgToQuery($scope.originalQuery, "party_is_institution_b", "true")
       else if filterName.join(" ").includes("Authorized")
         # Select authorized users only
-        $scope.query = $scope.addArgToQuery($scope.originalQuery, "party_is_authorized_b", "true")
+        $scope.query = addArgToQuery($scope.originalQuery, "party_is_authorized_b", "true")
       console.log("Query after filter", $scope.query)
 
 

      $scope.query = $scope.originalQuery
      $scope.offset = 0
      console.log("NEW SEARCH:", $scope.query)
      $scope.search()

    # Put an ng-key enter here so it does what we offset
    $scope.search = (query = "") ->
      # This is for if we want to pass an argument into this...
      if query.length > 0
        $scope.query = query

    $scope.partyDisplayStr = "People"
    $scope.partyLinkPrefix = "party/"
    $scope.volumeLinkPrefix = "volume/"

    # Holds the current text of the search box
    $scope.searchBoxQuery = ""

    # List of affiliations (currently unused)
    $scope.affiliations = []

    # Number of results of each facet to return.
    # Currently hardcoded to 10.
    $scope.limit = 10
    display.title = 'Search'

    # Name of the currently selected filter.
    currentFilter = ""


  ###########################
  # Functions for transforming a document into strings
  ###########################

    # Def formPartyLink:
    # Given a party document, returns a hyperlink.
    formPartyLink = (doc) ->
      return partyLinkPrefix + doc.party_id_i

    # Def formVolumeLink:
    # Function that, given a volume document, returns a hyperlink.
    formVolumeLink = (doc) ->
      return volumeLinkPrefix + doc.volume_id_i

    # Def formVolumeResult:
    # This is a helper function that concats parts of a volume into a string.
    $scope.formVolumeResult = (doc) ->
      # Form everything except the title, which we'll do in HTML so we can make it the link
      res = []
