Fixing thread problem.