Change process function to return multiple values and then calculate
final statistical values for plots.