Pion production in the Liège intranuclear cascade model (INCL4) for spallation reactions is revisited to alleviate the overestimate of the pion yield. Three modifications are proposed: a better pion-nucleon cross-section at high energy, the introduction of a pion average potential and the modification of the average mass of the Delta resonance. The pion potential is determined from a global fit. The resulting pion potential agrees with the phenomenological optical-model potentials. With these modifications, the predictions of the INCL4 model concerning pion production cross-sections in proton-induced reactions, pion-nucleus reaction and absorption cross-sections and proton, residue and fission cross-sections in pion-induced reactions are improved. Several results on pion production and the relative insentivity to the pion potential in the nuclear interior are shown to be consistent with the fact that most pions are not produced in early collisions. Importance of rescattering in pion absorption on nuclei is also pointed out. A comparison is made with the so-called Delta-hole model. Residual discrepancies are identified and are interpreted as due to the lack of pion interaction with two nucleons at low energy, to the neglect of quantum motion effects and to a possible underestimate of rescattering.