Makefile redesign. Some other small fixes