[Fix] Some behaviours in numerical derivative and line search.

They caused endless loop.