fix event dispatch and delegation