Better way to calculate sum column. Fixes #310.