Fix document validation and orphaned data

https://trello.com/c/Wtr6uYiX/86-bug-investigate-why-it-was-not-possible-to-publish-a-cma-case