Smoothing maps into algebraic sets and spaces of flat connections