Fix bug and attachment creation