Simplify array iterations and event adding.