Bug with thread creation fixed