Only call proc if it is set

Fixes #30723.
Fixes #30724.
Fixes #30727.