Fixed pthread problems. It should work now.