unify the stdio handling
unify the naming of vaiouse output files, using more macros