Check fuel pressure. I dont know what the exact numbers are, but test while revving high and low to make sure things stay consistant. I read that you can tell when a pump is going bad when you start getting detonation when you are running that motor high and hot, but great everywhere else.
4.0's are notorious for detonating, and ironically the detonation associated with the 4.0's is generally mild and almost taken for harmless. Although playing with mine as much as i have, the detonation CAN be overcome and completely cured, it just takes patience, a lot of money, and a good sense of where to look. Check your plugs, are they whitish? you are running lean. Cleaning MAF might work, if not, you need to look into fuel pressure.
If the fuel pressure is good (i think its like 30lbs at idle, 45lbs at like WOT), then vacume leaks are your next best bet. If that STILL doesnt fix the issue, its time to take the motor apart from the heads up start cleaning out that carbon.