Fixed Threading.

Rewrote threading so it should work properly.