Add check for existence of function, before trying to call it.

Also, a little change in semantics--should help future extensibility.