Add nested counts and all counts for submissions. Fix #979. Fix #972.