I am trying to understand the proof of the fact that UFDs are integrally closed. In addition to the lecture notes I have, there are at least two solutions on MSE: One is here: How to prove that UFD implies normal? and the other is here: UFDs are integrally closed
In all instances, I am failing to understand where and how exactly we are using the "unique factorization" property of the domain, which makes me think maybe I have never properly understood the definition of a UFD. Let's stick to the notation used in the answer of the first link:
I am thinking one place where we used "unique factorization" is at the end where we are concluding $b$ is a unit. Since $R$ is a UFD, we can write $b=u b_{1} b_{2} ... b_{n}$ where $u$ is a unit and $b_{i}$'s are irreducibles. Since $b$ does not have any irreducibles in its factorization, we get that $b=u,$ i.e., b is a unit. However, I don't think I used "uniqueness" here. I am not sure if this is an actual thing, but if $R$ was just a "factorization domain" (meaning, any nonzero element could be factored into product of irreducibles, but not necessarily in a unique way), I think we would have the same conclusion.
The other place where we use unique factorization might be at the beginning of the proof, where we take $a$ and $b$ as having no common irreducible factors, i.e. they are relatively prime. I am thinking that if an element of $R$ can have more than one factorization into irreducibles, then the following can happen: Suppose $\dfrac{s}{t}=\dfrac{abcd}{abef}$ where $s, t\in R$ and $abcd$ is one of the possible factorizations of $s$ into irreducibles, and similarly $abef$ for $t$. Then $\dfrac{s}{t}=\dfrac{cd}{ef}$ ($c, d, e, f$ all distinct). Even though $c, d, e, f$ are distinct, the elements $cd, ef \in R$ could have different factorizations into irreducibles, say $cd=klm$ and $ef =knp$. But then $\dfrac{s}{t}=\dfrac{klm}{knp}=\dfrac{lm}{np},$ and we are back to the similar situation we started with, and there is no guarantee that this process will end. i.e., we don't know if $\dfrac{s}{t}$ can be written as $\dfrac{a}{b}$ with $a, b$ relatively prime.
Is there anything I am failing to see?