Fix TSRM issues and add option not to track internal functions