We will study a linear first order system, a connection @ problem, on a vector bundle equipped with a connection, over a Riemann surface. We show optimal conditions on the connection forms which allow one to find a holomorphic frame, or in other words to prove the optimal regularity of our solution. The underlying geometric principle, discovered by Koszul-Malgrange, is classical and well known; it gives necessary and sufficient conditions for a connection to induce a holomorphic structure on a vector bundle over a complex manifold. Here we explore the limits of this statement when the connection is not smooth and our findings lead to a very short proof of the regularity of harmonic maps in two dimensions as well as re-proving a recent estimate of Lamm and Lin concerning conformally invariant variational problems in two dimensions.