Fixed thread bug introduced during new coding.