Expected value and variance of ratio of two sums of two sets of random variables 
Let $X_1,X_2,\ldots,X_n$ be iid $\operatorname{Gamma}(\alpha,\beta)$ random variables. Suppose that, conditionally on $X_1,X_2,\ldots,X_n$, the random variables $Y_1,Y_2,\ldots,Y_n$ are independent and $Y_{i}\mid X_{i}\sim \operatorname{Gamma}(\alpha,\beta X_i)$. Show that $$E\left(\frac{\bar{Y}}{\bar{X}}\right)=\alpha\beta$$ and $$\operatorname{Var}\left(\frac{\bar{Y}}{\bar{X}}\right)=\alpha\beta^2E\left(\frac{\sum X_i^2}{(\sum X_i)^2}\right).$$ 

It is a question from a past comprehensive exam. The hint says "use the iterated expectation and variance formulas". But I do not see anywhere can use this hint.
 A: If $X_i \backsim \operatorname{Gamma}(\alpha,\beta)$ where $\alpha$ is the shape and $\beta$ is the scale parameter then 
$$ \mathbb{E}\left[ X_i \right] = \alpha \beta \quad \quad \mbox{and} \quad \quad  \mathbb{V}\mbox{ar}\left[ X_i \right]  = \alpha \beta^2 $$
From the properties of the gamma distribution 
$$ \overline{X} \backsim \operatorname{Gamma}\left(n \alpha, \beta/n \right) $$ 
which means
$$ \mathbb{E}\left[ \bar{X}\right] =  \alpha\beta \quad \quad \mbox{and} \quad \quad  \mathbb{V}\mbox{ar}\left[\bar{X}\right]  = \alpha \beta^2/n   $$
Then for 
$$ Y_i | X_i \backsim \operatorname{Gamma}\left(\alpha, \beta X_i \right) $$ 
$$ \mathbb{E}\left[ Y_i | X_i \right] =\alpha \beta X_i  \quad \quad \mbox{and} \quad \quad  \mathbb{V}\mbox{ar}\left[Y_i | X_i \right]  = \alpha (\beta X_i )^2  $$
From the law of total expectation we have
\begin{equation}
\begin{split}
\mathbb{E}\left[\frac{\bar{Y}}{\bar{X}}\right]&= \left.
\mathbb{E}\left[ \mathbb{E}\left[ \frac{\bar{Y}}{\bar{X}} \right| X_1, \ldots, X_n \right]  \right] \\
&=
\mathbb{E}\left[ \frac{1}{\bar{X}} \frac{1}{n} \sum_{i=1}^n\mathbb{E} [ Y_i \big| X_1, \ldots, X_n ]  \right] \\
&= 
\mathbb{E}\left[ \frac{1}{\bar{X}} \frac{1}{n} \sum_{i=1}^n\mathbb{E}[ Y_i \big| X_i ]  \right] \\
& = \mathbb{E}\left[ \frac{1}{\bar{X}} \frac{1}{n} \sum_{i=1}^n \alpha \beta X_i  \right] \\
& =  \alpha \beta \mathbb{E}\left[ \frac{1}{\bar{X}} \frac{1}{n} \sum_{i=1}^n X_i  \right] \\
& =  \alpha \beta \mathbb{E}\left[ \frac{1}{\bar{X}} \bar{X}  \right] \\
& =  \alpha \beta \mathbb{E}\left[ 1 \right] \\
& =  \alpha \beta  \\
\end{split}
\end{equation}
From the law of total variance we have
\begin{equation*}
\begin{split}
\mathbb{V}\mbox{ar}\left[\frac{\bar{Y}}{\bar{X}}\right] &= \left.
\mathbb{V}\mbox{ar}\left[ \mathbb{E}\left[ \frac{\bar{Y}}{\bar{X}} \right| X_1, \ldots, X_n \right]  \right] + \left. \mathbb{E}\left[   \mathbb{V}\mbox{ar} \left[ \frac{\bar{Y}}{\bar{X}} \right| X_1, \ldots, X_n \right]  \right] \\
&= \left.
\mathbb{V}\mbox{ar}\left[ \frac{1}{\bar{X} } \frac{1}{n}   \mathbb{E}\left[  \sum_{i=1}^nY_i\right| X_1, \ldots, X_n \right]  \right] + \left. \mathbb{E}\left[   \frac{1}{\bar{X}^2 } \frac{1}{n^2}   \mathbb{V}\mbox{ar} \left[ \sum_{i=1}^nY_i \right| X_1, \ldots, X_n \right]  \right] \\
&= 
\mathbb{V}\mbox{ar}\left[ \frac{1}{\bar{X} } \frac{1}{n}    \sum_{i=1}^n \mathbb{E}\left[ Y_i\big| X_i\right]  \right] +  \mathbb{E}\left[   \frac{1}{\bar{X}^2 } \frac{1}{n^2}   \sum_{i=1}^n \mathbb{V}\mbox{ar} [ Y_i \big| X_i]  \right] \\
&= \mathbb{V}\mbox{ar}\left[ \frac{1}{\bar{X} } \frac{1}{n}   \sum_{i=1}^n  \alpha \beta X_i  \right] +\mathbb{E}\left[   \frac{1}{\bar{X}^2 } \frac{1}{n^2}   \sum_{i=1}^n  \alpha (\beta X_i )^2  \right] \\
&= \alpha^2 \beta^2 \mathbb{V}\mbox{ar}\left[ \frac{1}{\bar{X} } \bar{X}  \right] +\mathbb{E}\left[   \frac{n^2}{ (\sum_{i=1}^n X_i)^2 } \frac{\alpha \beta^2}{n^2}   \sum_{i=1}^n   X_i^2  \right] \\
&= \alpha^2 \beta^2 \mathbb{V}\mbox{ar}\left[ 1 \right] + \alpha \beta^2 \mathbb{E}\left[   \frac{1}{ (\sum_{i=1}^n X_i)^2 }    \sum_{i=1}^n   X_i^2  \right] \\
&= \alpha \beta^2 \mathbb{E}\left[   \frac{    \sum_{i=1}^n   X_i^2 }{ (\sum_{i=1}^n X_i)^2 }   \right] \\
\end{split}
\end{equation*}
