overhaul of threading/event handling