Fixing some timing issues with the threads