better handle embedded documents in plugin mode (fixes issue 2163)