Misc fixes

* Use locally available copy of thd instead of current_thd
* Add data from different threads in different files