Make sure library functions are tail-recursive where possible.