Makefile fixes

Various fixes and enhancements to the Makefile. It should be obvious what most of these do.

You might not want 695b112. I think the change makes sense, but I don't know if using global installs of node.js dependencies is something you want to have easy support for.