Fixed a race condition when the main context gets created before the parent context is set-up.
The symptom was a Core Data exception saying that it couldn't find certain entity types when the document is opened.