Correct bugs in new tps output format
Clean comments in main script.