More error handling fixes, Makefile improvements