DRY up the code some.
Merge branch 'master' into attachments