Updated some implementation and error handling by threads