Remove infinite loop when calculating functions in lazy mode.