Fix TEvent handling so it doesn't crash anymore.