Makefile fixes

A bunch of build fixes.