Fixed Some Threading Issues