fix segfault with optimized code; initialize TSRM stuff