Pepe's death could have been caused by many things. Internal organ failure doesn't just happen as a result of malnutrition. We can even reverse this statement, to say that, malnutrition is a side effect of organ failure. The thing is not to dwell on his death, or rather the cause. I think we are all in agreeance that as you have kept him well for over a decade (and judging by the photo, in top shape as well), you havn't made any stupid mistakes.
Looking into the future, is where we can be sure to get things right. And as already said, diet is key factor,
along with the environment you keep your birds.
My personnel recommendation would be to keep away from the pelleted foods. In the wild a parrots life is dominated by the search for food, and as a result they have quite an appetite for flavour and variety.
To deny this natural stimulant in an already truncated lifestyle, is just wrong.
In this day of parot keeping, we are very fortunate to have science on our side, and there are some extremely good additives on the market. (EasyBird, BreedMax etc...) which can be added (simply sprinkled over fresh fruit/veg or mixed in with egg food) which help your birds absorb and mobilse all the goodness out of their food - providing the goodness is on what you feed them. Which brings up onto more than just Tidymix (which does come highly recommended). Feed pulses which have been soaked and sprouted (the more variety the better) and the same with seed, white sunflower, wheat etc.. all of which can be sprouted increasing the nutrient content.
Don't forget natural light as well. Particularly as your bird is kept indoors. How often does he get a trip out side, or do you have a natural spectrum bulb near his cage.
I hope you search for a new bird goes well.
If God had intended man to fly, He would have given us wings. Instead He gave us Parrots.