add managed document.
correct compiling error
fix core data crash problem.