only calculate sums if needed
segfault, resizing may move the buffer