Fixing logic to avoid incorrect notifications on off-chance script restart.