More robust tail calls, add function names, add some test cases.