Fixes #205 Performance issue when an entity has a lot of attachments