First attempt at optimizing tail calls.