Rework stack overflow handling.