Cocenters of p-adic Groups, III: Elliptic and Rigid Cocenters