Avoideded flushing the console output from inside a thread, which caused a crash

The problem could be due to the use of global variables randomly uninitialized.