Fixed problem when two same functions are fitted with Lorenzo's patch