now the average population is calculated correctly.
the buffer for tmpvars is freed.