Added capability for tail recursion.