cleanup for async thread code; introduced lock