Let $X=\text{Spec}(A)$ where $A$ is noetherian. Suppose $M$ is a finitelly generated $A$-module and that $M_x$ is a free $A_x$-module with finite rank for some $x\in X$. Show that there exists an open neighbourhood $U\subset X$ of $x$ such that $\widetilde{M}\big|_U$ is free.
[here $\widetilde{M}$ is the sheaf on $X$ defined by $\widetilde{M}(X_f)=M_f$ when $f\in A$]
Suppose $M_x$ is generated by $\frac{m_1}{f_1},...,\frac{m_r}{f_r}\in M_x$ with $m_i\in M$ and $f_i\notin x$. In that case $\frac{m_i}{f_i}\in M_{f_i}=\widetilde{M}(X_{f_i})$. Defining $f:=f_1\cdots f_n$, we have $X_f\subset X_{f_i}$ for all $i$, so we may assume the generators are of the form $\frac{m_i}{f^{k_i}}\in M_f$.
I'm trying to prove that $\widetilde{M}\big|_{X_f}$ is free. The fact that $M$ is finitely generated means that there is an exact sequence $A^n\stackrel{\phi}{\to} M\to 0$ where $\phi(a_1,...,a_n)=\sum_{i=1}^na_iu_i$ for some $u_i\in M$. Localizing at $f$, we have a new exact sequence $A_f^n\stackrel{\phi_f}{\to}M_f\to 0$ and an isomorphism $A^n_f/\ker(\phi_f)\simeq M_f$.
I really can't see how to prove that $A_f^n/\ker(\phi_f)$ is free, and also why is the noetherian condition necessary.
Is there maybe a better way to approach this?
Since $M_x$ is generated by $\frac{m_1}{f_1}, \ldots, \frac{m_r}{f_r}$ it is also generated by $\frac{m_1}{1}, \ldots, \frac{m_r}{1}$. That means the isomorphism $A_x^{\oplus r} \cong M_x$ can be written as $\varphi_x$ for some homomorphism $\varphi: A^{\oplus r} \rightarrow M$. Since $M$ is finitely generated $\text{coker }\varphi$ is finitely generated. And since $A$ is noetherian $\text{ker }\varphi$ is finitely generated. As localization is an exact functor, we have $(\text{ker }\varphi)_x = \text{ker }(\varphi_x) = 0$ and $(\text{coker }\varphi)_x = \text{coker}(\varphi_x) = 0$, which means each of the generators of $\text{ker } \varphi$ and $\text{coker }\varphi$ restricts to $0$ in a neighborhood of $x$. Since there are only finitely many of these generators it is clear that we can choose a $f \in A$ (edit: with $f \not \in x$) such that $U=D(f)$ is contained in the intersection of these neighborhoods. That means that $\text{ker }\varphi_f = 0$ and $\text{coker }\varphi_f=0$. So $\varphi_f$ is an isomorphism showing that $\widetilde{M}_{|U}$ is free.