added stats and ability to set logging flags for each thread