fixes concurrent event handling and resource releasing