Let $A$ be a reduced local Noetherian ring, and $\phi: M\to N$ a morphism of finitely generated free $A$-modules. For all $\mathfrak{p}\in\text{Spec}(A)$, let $k(\mathfrak{p})=A_\mathfrak{p}/\mathfrak{p}$ denote the residue class field and let $\phi_\mathfrak{p}:M_\mathfrak{p}/\mathfrak{p}\to N_\mathfrak{p}/\mathfrak{p}$ be the $k(\mathfrak{p})$-morphism induced by $\phi$.
Assume that $\dim_{k(\mathfrak{p})}\ \text{Im } \phi_{\mathfrak{p}}$ is constant.
(*) We have the following fact: For a finite $A$-module $M$, if $\dim_{k(\mathfrak{p})} M_\mathfrak{p}/\mathfrak{p}$ is constant over all $\mathfrak{p}\in\text{Spec}(A)$, then $M$ is free.
Then I would like to prove that
(a) $N/\text{Im}(\phi)$ and $\text{Im}(\phi)$ are free and we have an isomorphism: $N\simeq \text{Im}(\phi)\oplus N/\text{Im}(\phi)$.
(b) $\ker (\phi)$ is free and we have an isomorphism: $M\simeq \ker(\phi)\oplus \text{Im}(\phi)$
[This is essentially Lang Alg X.16, with (*) suggested to prove (a)]
I suppose for (a) we want to show there is an exact sequence $$0\to \text{Im}(\phi)\to N\to N/\text{Im}(\phi)\to 0.$$ Since we are given that $\dim_{k(\mathfrak{p})} \text{Im}(\phi_{\mathfrak{p}})$ is constant, by (*) (which I think we can apply since the image is, I think, finite $A$-module) it follows that $\text{Im}(\phi_{\mathfrak{p}})$ is free.
For (b) I need to prove that the $\ker$ is projective and finite, from which freedom follows.
My algebraic geometry background is quite weak, though Lang doesn't presuppose any really. I'm not entirely sure how to proceed, any help would be much appreciated.