better use of DIRNAME + fixes