Fixed threading issues.