 
 routes.config ['$stateProvider', '$urlRouterProvider', '$locationProvider',
   ($stateProvider, $urlRouterProvider, $locationProvider) ->
-    # Make a subject from the route parameters. If there is not
-    # a detail parameter, then fetch the subject.
+    # Make a subject from the given route parameters. If there
+    # is not a detail parameter, then fetch the subject from the
+    # Subject resource.
     #
+    # @param project the project
+    # @param params the URL parameters 
     # @param resource the Subject resource
-    # @param params the URL parameters
     # @returns the subject
-    getSubject = (resource, params) ->
+    getSubject = (project, params, resource) ->
       sbj =
-        project: params.project or 'QIN'
+        project: project
         collection: _.str.capitalize(params.collection)
         number: parseInt(params.subject)
       if params.detail

      # The home landing page.
      .state 'quip.home',
        url: ''
        views:
          'main@':
            templateUrl: '/partials/subject-list.html'

      else
        resource.get(sbj).$promise
    
    # @param subject the parent object
    # @param Subject the Subject Resource
    # @returns the detail object
    getSubjectDetail = (subject, Subject) ->
      if subject.detail
        Subject.detail(id: subject.detail).$promise
      else
        Subject.get(subject).$promise.then (fetched) ->
          # If the fetched subject has no detail, then complain.
          if not fetched.detail
            throw "Subject does not have detail: #{ subject.number }"
          getSubjectDetail(fetched, Subject)
    
    # @param session the parent object
    # @param Session the Session Resource
    # @returns the detail object
    getSessionDetail = (session, Session, Subject) ->
      if session.detail
        Session.detail(id: session.detail).$promise
      else
        getSubjectDetail(session.subject, Subject).then (detail) ->
          # Find the session in the session list.
          sbj_session = _.find detail.sessions, (other) ->
            other.number == session.number
          # If the session was not found, then complain.
          if not sbj_session
            throw "Subject #{ subject.number } does not have a session #{ session.number }"
          # Recurse.
          session.detail = sbj_session.detail_id
          getSessionDetail(session, Session, Subject)
        
    $stateProvider
      # The top-level state. This abstract state is the ancestor
      # of all other states. It holds the url prefix. There are
      # two ui-views in the index.html file, main and goHome. This
      # top-level state formats the goHome navigation button. The
      # main ui-view is formatted by child states. Since the main
      # ui-view is in the root context, it is referenced by the
