  Let $F$ be an affine flat group scheme over a commutative ring $R$, and $S$
an $F$-algebra (an $R$-algebra on which $F$ acts). We define an equivariant
analogue $Q_F(S)$ of the total ring of fractions $Q(S)$ of $S$. It is the
largest $F$-algebra $T$ such that $S\subset T\subset Q(S)$, and $S$ is an
$F$-subalgebra of $T$. We study some basic properties.
  Utilizing this machinery, we give some new criteria for factoriality (UFD
property) of (semi-)invariant subrings under the action of algebraic groups,
generalizing a result of Popov. We also prove some variations of classical
results on factoriality of (semi-)invariant subrings. Some results over an
algebraically closed base field are generalized to those over an arbitrary base
field.
