Makefile improvements

See commit messages. Fixes compilation with multiple jobs. Like issue #17 says, there's a lot to improve here, but this is a start.