Fixed a bug where events are propagated to document from $events