Improved tracing. Added fflush