Fixed flush code so that flush will not send empty emails