Fix import races in client. Refactor event handling to be a lot more closure friendly and a little less awkward