TMP changes and bugfixes