clean up TH code