Fix for CPU usage from thread spinning out of control