Patch to move the recursive call outside of the lock block.