Improved comments handler to fix possible Denial of Service vulnerability