Fixed bug with thread init