Makefile now generates dependencies and uses smarter rules

to recompile less things.
Also fixed some header file names.