ModelCache: Exception "Event outside of a command" from EventsCollector during generation