fixes #272: Redesign cortex publish and avoid to update attachments seperately.