avoid duplication of input dirs, plus some cleaning