Fix an edge case and simplify total sum updates