Revert commits that caused a stack overflow on Mac

See #6061. Reverting these commits fixes it; later we'll isolate the problem.