Fix various build errors