Reorganized event engine code.