fix problem with dispatching events after shutdown
fix circular dependency