More robust event dispatch, remove unused imports.