Makefile improvements

Added `-lpthread` flag and some Makefile improvements