         abstract: true
         url: '/:collection/subject/{subject:[0-9]+}'
         resolve:
-          subject: ['$stateParams', 'Subject',
-            ($stateParams, Subject) ->
-              getSubject($stateParams, Subject)
-          ]
+          subject: (project, $stateParams, Subject) ->
+            getSubject(project, $stateParams, Subject)
       
       # The subject detail page.
       .state 'quip.subject.detail',
         url: '?detail'
         resolve:
-          detail: ['Subject', 'subject',
-            (Subject, subject) ->
-              Subject.detail(id: subject.detail)
-          ]
+          detail: (subject, Subject) ->
+            getSubjectDetail(subject, Subject)
         views:
           'main@':
             templateUrl: '/partials/subject-detail.html'

      .state 'quip.subject.session',
        abstract: true
        url: '/session/{session:[0-9]+}'
        # TODO - enable
        # resolve:
        #   session: ['$stateParams', 'subject', 'Session',
        #     ($stateParams, subject, Session) ->
        #       getSession($stateParams, subject, Session)
        #   ]
      
      # The session detail page.
      .state 'quip.subject.session.detail',
        url: '?detail'
        # TODO - enable
        # resolve:
        #   detail: ['$stateParams', 'Session', 'session',
        #     ($stateParams, Session, session) ->
        #       detail_id = $stateParams.detail or ssession.detail
        #       Session.detail(id: $stateParams.detail)
        #   ]
        views:
          'main@':
            templateUrl: '/partials/session-detail.html'
            controller:  'SessionDetailCtrl'
        reloadOnSearch: false
     
      # The series image page.
      .state 'quip.subject.session.series',
        url: '/:image_container/series/{series:[0-9]+}'
        views:
          'main@':
            templateUrl: '/partials/series-detail.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
