cleaned up event flattening