added some threading and event debugging