Added necessary code for storing and retrieving Documents with References