registerEvent optimizations

Use static_cast instead of dynamic_cast to omit run-time checks