work with signals only in main thread
destroy contexts in safe manner
simplify stats logic