Stein factorization

In algebraic geometry, the Stein factorization, introduced by for the case of complex spaces, states that a proper morphism can be factorized as a composition of a finite mapping and a proper morphism with connected fibers. Roughly speaking, Stein factorization contracts the connected components of the fibers of a mapping to points.

Statement
One version for schemes states the following: Let X be a scheme, S a locally noetherian scheme and $$f: X \to S$$ a proper morphism. Then one can write
 * $$f = g \circ f'$$

where $$g\colon S' \to S$$ is a finite morphism and $$f'\colon X \to S'$$ is a proper morphism so that $$f'_* \mathcal{O}_X = \mathcal{O}_{S'}.$$

The existence of this decomposition itself is not difficult. See below. But, by Zariski's connectedness theorem, the last part in the above says that the fiber $$f'^{-1}(s)$$ is connected for any $$s \in S'$$. It follows:

Corollary: For any $$s \in S$$, the set of connected components of the fiber $$f^{-1}(s)$$ is in bijection with the set of points in the fiber $$g^{-1}(s)$$.

Proof
Set:
 * $$S' = \operatorname{Spec}_S f_* \mathcal{O}_X$$

where SpecS is the relative Spec. The construction gives the natural map $$g\colon S' \to S$$, which is finite since $$\mathcal{O}_X$$ is coherent and f is proper. The morphism f factors through g and one gets $$f'\colon X \to S'$$, which is proper. By construction, $$f'_* \mathcal{O}_X = \mathcal{O}_{S'}$$. One then uses the theorem on formal functions to show that the last equality implies $$f'$$ has connected fibers. (This part is sometimes referred to as Zariski's connectedness theorem.)