Improved notification generation logic.