Added tail-call optimization.