Just so you know, Function2 is NOT an iTVF (Inline Table Valued Function). Rather, it's an mTFV (Multiline Table Valued Function) and those can be as bad or worse than a Scalar Function. I can't tell because you didn't list the final modified code for function 2 but if it still contains the table definition and the BEGIN/END, then it's still an mTVF and will still perform poorly as before.
--Jeff Moden
Change is inevitable... Change for the better is not.