Fixed attachments, added transient handling to all SQL calls