Updated TDM and done lots of bugfixes