Fixes a bug where an event handler is called when no targetObject exists