Makefile

Makefile fixes, split off from pull request 738