cleanup for events

1) util.isObject -> Array.isArray;
2) remove unnecessary length var
3) util.isUndefined -> handler == null

On branch cleanup_events
Changes to be committed:
    modified:   lib/events.js