It is mostly a matter of developing all round musicianship. That means having an appreciation for harmony, knowing your major and minor scales, recognizing when there is a modulation to another key, understanding cadences, training your ear. Anything that improves your musicianship is a transferable skill that will help improve your playing of any piece.