Fixed: in certain cases (replication), doc could be undefined resulting ...

...to a crash of the application