How to regularize the infrared and mass singularities in QCD