I think that these questions should be addresses already on the mixing stage. As far as I know, "unnecessary frequencies" are frequencies that a) are outside of the 20 Hz - 20 kHz human hearing range, b) are irrelevant to the sound in question, like for example low end for hi hats, c) don't contribute to the character of the sound, like a low mid-range for the majority of kick drums, where the "muddiness" is, and d) are masked by the equivalent frequencies of another sound you're mixing it with, therefore becoming inaudible. You can completely eliminate or attenuate those frequency ranges to achieve a cleaner mix. I'd say that "painful" or irritating frequencies are those we humans are most sensitive to (in other words, able to discern at lowest volumes, according to the equal-loudness contours). Normally it's everything between 2 kHz and 5 kHz. If you overdo those, your track will sound painful. You can also make things uncomfortable if you boost the main frequency of a given sound too much, like for example 8-12 kHz for hi hats. I hope this helps.
Do you have any specific questions about mastering?