Updated Makefile and source files with better code