threads: set up Thread to be freed properly