         if computedScore
           overall = 0
           for field of computedScore.value
-            if field != 'popularity'
-              team.scores[ field ] = computedScore.value[ field ]
+            team.scores[ field ] = computedScore.value[ field ]
+            if field != 'contestant_count' and field != 'judge_count' and field != 'popularity_count'
               overall += computedScore.value[ field ]
-          if maxPopularity == 0
+          if max_popularity_count == 0
             team.scores.popularity = 0
           else
-            team.scores.popularity = computedScore.value.popularity / maxPopularity * 10
+            team.scores.popularity = computedScore.value.popularity_count / max_popularity_count * 10
           overall += team.scores.popularity
           team.scores.overall = overall
         else

    contestant_design: Number
    contestant_innovation: Number
    contestant_completeness: Number
    judge_utility: Number
    judge_design: Number
    judge_innovation: Number
    judge_completeness: Number
    popularity: Number
    overall: Number
TeamSchema.plugin require('mongoose-types').useTimestamps
TeamSchema.index updatedAt: -1

TeamSchema.static 'updateAllSavedScores', (next) ->
  map = ->
    ret =
      contestant_utility: 0
      contestant_design: 0
      contestant_innovation: 0
      contestant_completeness: 0
      contestant_count: 0
      judge_utility: 0
      judge_design: 0
      judge_innovation: 0
      judge_completeness: 0
      judge_count: 0
      popularity_count: 0
    if this.type == 'contestant' or this.type == 'judge'
      ret[this.type + '_utility'] = this.utility
      ret[this.type + '_design'] = this.design
      ret[this.type + '_innovation'] = this.innovation
      ret[this.type + '_completeness'] = this.completeness
      ret[this.type + '_count'] = 1
    else if this.type == 'voter'
      ret.popularity_count = 1
    emit this.teamId, ret

  reduce = (key,vals) ->
    ret = vals.shift()
    vals.forEach (val) ->
      for field of ret
        ret[ field ] += val[ field ]
    ret
    
  finalize = (key,val) ->
    ret = {}
    [ 'contestant_utility', 'contestant_design', 'contestant_innovation', 'contestant_completeness' ].forEach (field) ->
      if val.contestant_count != 0
        ret[ field ] = val[ field ] / val.contestant_count
      else
        ret[ field ] = 0
    ret[ 'contestant_count' ] = val.contestant_count
    [ 'judge_utility', 'judge_design', 'judge_innovation', 'judge_completeness' ].forEach (field) ->
      if val.judge_count != 0
        ret[ field ] = val[ field ] / val.judge_count
      else
        ret[ field ] = 0
    ret[ 'judge_count' ] = val.judge_count
    ret[ 'popularity_count' ] = val.popularity_count
    ret
             
  mrCommand =
