Fixes #1858, also for maps and documents