Bug fix for IO in case of BOTH mode + support output TDirectory structure --kazu