Fixing bug with sum and weights.