TDT main program and supporting scripts