fix attachments store; code refactoring after previous merge