Add support for event archives and remove direct usage of global variables.