Added defaults for optimization and attachments.
Extracted basic message logic into a helper.