Fixed initialization order fiasco
Added needed pthread for linux build