Rebased: Handle invalid timing function params

Rebased version of #6757.

@redmunds