Better output directory handling