build issues

Fix several build issues. Please see individual commits.