additional logging, multithreading protection, cleanup