Fix excpetions if pipe dies unexpectedly. Add debug mode to Makefile