I am reading Milne, Algebraic Number Theory, and I came across with the following interesting example:
EXAMPLE 3.40 (For experts on Riemann surfaces.) Let $X$ and $Y$ be compact connected Riemann surfaces, and let $\alpha: Y \rightarrow X$ be a nonconstant holomorphic mapping. Write $\mathcal{M}(X)$ and $\mathcal{M}(Y)$ for the fields of meromorphic functions on $X$ and $Y$. The map $f \mapsto f \circ \alpha$ is an inclusion $\mathcal{M}(X) \hookrightarrow \mathcal{M}(Y)$ which makes $\mathcal{M}(Y)$ into a field of finite degree over $\mathcal{M}(X)$; let $m$ be this degree. Geometrically, the map is $m: 1$ except at a finite number of branch points.
Let $P \in X$ and let $\mathcal{O}_P$ be the set of meromorphic functions on $X$ that are holomorphic at $P$ - it is the discrete valuation ring attached to the discrete valuation $\mathrm{ord}_P$, and its maximal ideal is the set of meromorphic functions on $X$ that are zero at $P$. Let $B$ be the integral closure of $\mathcal{O}_P$ in $\mathcal{M}(Y)$. Let $\alpha^{-1}(P)=\left\{Q_1, \ldots, Q_g\right\}$ and let $e_i$ be the number of sheets of $Y$ over $X$ that coincide at $Q_i$. Then $\mathfrak{p} B=\prod \mathfrak{q}_i^{{e_i}}$, where $\mathfrak{q}_i$ is the prime ideal $\left\{f \in B \mid f\left(Q_i\right)=0\right\}$.
This is totally amazing, but I'm having trouble figuring out why this ought to be true (I don't know enough about Riemann surfaces).
I have a few guesses:
The exponents $e_i$ (ramification index) can also be computed as follows. Take a uniformizer $\pi$ at $P$, then $\alpha^*(\pi)\in\mathcal{M}(Y)$, and let $e_i$ be the valuation (ord) of $\alpha^*(\pi)$ at the point $Q_i$ in the fiber over $P$. That is, $e_i=\mathrm{ord}_{Q_i}(\alpha^*\pi)$
I think $B$ equals the intersection $\bigcap_{i=1}^g\mathcal{O}_{Q_i}$, where $\mathcal{O}_{Q_i}\subset\mathcal{M}(Y)$ is the local ring of $Y$ at $Q_i$.
Assuming that these claims are true, I can make sense of the statement. Here's how. This MSE post mentions that if $R$ a finite intersection of DVR's, then the maximal ideals of $R$ correspond to the maximal ideals of each DVR, and localization at those maximal ideals just give back those DVR's. Hence, (2) would imply that prime ideals (or maximal ideals, since $B$ is Dedekind) $\mathfrak{P}_i$ of $B$ correspond to points $Q_i$ in the fiber over $P$, and $B_{\mathfrak{P}_i}\cong\mathcal{O}_{Q_i}$. Furthermore, in this case the base ring $\mathcal{O}_P$ is a DVR, with unique maximal ideal $\mathfrak{p}=(\pi)$. By the general theorem about Dedekind domains, the exponents $e_i$ in the factorization of $\pi B$ are exactly the valuation of $\pi$ at the localizations at various prime ideals, which are isomorphic to the local rings $\mathcal{O}_{Q_i}$. Hence, $e_i=\mathrm{ord}_{Q_i}(\alpha^*\pi)$, which equals the number of sheets at $Q_i$, and we're finished by (1).
But now I don't know how to prove (1) and (2). For (1), I guess it should be a general fact about Riemann surfaces that can be found in textbooks (?) so maybe it shouldn't be too hard.
For (2), if $f\in \mathcal{M}(Y)$ is integral over $\mathcal{O}_P$, then writing down that monic polynomial equation satisfied by $f$ (using integrality) and looking at the constant term, one can see that f cannot have any pole at those points $Q_i$, so $B\subset \bigcap_{i=1}^g\mathcal{O}_{Q_i}$. But the reverse inclusion seems tricky, and I don't know how to do it.
My questions: Are my two guesses above correct (especially the second one)? How can I prove/disprove them? Since I am not an expert on Riemann surfaces, it would be great if you could provide references if you appeal to some general theorem in Riemann surfaces.
Any help would be appreciated, thanks!!!!!