Updated head_tracker.py script to be thread safe