Fix a number of issues in the doc build

Incorporates #2031.