Small build fixes

So here is the next round of small build system fixes, to be applied before I submit the more substantial set of changes. This was freshly rebased on top of the master-test branch.