Add constants.
Refactor savin of attachments
Fix loading of attachments.