Fix Makefile, functions and links