Fixed thread part of perf. Needs clean up