A popular self-enrichment scenario for the formation of globular clusters assumes that the abundance anomalies seen in the stars in many clusters are due to a second stage of star formation occurring from the matter lost by the winds of massive asymptotic giant branch (AGB) stars. Until today, the modelings of the AGB evolution by several different groups has failed, for different reasons, to account for the patterns of chemical anomalies. Here we show that our own modeling can provide a consistent picture if we constrain the three main parameters that regulate AGB evolution, by (1) adopting a high efficiency convection model, (2) adopting rates of mass loss with a high dependence on the stellar luminosity, and (3) assuming a very small overshooting below the formal convective regions during the thermal pulse (TP) phase. The first assumption is needed to obtain an efficient oxygen depletion in the AGB envelopes, and the second is needed to lose the whole stellar envelope within few thermal pulses, so that the sum of CNO elements does not increase too much, consistent with observations. The third assumption is needed to fully understand the sodium production. We also show that the Mg-Al anticorrelation can be explained by adopting the higher limit of the NACRE rates for proton captures by 25Mg and 26Mg; the models are consistent with the recently discovered F-Al correlation. Problems remain in fully explaining the observed Mg isotope ratios.