Fixed parent loading problem in prepareDocument