minor changes to tally() for margins