Ported the Attachment class.

The attachment class was brought over with a combination of
hand-written code plus sharpened code (some of which was
refactored). There was significant dependent code that came
with, and all of it was either brought in or stubbed out.