Exercise on finitely generated $A$-modules Here is the exercise I'm trying to solve:

Let $M$ be a finitely generated $A$-module (where $A$ is a commutative ring) and let $g:M\rightarrow A^n$ a surjective $A$-module morphism. Prove that $\text{Ker}(g)$ is finitely generated.

Here is what I'd do:
Since $g$ is surjective I'd choose $\{x_1,x_2,\dots,x_n\}\subset M$ s.t. $g(x_i)=e_i$ for all $i=1\dots n$, where $e_i$ is the i-th canonical generator of the direct product $A^n$.
Then I'd consider $$\begin{align}\varphi: A^n \oplus\text{Ker}(g) &\longrightarrow M\\ ((a_1,\dots,a_n),y) &\longmapsto a_1 x_1 + \dots + a_n x_n + y\end{align}$$
which is an $A$-module isomorphism. Hence $$M \cong A^n\oplus \text{Ker}(g)$$ Since $M, A^n$ are both finitely generated as $A$-modules, $\text{Ker}(g)$ also needs to be finitely generated.
Is this acceptable? I have the feeling that it could be solved in a more concise way, without having to explicitely construct a morphism. Thanks!
 A: I doubt that there is any better way than noting that the kernel is a direct summand of $M$, hence, finitely generated too. You could circumvent this a little by noting that if $f\colon A^n\to M$ is the map $e_i\mapsto x_i$ (the first component of your $\varphi$), then $\mathrm{id}_M-fg$ maps $M$ surjectively onto $\ker g$. Perhaps this feels a bit more concise.
In case you just don't want to deal with elements, here is a closely related argument in a slightly more abstract phrasing. Consider the short exact sequence $0\to \ker g\to M\to A^n\to 0 $ and the associated exact sequence after applying $\hom(-,\ker g)$:
$$0\to\hom(A^n,\ker g)\to\hom(M,\ker g)\to\hom(\ker g,\ker g)\to \mathrm{ext}^1_A(A^n,\ker g).$$
Since $A^n$ is projective, $\mathrm{ext}^1_A(A^n,M)=0$ and so the map $\hom(M,\ker g)\to\hom(\ker g,\ker g)$, $\varphi\mapsto \varphi|_{\ker g}$, is surjective. Thus, there exists a morphism $\varphi\colon M\to \ker g$ such that $\varphi|_{\ker g}=\mathrm{id}_{\ker g}$. In particular, $\varphi$ is surjective and since $M$ is finitely generated, so is $\ker g$.
