Documentation improvements. Fixes #2004, #2115, #2171.