Haddock support improvements

Various improvements or simplifications to the haddock support.  The ultimate aim of the branch is to fix #1808.