Added some error checks
also changed the makefile and fixed names