Added makefile.
Added error checking.