Reorganized the zonal averaging code. More flexible now.