Understanding a morphism of modules by properties of the induced residue field homomorphism

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.

-
I think your short exact sequence is the key. If we localize it at $\mathfrak{p}$ and look at the dimension over $k(\mathfrak{p})$, we should find that $$\dim \ \mathrm{Im}(\Phi)_{\mathfrak{p}} + \dim (N / \mathrm{Im}(\Phi))_{\mathfrak{p}} = \dim N_{\mathfrak{p}}.$$
Hence, the dimensions of $N/\mathrm{Im}(\Phi)_{\mathfrak{p}}$ are constant, so by (*), $N/\mathrm{Im}(\Phi)$ is free. Finally, because $N/\mathrm{Im}(\Phi)$ is free (hence projective), the short exact sequence splits.
For (b), we use basically the same argument with the short exact sequence $$0 \to \ker \Phi \to M \to \mathrm{Im}(\Phi) \to 0.$$