Updates for terminating threads in tracker_heartbeat.py
I have no idea what these problems are.
A bunch of changes to try and fix bugs.
Pulled in latest merge.