Use weak pointers for document and controller references to prevent cyclic dependencies