Fixed bug in determining whihc function definition should be used to
replace a function.