added more careful flags to makefile and fixed code