improved Makefile and script for stdout and stderr