Added allocation error check, updated Makefile