Move detection of number of event channels to global.h