Added state machine, created mailer