Refactored the automatic mailer.