Misc minor build tweaks.

There's one real build-fix (at least on my system), and a bunch of stuff that needs review.

(See commit comments).